Changeset 57276 in vbox for trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
- Timestamp:
- Aug 11, 2015 2:39:19 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
r56290 r57276 548 548 DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem) 549 549 { 550 IPRT_LINUX_SAVE_EFL_AC(); 550 551 PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)pMem; 551 552 … … 626 627 return VERR_INTERNAL_ERROR; 627 628 } 629 IPRT_LINUX_RESTORE_EFL_ONLY_AC(); 628 630 return VINF_SUCCESS; 629 631 } … … 632 634 DECLHIDDEN(int) rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 633 635 { 636 IPRT_LINUX_SAVE_EFL_AC(); 634 637 PRTR0MEMOBJLNX pMemLnx; 635 638 int rc; … … 648 651 { 649 652 *ppMem = &pMemLnx->Core; 653 IPRT_LINUX_RESTORE_EFL_AC(); 650 654 return rc; 651 655 } … … 655 659 } 656 660 661 IPRT_LINUX_RESTORE_EFL_AC(); 657 662 return rc; 658 663 } … … 661 666 DECLHIDDEN(int) rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 662 667 { 668 IPRT_LINUX_SAVE_EFL_AC(); 663 669 PRTR0MEMOBJLNX pMemLnx; 664 670 int rc; … … 688 694 { 689 695 *ppMem = &pMemLnx->Core; 696 IPRT_LINUX_RESTORE_EFL_AC(); 690 697 return rc; 691 698 } … … 695 702 } 696 703 704 IPRT_LINUX_RESTORE_EFL_AC(); 697 705 return rc; 698 706 } … … 701 709 DECLHIDDEN(int) rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 702 710 { 711 IPRT_LINUX_SAVE_EFL_AC(); 703 712 PRTR0MEMOBJLNX pMemLnx; 704 713 int rc; … … 731 740 pMemLnx->Core.u.Cont.Phys = page_to_phys(pMemLnx->apPages[0]); 732 741 *ppMem = &pMemLnx->Core; 742 IPRT_LINUX_RESTORE_EFL_AC(); 733 743 return rc; 734 744 } … … 738 748 } 739 749 750 IPRT_LINUX_RESTORE_EFL_AC(); 740 751 return rc; 741 752 } … … 809 820 { 810 821 int rc; 822 IPRT_LINUX_SAVE_EFL_AC(); 811 823 812 824 /* … … 844 856 rc = rtR0MemObjLinuxAllocPhysSub2(ppMem, enmType, cb, uAlignment, PhysHighest, GFP_DMA); 845 857 } 858 IPRT_LINUX_RESTORE_EFL_AC(); 846 859 return rc; 847 860 } … … 954 967 DECLHIDDEN(int) rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy) 955 968 { 969 IPRT_LINUX_SAVE_EFL_AC(); 970 956 971 /* 957 972 * All we need to do here is to validate that we can use … … 964 979 pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_PHYS, NULL, cb); 965 980 if (!pMemLnx) 981 { 982 IPRT_LINUX_RESTORE_EFL_AC(); 966 983 return VERR_NO_MEMORY; 984 } 967 985 968 986 pMemLnx->Core.u.Phys.PhysBase = PhysAddr; … … 971 989 Assert(!pMemLnx->cPages); 972 990 *ppMem = &pMemLnx->Core; 991 IPRT_LINUX_RESTORE_EFL_AC(); 973 992 return VINF_SUCCESS; 974 993 } … … 977 996 DECLHIDDEN(int) rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process) 978 997 { 998 IPRT_LINUX_SAVE_EFL_AC(); 979 999 const int cPages = cb >> PAGE_SHIFT; 980 1000 struct task_struct *pTask = rtR0ProcessToLinuxTask(R0Process); … … 997 1017 pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(RT_OFFSETOF(RTR0MEMOBJLNX, apPages[cPages]), RTR0MEMOBJTYPE_LOCK, (void *)R3Ptr, cb); 998 1018 if (!pMemLnx) 1019 { 1020 IPRT_LINUX_RESTORE_EFL_AC(); 999 1021 return VERR_NO_MEMORY; 1022 } 1000 1023 1001 1024 papVMAs = (struct vm_area_struct **)RTMemAlloc(sizeof(*papVMAs) * cPages); … … 1048 1071 *ppMem = &pMemLnx->Core; 1049 1072 1073 IPRT_LINUX_RESTORE_EFL_AC(); 1050 1074 return VINF_SUCCESS; 1051 1075 } … … 1068 1092 1069 1093 rtR0MemObjDelete(&pMemLnx->Core); 1094 IPRT_LINUX_RESTORE_EFL_AC(); 1070 1095 return rc; 1071 1096 } … … 1074 1099 DECLHIDDEN(int) rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, uint32_t fAccess) 1075 1100 { 1101 IPRT_LINUX_SAVE_EFL_AC(); 1076 1102 void *pvLast = (uint8_t *)pv + cb - 1; 1077 1103 size_t const cPages = cb >> PAGE_SHIFT; … … 1106 1132 pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(RT_OFFSETOF(RTR0MEMOBJLNX, apPages[cPages]), RTR0MEMOBJTYPE_LOCK, pv, cb); 1107 1133 if (!pMemLnx) 1134 { 1135 IPRT_LINUX_RESTORE_EFL_AC(); 1108 1136 return VERR_NO_MEMORY; 1137 } 1109 1138 1110 1139 /* … … 1147 1176 *ppMem = &pMemLnx->Core; 1148 1177 1178 IPRT_LINUX_RESTORE_EFL_AC(); 1149 1179 return VINF_SUCCESS; 1150 1180 } 1151 1181 1152 1182 rtR0MemObjDelete(&pMemLnx->Core); 1183 IPRT_LINUX_RESTORE_EFL_AC(); 1153 1184 return rc; 1154 1185 } … … 1158 1189 { 1159 1190 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22) 1191 IPRT_LINUX_SAVE_EFL_AC(); 1160 1192 const size_t cPages = cb >> PAGE_SHIFT; 1161 1193 struct page *pDummyPage; … … 1172 1204 */ 1173 1205 pDummyPage = alloc_page(GFP_HIGHUSER | __GFP_NOWARN); 1174 if ( !pDummyPage)1175 return VERR_NO_MEMORY;1176 papPages = RTMemAlloc(sizeof(*papPages) * cPages);1177 if (papPages)1178 {1179 void *pv;1180 size_t iPage = cPages;1181 while (iPage-- > 0)1182 papPages[iPage] = pDummyPage;1206 if (pDummyPage) 1207 { 1208 papPages = RTMemAlloc(sizeof(*papPages) * cPages); 1209 if (papPages) 1210 { 1211 void *pv; 1212 size_t iPage = cPages; 1213 while (iPage-- > 0) 1214 papPages[iPage] = pDummyPage; 1183 1215 # ifdef VM_MAP 1184 pv = vmap(papPages, cPages, VM_MAP, PAGE_KERNEL_RO);1216 pv = vmap(papPages, cPages, VM_MAP, PAGE_KERNEL_RO); 1185 1217 # else 1186 pv = vmap(papPages, cPages, VM_ALLOC, PAGE_KERNEL_RO);1218 pv = vmap(papPages, cPages, VM_ALLOC, PAGE_KERNEL_RO); 1187 1219 # endif 1188 RTMemFree(papPages); 1189 if (pv) 1190 { 1191 PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_RES_VIRT, pv, cb); 1192 if (pMemLnx) 1193 { 1194 pMemLnx->Core.u.ResVirt.R0Process = NIL_RTR0PROCESS; 1195 pMemLnx->cPages = 1; 1196 pMemLnx->apPages[0] = pDummyPage; 1197 *ppMem = &pMemLnx->Core; 1198 return VINF_SUCCESS; 1199 } 1200 vunmap(pv); 1201 } 1202 } 1203 __free_page(pDummyPage); 1220 RTMemFree(papPages); 1221 if (pv) 1222 { 1223 PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_RES_VIRT, pv, cb); 1224 if (pMemLnx) 1225 { 1226 pMemLnx->Core.u.ResVirt.R0Process = NIL_RTR0PROCESS; 1227 pMemLnx->cPages = 1; 1228 pMemLnx->apPages[0] = pDummyPage; 1229 *ppMem = &pMemLnx->Core; 1230 IPRT_LINUX_RESTORE_EFL_AC(); 1231 return VINF_SUCCESS; 1232 } 1233 vunmap(pv); 1234 } 1235 } 1236 __free_page(pDummyPage); 1237 } 1238 IPRT_LINUX_RESTORE_EFL_AC(); 1204 1239 return VERR_NO_MEMORY; 1205 1240 … … 1216 1251 DECLHIDDEN(int) rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process) 1217 1252 { 1253 IPRT_LINUX_SAVE_EFL_AC(); 1218 1254 PRTR0MEMOBJLNX pMemLnx; 1219 1255 void *pv; … … 1233 1269 pv = rtR0MemObjLinuxDoMmap(R3PtrFixed, cb, uAlignment, pTask, RTMEM_PROT_NONE); 1234 1270 if (pv == (void *)-1) 1271 { 1272 IPRT_LINUX_RESTORE_EFL_AC(); 1235 1273 return VERR_NO_MEMORY; 1274 } 1236 1275 1237 1276 pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_RES_VIRT, pv, cb); … … 1239 1278 { 1240 1279 rtR0MemObjLinuxDoMunmap(pv, cb, pTask); 1280 IPRT_LINUX_RESTORE_EFL_AC(); 1241 1281 return VERR_NO_MEMORY; 1242 1282 } … … 1244 1284 pMemLnx->Core.u.ResVirt.R0Process = R0Process; 1245 1285 *ppMem = &pMemLnx->Core; 1286 IPRT_LINUX_RESTORE_EFL_AC(); 1246 1287 return VINF_SUCCESS; 1247 1288 } … … 1255 1296 PRTR0MEMOBJLNX pMemLnxToMap = (PRTR0MEMOBJLNX)pMemToMap; 1256 1297 PRTR0MEMOBJLNX pMemLnx; 1298 IPRT_LINUX_SAVE_EFL_AC(); 1257 1299 1258 1300 /* Fail if requested to do something we can't. */ … … 1326 1368 pMemLnx->Core.u.Mapping.R0Process = NIL_RTR0PROCESS; 1327 1369 *ppMem = &pMemLnx->Core; 1370 IPRT_LINUX_RESTORE_EFL_AC(); 1328 1371 return VINF_SUCCESS; 1329 1372 } … … 1331 1374 } 1332 1375 1376 IPRT_LINUX_RESTORE_EFL_AC(); 1333 1377 return rc; 1334 1378 } … … 1395 1439 RTHCPHYS DummyPhys; 1396 1440 #endif 1441 IPRT_LINUX_SAVE_EFL_AC(); 1397 1442 1398 1443 /* … … 1410 1455 pDummyPage = alloc_page(GFP_USER | __GFP_NOWARN); 1411 1456 if (!pDummyPage) 1457 { 1458 IPRT_LINUX_RESTORE_EFL_AC(); 1412 1459 return VERR_NO_MEMORY; 1460 } 1413 1461 SetPageReserved(pDummyPage); 1414 1462 DummyPhys = page_to_phys(pDummyPage); … … 1564 1612 pMemLnx->Core.u.Mapping.R0Process = R0Process; 1565 1613 *ppMem = &pMemLnx->Core; 1614 IPRT_LINUX_RESTORE_EFL_AC(); 1566 1615 return VINF_SUCCESS; 1567 1616 } … … 1578 1627 #endif 1579 1628 1629 IPRT_LINUX_RESTORE_EFL_AC(); 1580 1630 return rc; 1581 1631 }
Note:
See TracChangeset
for help on using the changeset viewer.