Changeset 100357 in vbox for trunk/src/VBox/Runtime/r0drv/darwin
- Timestamp:
- Jul 4, 2023 7:00:26 AM (22 months ago)
- svn:sync-xref-src-repo-rev:
- 158087
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp
r100356 r100357 885 885 886 886 887 DECLHIDDEN(int) rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable, const char *pszTag) 888 { 887 /** 888 * Translates the PhysHighest address into a mask. 889 */ 890 static mach_vm_address_t rtR0MemObjDarwinCalcPhysMask(RTHCPHYS PhysHighest, size_t uAlignment) 891 { 892 if (PhysHighest == NIL_RTHCPHYS) 893 return uAlignment <= PAGE_SIZE ? 0 : ~(mach_vm_address_t)(uAlignment - 1); 894 895 mach_vm_address_t PhysMask = ~(mach_vm_address_t)0; 896 while (PhysMask > (PhysHighest | PAGE_OFFSET_MASK)) 897 PhysMask >>= 1; 898 PhysMask &= ~(mach_vm_address_t)(uAlignment - 1); 899 900 return PhysMask; 901 } 902 903 904 DECLHIDDEN(int) rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, 905 bool fExecutable, const char *pszTag) 906 { 907 mach_vm_address_t const PhysMask = rtR0MemObjDarwinCalcPhysMask(PhysHighest, PAGE_SIZE); 889 908 IPRT_DARWIN_SAVE_EFL_AC(); 890 909 891 int rc = rtR0MemObjNativeAllocWorker(ppMem, cb, fExecutable, true /* fContiguous */, 892 ~(uint32_t)PAGE_OFFSET_MASK, _4G - PAGE_SIZE, 910 int rc = rtR0MemObjNativeAllocWorker(ppMem, cb, fExecutable, true /* fContiguous */, PhysMask, PhysHighest, 893 911 RTR0MEMOBJTYPE_CONT, PAGE_SIZE, pszTag, false /*fOnKernelThread*/); 894 912 … … 898 916 */ 899 917 if (RT_FAILURE(rc) && cb <= PAGE_SIZE) 900 rc = rtR0MemObjNativeAllocWorker(ppMem, cb + PAGE_SIZE, fExecutable, true /* fContiguous */, 901 ~(uint32_t)PAGE_OFFSET_MASK, _4G - PAGE_SIZE, 918 rc = rtR0MemObjNativeAllocWorker(ppMem, cb + PAGE_SIZE, fExecutable, true /* fContiguous */, PhysMask, PhysHighest, 902 919 RTR0MEMOBJTYPE_CONT, PAGE_SIZE, pszTag, false /*fOnKernelThread*/); 903 920 IPRT_DARWIN_RESTORE_EFL_AC(); … … 915 932 return VERR_NOT_SUPPORTED; 916 933 } 934 mach_vm_address_t const PhysMask = rtR0MemObjDarwinCalcPhysMask(PhysHighest, uAlignment); 917 935 918 936 IPRT_DARWIN_SAVE_EFL_AC(); … … 923 941 int rc; 924 942 if (PhysHighest == NIL_RTHCPHYS) 925 rc = rtR0MemObjNativeAllocWorker(ppMem, cb, false /* fExecutable */, true /* fContiguous */, 926 uAlignment <= PAGE_SIZE ? 0 : ~(mach_vm_address_t)(uAlignment - 1) /* PhysMask*/, 927 UINT64_MAX, RTR0MEMOBJTYPE_PHYS, uAlignment, pszTag, false /*fOnKernelThread*/); 943 rc = rtR0MemObjNativeAllocWorker(ppMem, cb, false /* fExecutable */, true /* fContiguous */, PhysMask, UINT64_MAX, 944 RTR0MEMOBJTYPE_PHYS, uAlignment, pszTag, false /*fOnKernelThread*/); 928 945 else 929 946 { 930 mach_vm_address_t PhysMask = 0;931 PhysMask = ~(mach_vm_address_t)0;932 while (PhysMask > (PhysHighest | PAGE_OFFSET_MASK))933 PhysMask >>= 1;934 947 AssertReturn(PhysMask + 1 <= cb, VERR_INVALID_PARAMETER); 935 PhysMask &= ~(mach_vm_address_t)(uAlignment - 1); 936 937 rc = rtR0MemObjNativeAllocWorker(ppMem, cb, false /* fExecutable */, true /* fContiguous */, 938 PhysMask, PhysHighest, 948 rc = rtR0MemObjNativeAllocWorker(ppMem, cb, false /* fExecutable */, true /* fContiguous */, PhysMask, PhysHighest, 939 949 RTR0MEMOBJTYPE_PHYS, uAlignment, pszTag, false /*fOnKernelThread*/); 940 950 }
Note:
See TracChangeset
for help on using the changeset viewer.