VirtualBox

Changeset 93618 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 6, 2022 9:26:15 AM (3 years ago)
Author:
vboxsync
Message:

VMM/PGMPhys: Replaced two MMR3HyperAllocOnceNoRel calls with direct SUPR3PageAllocEx call. bugref:10093

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp

    r93593 r93618  
    11431143    for (pCur = pVM->pgm.s.pRamRangesXR3; pCur; pCur = pCur->pNextR3)
    11441144    {
    1145         Assert((pCur->fFlags & PGM_RAM_RANGE_FLAGS_FLOATING) || pCur->pSelfR0 == MMHyperCCToR0(pVM, pCur));
    11461145        Assert((pCur->GCPhys     & GUEST_PAGE_OFFSET_MASK) == 0);
    11471146        Assert((pCur->GCPhysLast & GUEST_PAGE_OFFSET_MASK) == GUEST_PAGE_OFFSET_MASK);
     
    11841183{
    11851184    AssertMsg(pNew->pszDesc, ("%RGp-%RGp\n", pNew->GCPhys, pNew->GCPhysLast));
    1186     Assert((pNew->fFlags & PGM_RAM_RANGE_FLAGS_FLOATING) || pNew->pSelfR0 == MMHyperCCToR0(pVM, pNew));
    11871185
    11881186    PGM_LOCK_VOID(pVM);
     
    12191217{
    12201218    Assert(pPrev ? pPrev->pNextR3 == pRam : pVM->pgm.s.pRamRangesXR3 == pRam);
    1221     Assert((pRam->fFlags & PGM_RAM_RANGE_FLAGS_FLOATING) || pRam->pSelfR0 == MMHyperCCToR0(pVM, pRam));
    12221219
    12231220    PGM_LOCK_VOID(pVM);
     
    18201817         */
    18211818        const size_t cbRamRange = RT_UOFFSETOF_DYN(PGMRAMRANGE, aPages[cPages]);
    1822         PPGMRAMRANGE pNew;
    1823         rc = MMR3HyperAllocOnceNoRel(pVM, cbRamRange, 0, MM_TAG_PGM_PHYS, (void **)&pNew);
     1819        PPGMRAMRANGE pNew = NULL;
     1820        RTR0PTR      pNewR0 = NIL_RTR0PTR;
     1821        rc = SUPR3PageAllocEx(RT_ALIGN_Z(cbRamRange, HOST_PAGE_SIZE) >> HOST_PAGE_SHIFT, 0 /*fFlags*/,
     1822                              (void **)&pNew, &pNewR0, NULL /*paPages*/);
    18241823        AssertLogRelMsgRCReturn(rc, ("rc=%Rrc cbRamRange=%zu\n", rc, cbRamRange), rc);
    18251824
    1826         rc = pgmR3PhysInitAndLinkRamRange(pVM, pNew, GCPhys, GCPhysLast, MMHyperCCToR0(pVM, pNew), 0 /*fFlags*/, pszDesc, pPrev);
     1825        rc = pgmR3PhysInitAndLinkRamRange(pVM, pNew, GCPhys, GCPhysLast, pNewR0, 0 /*fFlags*/, pszDesc, pPrev);
    18271826        AssertLogRelMsgRCReturn(rc, ("rc=%Rrc cbRamRange=%zu\n", rc, cbRamRange), rc);
    18281827    }
     
    27822781        const size_t     cbRange = RT_UOFFSETOF_DYN(PGMREGMMIO2RANGE, RamRange.aPages[cPagesTrackedByChunk]);
    27832782        PPGMREGMMIO2RANGE pNew    = NULL;
    2784         if (   iChunk + 1 < cChunks
    2785             || cbRange >= _1M)
    2786         {
    2787             /*
    2788              * Allocate memory for the registration structure.
    2789              */
    2790             size_t const cChunkPages  = RT_ALIGN_Z(cbRange, HOST_PAGE_SIZE) >> HOST_PAGE_SHIFT;
    2791             size_t const cbChunk      = (1 + cChunkPages + 1) << HOST_PAGE_SHIFT;
    2792             AssertLogRelBreakStmt(cbChunk == (uint32_t)cbChunk, rc = VERR_OUT_OF_RANGE);
    2793             PSUPPAGE     paChunkPages = (PSUPPAGE)RTMemTmpAllocZ(sizeof(SUPPAGE) * cChunkPages);
    2794             AssertBreakStmt(paChunkPages, rc = VERR_NO_TMP_MEMORY);
    2795             RTR0PTR      R0PtrChunk   = NIL_RTR0PTR;
    2796             void        *pvChunk      = NULL;
    2797             rc = SUPR3PageAllocEx(cChunkPages, 0 /*fFlags*/, &pvChunk, &R0PtrChunk, paChunkPages);
    2798             AssertLogRelMsgRCBreakStmt(rc, ("rc=%Rrc, cChunkPages=%#zx\n", rc, cChunkPages), RTMemTmpFree(paChunkPages));
    2799 
    2800             Assert(R0PtrChunk != NIL_RTR0PTR || PGM_IS_IN_NEM_MODE(pVM));
    2801             RT_BZERO(pvChunk, cChunkPages << HOST_PAGE_SHIFT);
    2802 
    2803             pNew = (PPGMREGMMIO2RANGE)pvChunk;
    2804             pNew->RamRange.fFlags   = PGM_RAM_RANGE_FLAGS_FLOATING;
    2805             pNew->RamRange.pSelfR0  = R0PtrChunk + RT_UOFFSETOF(PGMREGMMIO2RANGE, RamRange);
    2806 
    2807             RTMemTmpFree(paChunkPages);
    2808         }
     2783
    28092784        /*
    2810          * Not so big, do a one time hyper allocation.
     2785         * Allocate memory for the registration structure.
    28112786         */
    2812         else
    2813         {
    2814             rc = MMR3HyperAllocOnceNoRel(pVM, cbRange, 0, MM_TAG_PGM_PHYS, (void **)&pNew);
    2815             AssertLogRelMsgRCBreak(rc, ("cbRange=%zu\n", cbRange));
    2816 
    2817             /*
    2818              * Initialize allocation specific items.
    2819              */
    2820             //pNew->RamRange.fFlags = 0;
    2821             pNew->RamRange.pSelfR0  = MMHyperCCToR0(pVM, &pNew->RamRange);
    2822         }
     2787        size_t const cChunkPages  = RT_ALIGN_Z(cbRange, HOST_PAGE_SIZE) >> HOST_PAGE_SHIFT;
     2788        size_t const cbChunk      = (1 + cChunkPages + 1) << HOST_PAGE_SHIFT;
     2789        AssertLogRelBreakStmt(cbChunk == (uint32_t)cbChunk, rc = VERR_OUT_OF_RANGE);
     2790        RTR0PTR      R0PtrChunk   = NIL_RTR0PTR;
     2791        void        *pvChunk      = NULL;
     2792        rc = SUPR3PageAllocEx(cChunkPages, 0 /*fFlags*/, &pvChunk, &R0PtrChunk, NULL /*paPages*/);
     2793        AssertLogRelMsgRCBreak(rc, ("rc=%Rrc, cChunkPages=%#zx\n", rc, cChunkPages));
     2794
     2795        Assert(R0PtrChunk != NIL_RTR0PTR || PGM_IS_IN_NEM_MODE(pVM));
     2796        RT_BZERO(pvChunk, cChunkPages << HOST_PAGE_SHIFT);
     2797
     2798        pNew = (PPGMREGMMIO2RANGE)pvChunk;
     2799        pNew->RamRange.fFlags   = PGM_RAM_RANGE_FLAGS_FLOATING;
     2800        pNew->RamRange.pSelfR0  = R0PtrChunk + RT_UOFFSETOF(PGMREGMMIO2RANGE, RamRange);
    28232801
    28242802        /*
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