VirtualBox

Changeset 104841 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jun 5, 2024 1:00:55 AM (8 months ago)
Author:
vboxsync
Message:

IPRT: Moved and corrected rtR0MemObjNativeAllocPage size restrictions for NT. bugref:10687

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/nt/memobj-r0drv-nt.cpp

    r100357 r104841  
    258258DECLHIDDEN(int) rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable, const char *pszTag)
    259259{
    260     AssertMsgReturn(cb <= _1G, ("%#x\n", cb), VERR_OUT_OF_RANGE); /* for safe size_t -> ULONG */
    261260    RT_NOREF1(fExecutable);
    262261
     
    316315        }
    317316    }
     317
     318    /*
     319     * There are serveral limiting factors here.  First there the ULONG length
     320     * parameter in the IoAllocateMdl call that means the absolute maximum is
     321     * 4GiB - PAGE_SIZE.  That API is documented to limit the max length
     322     * differently for the windows versions:
     323     *  - Pre-vista: (65535 - sizeof(MLD)/sizeof(ULONG_PTR)) * PAGE_SIZE
     324     *  - Vista & Server 2008: 2GiB - PAGE_SIZE.
     325     *  - Windows 7 & Server 2008 R2 and higher: 4GiB - PAGE_SIZE.
     326     *
     327     * Before that we've got the limitations of the pool code and available
     328     * kernel mapping space (32-bit).
     329     */
     330#if ARCH_BITS == 32
     331    AssertMsgReturn(cb < _512M, ("%#x\n", cb), VERR_OUT_OF_RANGE);
     332#else
     333    AssertMsgReturn(cb < _4G, ("%#x\n", cb), VERR_OUT_OF_RANGE);
     334#endif
    318335
    319336    /*
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