Changeset 22679 in vbox for trunk/src/VBox/Runtime/r0drv/linux
- Timestamp:
- Sep 1, 2009 3:13:42 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 51780
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
r22617 r22679 1154 1154 #ifdef VBOX_USE_PAE_HACK 1155 1155 /** 1156 * Replace the PFN of a PTE entry of a reserved page. This hack is required for older Linux 1157 * kernels which don't provide remap_pfn_range(). 1156 * Replace the PFN of a PTE with the address of the actual page. 1157 * 1158 * The caller maps a reserved dummy page at the address with the desired access 1159 * and flags. 1160 * 1161 * This hack is required for older Linux kernels which don't provide 1162 * remap_pfn_range(). 1163 * 1164 * @returns 0 on success, -ENOMEM on failure. 1165 * @param mm The memory context. 1166 * @param ulAddr The mapping address. 1167 * @param Phys The physical address of the page to map. 1158 1168 */ 1159 static int fixPte(struct mm_struct *mm, unsigned long ulAddr, unsigned long long u64Phys)1169 static int rtR0MemObjLinuxFixPte(struct mm_struct *mm, unsigned long ulAddr, RTHCPHYS Phys) 1160 1170 { 1161 1171 int rc = -ENOMEM; … … 1175 1185 pte_t pte = *ptep; 1176 1186 pte.pte_high &= 0xfff00000; 1177 pte.pte_high |= (( u64Phys >> 32) & 0x000fffff);1187 pte.pte_high |= ((Phys >> 32) & 0x000fffff); 1178 1188 pte.pte_low &= 0x00000fff; 1179 pte.pte_low |= ( u64Phys & 0xfffff000);1189 pte.pte_low |= (Phys & 0xfffff000); 1180 1190 set_pte(ptep, pte); 1181 1191 pte_unmap(ptep); … … 1229 1239 size_t iPage; 1230 1240 #ifdef VBOX_USE_PAE_HACK 1231 struct page 1241 struct page *pDummyPage = alloc_page(GFP_USER); 1232 1242 RTHCPHYS DummyPhys; 1233 1243 1234 1244 if (!pDummyPage) 1235 goto error; 1236 1245 goto l_error; 1237 1246 SetPageReserved(pDummyPage); 1238 1247 DummyPhys = page_to_phys(pDummyPage); 1239 1248 #endif 1249 1240 1250 rc = 0; 1241 1251 if (pMemLnxToMap->cPages) … … 1262 1272 #elif defined(VBOX_USE_PAE_HACK) 1263 1273 rc = remap_page_range(vma, ulAddrCur, DummyPhys, PAGE_SIZE, fPg); 1264 if (rc) 1265 { 1266 rc = VERR_NO_MEMORY; 1267 break; 1268 } 1269 rc = fixPte(pTask->mm, ulAddrCur, Phys); 1274 if (!rc) 1275 rc = rtR0MemObjLinuxFixPte(pTask->mm, ulAddrCur, Phys); 1270 1276 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE) 1271 1277 rc = remap_page_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg); … … 1309 1315 #elif defined(VBOX_USE_PAE_HACK) 1310 1316 rc = remap_page_range(vma, ulAddrCur, DummyPhys, PAGE_SIZE, fPg); 1311 if (rc) 1312 { 1313 rc = VERR_NO_MEMORY; 1314 break; 1315 } 1316 rc = fixPte(pTask->mm, ulAddrCur, Phys); 1317 if (!rc) 1318 rc = rtR0MemObjLinuxFixPte(pTask->mm, ulAddrCur, Phys); 1317 1319 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE) 1318 1320 rc = remap_page_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg); … … 1328 1330 } 1329 1331 } 1330 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11) && defined(CONFIG_X86_PAE)1332 #ifdef VBOX_USE_PAE_HACK 1331 1333 __free_page(pDummyPage); 1332 1334 #endif … … 1345 1347 */ 1346 1348 MY_DO_MUNMAP(pTask->mm, (unsigned long)pv, pMemLnxToMap->Core.cb); 1347 if (rc != VERR_INTERNAL_ERROR)1348 rc = VERR_NO_MEMORY;1349 1349 } 1350 1350 1351 1351 #ifdef VBOX_USE_PAE_HACK 1352 error:1352 l_error: 1353 1353 #endif 1354 1354 up_write(&pTask->mm->mmap_sem);
Note:
See TracChangeset
for help on using the changeset viewer.