Changeset 29831 in vbox for trunk/src/VBox/Runtime/r0drv/freebsd/alloc-r0drv-freebsd.c
- Timestamp:
- May 26, 2010 9:13:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/freebsd/alloc-r0drv-freebsd.c
r29765 r29831 62 62 if (fFlags & RTMEMHDR_FLAG_EXEC) 63 63 { 64 # if USE_KMEM_ALLOC_PROT 65 pHdr = (PRTMEMHDR)kmem_alloc_prot(kernel_map, cb + sizeof(*pHdr), 66 VM_PROT_ALL, VM_PROT_ALL, KERNBASE); 67 # else 68 vm_object_t pVmObject = NULL; 64 69 vm_offset_t Addr = KERNBASE; 65 70 cbAllocated = RT_ALIGN_Z(cb + sizeof(*pHdr), PAGE_SIZE); 66 71 72 pVmObject = vm_object_allocate(OBJT_DEFAULT, cbAllocated >> PAGE_SHIFT); 73 if (!pVmObject) 74 return NULL; 75 67 76 /* Addr contains a start address vm_map_find will start searching for suitable space at. */ 68 int rc = vm_map_find(kernel_map, NULL, 0, &Addr, 69 cbAllocated, 70 TRUE, VM_PROT_ALL, VM_PROT_ALL, 0); 77 int rc = vm_map_find(kernel_map, pVmObject, 0, &Addr, 78 cbAllocated, TRUE, VM_PROT_ALL, VM_PROT_ALL, 0); 71 79 if (rc == KERN_SUCCESS) 72 80 { 73 /* Add the pages. */ 74 vm_offset_t AddressDst = Addr; 75 bool fSuccess = true; 76 77 do 78 { 79 vm_page_t pPage; 80 81 pPage = vm_page_alloc(NULL, 0, 82 VM_ALLOC_NOBUSY | VM_ALLOC_SYSTEM | 83 VM_ALLOC_WIRED | VM_ALLOC_NOOBJ); 84 if (pPage) 85 { 86 /* Put the page into the page table now. */ 87 MY_PMAP_ENTER(kernel_map->pmap, AddressDst, pPage, VM_PROT_ALL, 88 TRUE); 89 } 90 else 91 { 92 /* 93 * Allocation failed. vm_map_remove will remove any 94 * page already allocated. 95 */ 96 fSuccess = false; 97 break; 98 } 99 AddressDst += PAGE_SIZE; 100 } while(AddressDst < (Addr + cbAllocated)); 101 102 if (fSuccess) 81 rc = vm_map_wire(kernel_map, Addr, Addr + cbAllocated, 82 VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); 83 if (rc == KERN_SUCCESS) 103 84 { 104 85 pHdr = (PRTMEMHDR)Addr; … … 110 91 vm_map_remove(kernel_map, 111 92 Addr, 112 Addr + cb );93 Addr + cbAllocated); 113 94 } 95 else 96 vm_object_deallocate(pVmObject); 97 # endif 114 98 } 115 99 else … … 138 122 #ifdef RT_ARCH_AMD64 139 123 if (pHdr->fFlags & RTMEMHDR_FLAG_EXEC) 124 # if USE_KMEM_ALLOC_PROT 125 kmem_free(kernel_map, (vm_offset_t)pHdr, pHdr->cb); 126 # else 140 127 vm_map_remove(kernel_map, (vm_offset_t)pHdr, ((vm_offset_t)pHdr) + pHdr->cb); 128 # endif 141 129 else 142 130 #endif
Note:
See TracChangeset
for help on using the changeset viewer.