VirtualBox

Changeset 97901 in vbox for trunk


Ignore:
Timestamp:
Dec 29, 2022 5:59:30 PM (2 years ago)
Author:
vboxsync
Message:

IPRT/memobj-r0drv-solaris.c: Implemented support for the fExecutable parameter for regular PAGE allocations, rejecting attempt at executable LOW and CONT allocations. This should make it possible to enable SUPDRV_USE_MEMOBJ_FOR_LDR_IMAGE on all hosts and drop RTMemExecAlloc et al.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/solaris/memobj-r0drv-solaris.c

    r96407 r97901  
    7676    /** Access during locking. */
    7777    int                 fAccess;
    78     /** Set if large pages are involved in an RTR0MEMOBJTYPE_PHYS
    79      *  allocation. */
     78    /** Set if large pages are involved in an RTR0MEMOBJTYPE_PHYS allocation. */
    8079    bool                fLargePage;
    81     /** Whether we have individual pages or a kernel-mapped virtual memory block in
    82      * an RTR0MEMOBJTYPE_PHYS_NC allocation. */
     80    /** Whether we have individual pages or a kernel-mapped virtual memory
     81     * block in an RTR0MEMOBJTYPE_PHYS_NC allocation. */
    8382    bool                fIndivPages;
     83    /** Set if executable allocation - only RTR0MEMOBJTYPE_PHYS. */
     84    bool                fExecutable;
    8485} RTR0MEMOBJSOL, *PRTR0MEMOBJSOL;
    8586
     
    630631
    631632        case RTR0MEMOBJTYPE_PAGE:
    632             ddi_umem_free(pMemSolaris->Cookie);
     633            if (!pMemSolaris->fExecutable)
     634                ddi_umem_free(pMemSolaris->Cookie);
     635            else
     636                segkmem_free(heaptext_arena, pMemSolaris->Core.pv, pMemSolaris->Core.cb);
    633637            break;
    634638
     
    642646
    643647        case RTR0MEMOBJTYPE_RES_VIRT:
    644         {
    645648            if (pMemSolaris->Core.u.ResVirt.R0Process == NIL_RTR0PROCESS)
    646649                vmem_xfree(heap_arena, pMemSolaris->Core.pv, pMemSolaris->Core.cb);
     
    648651                AssertFailed();
    649652            break;
    650         }
    651653
    652654        case RTR0MEMOBJTYPE_CONT: /* we don't use this type here. */
     
    666668    if (pMemSolaris)
    667669    {
    668         void *pvMem = ddi_umem_alloc(cb, DDI_UMEM_SLEEP, &pMemSolaris->Cookie);
     670        void *pvMem;
     671        if (!fExecutable)
     672        {
     673            pMemSolaris->Core.fFlags |= RTR0MEMOBJ_FLAGS_ZERO_AT_ALLOC;
     674            pvMem = ddi_umem_alloc(cb, DDI_UMEM_SLEEP, &pMemSolaris->Cookie);
     675        }
     676        else
     677        {
     678            pMemSolaris->Core.fFlags |= RTR0MEMOBJ_FLAGS_UNINITIALIZED_AT_ALLOC; /** @todo does segkmem_alloc zero the memory? */
     679            pvMem = segkmem_alloc(heaptext_arena, cb, KM_SLEEP);
     680        }
    669681        if (pvMem)
    670682        {
    671             pMemSolaris->Core.fFlags |= RTR0MEMOBJ_FLAGS_ZERO_AT_ALLOC;
    672683            pMemSolaris->Core.pv  = pvMem;
    673684            pMemSolaris->pvHandle = NULL;
     685            pMemSolaris->fExecutable = fExecutable;
    674686            *ppMem = &pMemSolaris->Core;
    675687            return VINF_SUCCESS;
     
    691703DECLHIDDEN(int) rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable, const char *pszTag)
    692704{
    693     NOREF(fExecutable);
     705    AssertReturn(!fExecutable, VERR_NOT_SUPPORTED);
    694706
    695707    /* Create the object */
     
    717729DECLHIDDEN(int) rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable, const char *pszTag)
    718730{
    719     NOREF(fExecutable);
     731    AssertReturn(!fExecutable, VERR_NOT_SUPPORTED);
    720732    return rtR0MemObjNativeAllocPhys(ppMem, cb, _4G - 1, PAGE_SIZE /* alignment */, pszTag);
    721733}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette