Changeset 81587 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Oct 30, 2019 1:07:15 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134334
- Location:
- trunk/src/VBox/Runtime/r0drv/linux
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
r80327 r81587 87 87 * This means it has to be given back as one chunk. */ 88 88 bool fContiguous; 89 /** Set if executable allocation. */ 90 bool fExecutable; 89 91 /** Set if we've vmap'ed the memory into ring-0. */ 90 92 bool fMappedToRing0; … … 290 292 * @param fFlagsLnx The page allocation flags (GPFs). 291 293 * @param fContiguous Whether the allocation must be contiguous. 294 * @param fExecutable Whether the memory must be executable. 292 295 * @param rcNoMem What to return when we're out of pages. 293 296 */ 294 297 static int rtR0MemObjLinuxAllocPages(PRTR0MEMOBJLNX *ppMemLnx, RTR0MEMOBJTYPE enmType, size_t cb, 295 size_t uAlignment, gfp_t fFlagsLnx, bool fContiguous, int rcNoMem)298 size_t uAlignment, gfp_t fFlagsLnx, bool fContiguous, bool fExecutable, int rcNoMem) 296 299 { 297 300 size_t iPage; … … 372 375 { 373 376 pMemLnx->apPages[iPage] = &paPages[iPage]; 374 MY_SET_PAGES_EXEC(pMemLnx->apPages[iPage], 1); 377 if (fExecutable) 378 MY_SET_PAGES_EXEC(pMemLnx->apPages[iPage], 1); 375 379 if (PageHighMem(pMemLnx->apPages[iPage])) 376 380 BUG(); … … 380 384 #endif /* < 2.4.22 */ 381 385 pMemLnx->fContiguous = fContiguous; 386 pMemLnx->fExecutable = fExecutable; 382 387 383 388 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) … … 410 415 */ 411 416 printk("rtR0MemObjLinuxAllocPages(cb=0x%lx, uAlignment=0x%lx): alloc_pages(..., %d) returned physical memory at 0x%lx!\n", 412 417 (unsigned long)cb, (unsigned long)uAlignment, rtR0MemObjLinuxOrder(cPages), (unsigned long)page_to_phys(pMemLnx->apPages[0])); 413 418 rtR0MemObjLinuxFreePages(pMemLnx); 414 419 return rcNoMem; … … 439 444 { 440 445 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) 441 /* 442 * See SetPageReserved() in rtR0MemObjLinuxAllocPages() 443 */ 446 /* See SetPageReserved() in rtR0MemObjLinuxAllocPages() */ 444 447 ClearPageReserved(pMemLnx->apPages[iPage]); 445 448 #endif 446 #if LINUX_VERSION_CODE >=KERNEL_VERSION(2, 4, 22)447 #else 448 MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1);449 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 22) 450 if (pMemLnx->fExecutable) 451 MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1); 449 452 #endif 450 453 } … … 663 666 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22) 664 667 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_HIGHUSER, 665 false /* non-contiguous */, VERR_NO_MEMORY);668 false /* non-contiguous */, fExecutable, VERR_NO_MEMORY); 666 669 #else 667 670 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_USER, 668 false /* non-contiguous */, VERR_NO_MEMORY);671 false /* non-contiguous */, fExecutable, VERR_NO_MEMORY); 669 672 #endif 670 673 if (RT_SUCCESS(rc)) … … 697 700 /* ZONE_DMA32: 0-4GB */ 698 701 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_DMA32, 699 false /* non-contiguous */, VERR_NO_LOW_MEMORY);702 false /* non-contiguous */, fExecutable, VERR_NO_LOW_MEMORY); 700 703 if (RT_FAILURE(rc)) 701 704 #endif … … 703 706 /* ZONE_DMA: 0-16MB */ 704 707 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_DMA, 705 false /* non-contiguous */, VERR_NO_LOW_MEMORY);708 false /* non-contiguous */, fExecutable, VERR_NO_LOW_MEMORY); 706 709 #else 707 710 # ifdef CONFIG_X86_PAE … … 709 712 /* ZONE_NORMAL: 0-896MB */ 710 713 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_USER, 711 false /* non-contiguous */, VERR_NO_LOW_MEMORY);714 false /* non-contiguous */, fExecutable, VERR_NO_LOW_MEMORY); 712 715 #endif 713 716 if (RT_SUCCESS(rc)) … … 739 742 /* ZONE_DMA32: 0-4GB */ 740 743 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_DMA32, 741 true /* contiguous */, VERR_NO_CONT_MEMORY);744 true /* contiguous */, fExecutable, VERR_NO_CONT_MEMORY); 742 745 if (RT_FAILURE(rc)) 743 746 #endif … … 745 748 /* ZONE_DMA: 0-16MB */ 746 749 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_DMA, 747 true /* contiguous */, VERR_NO_CONT_MEMORY);750 true /* contiguous */, fExecutable, VERR_NO_CONT_MEMORY); 748 751 #else 749 752 /* ZONE_NORMAL (32-bit hosts): 0-896MB */ 750 753 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_USER, 751 true /* contiguous */, VERR_NO_CONT_MEMORY);754 true /* contiguous */, fExecutable, VERR_NO_CONT_MEMORY); 752 755 #endif 753 756 if (RT_SUCCESS(rc)) … … 796 799 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, enmType, cb, uAlignment, fGfp, 797 800 enmType == RTR0MEMOBJTYPE_PHYS /* contiguous / non-contiguous */, 798 VERR_NO_PHYS_MEMORY);801 false /*fExecutable*/, VERR_NO_PHYS_MEMORY); 799 802 if (RT_FAILURE(rc)) 800 803 return rc; -
trunk/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h
r80713 r81587 338 338 339 339 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) 340 # define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages) 341 # define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages) 340 # if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) /* The interface was removed, but we only need it for < 2.4.22, so who cares. */ 341 # define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages) 342 # define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages) 343 # endif 342 344 #else 343 345 # define MY_SET_PAGES_EXEC(pPages, cPages) \
Note:
See TracChangeset
for help on using the changeset viewer.