VirtualBox

Changeset 93617 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 6, 2022 8:35:16 AM (3 years ago)
Author:
vboxsync
Message:

VMM/PGMPool: Replaced MMR3HyperAllocOnceNoRel call with direct SUPR3PageAllocEx call, replacing a few associated MMHyperCCToR3/R0 calls with speedier pgmPoolConvertPageToR3/R0 ones. bugref:10093

Location:
trunk/src/VBox/VMM
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r93595 r93617  
    141141    AssertRCReturn(rc, rc);
    142142
    143     pVCpu->pgm.s.pShwPageCR3R3 = (R3PTRTYPE(PPGMPOOLPAGE))MMHyperCCToR3(pVM, pNewShwPageCR3);
    144     pVCpu->pgm.s.pShwPageCR3R0 = (R0PTRTYPE(PPGMPOOLPAGE))MMHyperCCToR0(pVM, pNewShwPageCR3);
     143    pVCpu->pgm.s.pShwPageCR3R3 = pgmPoolConvertPageToR3(pPool, pNewShwPageCR3);
     144    pVCpu->pgm.s.pShwPageCR3R0 = pgmPoolConvertPageToR0(pPool, pNewShwPageCR3);
    145145
    146146    /* Mark the page as locked; disallow flushing. */
     
    42434243    AssertFatalRC(rc2);
    42444244
    4245     pVCpu->pgm.s.CTX_SUFF(pShwPageCR3) = pNewShwPageCR3;
    4246 #  ifdef IN_RING0
    4247     pVCpu->pgm.s.pShwPageCR3R3 = MMHyperCCToR3(pVM, pVCpu->pgm.s.CTX_SUFF(pShwPageCR3));
    4248 #  else
    4249     pVCpu->pgm.s.pShwPageCR3R0 = MMHyperCCToR0(pVM, pVCpu->pgm.s.CTX_SUFF(pShwPageCR3));
    4250 #  endif
     4245    pVCpu->pgm.s.pShwPageCR3R3 = pgmPoolConvertPageToR3(pPool, pNewShwPageCR3);
     4246    pVCpu->pgm.s.pShwPageCR3R0 = pgmPoolConvertPageToR0(pPool, pNewShwPageCR3);
    42514247
    42524248    /* Set the current hypervisor CR3. */
  • trunk/src/VBox/VMM/VMMAll/PGMAllShw.h

    r93554 r93617  
    245245    AssertLogRelRCReturnStmt(rc, PGM_UNLOCK(pVM), rc);
    246246
    247     pVCpu->pgm.s.pShwPageCR3R3 = (R3PTRTYPE(PPGMPOOLPAGE))MMHyperCCToR3(pVM, pNewShwPageCR3);
    248     pVCpu->pgm.s.pShwPageCR3R0 = (R0PTRTYPE(PPGMPOOLPAGE))MMHyperCCToR0(pVM, pNewShwPageCR3);
     247    pVCpu->pgm.s.pShwPageCR3R3 = pgmPoolConvertPageToR3(pVM->pgm.s.CTX_SUFF(pPool), pNewShwPageCR3);
     248    pVCpu->pgm.s.pShwPageCR3R0 = pgmPoolConvertPageToR0(pVM->pgm.s.CTX_SUFF(pPool), pNewShwPageCR3);
    249249
    250250    PGM_UNLOCK(pVM);
  • trunk/src/VBox/VMM/VMMR3/PGMPool.cpp

    r93554 r93617  
    233233    cb += cMaxPhysExts * sizeof(PGMPOOLPHYSEXT);
    234234    PPGMPOOL pPool;
    235     rc = MMR3HyperAllocOnceNoRel(pVM, cb, 0, MM_TAG_PGM_POOL, (void **)&pPool);
     235    RTR0PTR  pPoolR0;
     236    rc = SUPR3PageAllocEx(RT_ALIGN_32(cb, HOST_PAGE_SIZE) >> HOST_PAGE_SHIFT, 0 /*fFlags*/, (void **)&pPool, &pPoolR0, NULL);
    236237    if (RT_FAILURE(rc))
    237238        return rc;
    238     pVM->pgm.s.pPoolR3 = pPool;
    239     pVM->pgm.s.pPoolR0 = MMHyperR3ToR0(pVM, pPool);
     239    Assert(ASMMemIsZero(pPool, cb));
     240    pVM->pgm.s.pPoolR3 = pPool->pPoolR3 = pPool;
     241    pVM->pgm.s.pPoolR0 = pPool->pPoolR0 = pPoolR0;
    240242
    241243    /*
     
    250252    PPGMPOOLUSER paUsers = (PPGMPOOLUSER)&pPool->aPages[pPool->cMaxPages];
    251253    pPool->paUsersR3 = paUsers;
    252     pPool->paUsersR0 = MMHyperR3ToR0(pVM, paUsers);
     254    pPool->paUsersR0 = pPoolR0 + (uintptr_t)paUsers - (uintptr_t)pPool;
    253255    for (unsigned i = 0; i < cMaxUsers; i++)
    254256    {
     
    262264    PPGMPOOLPHYSEXT paPhysExts = (PPGMPOOLPHYSEXT)&paUsers[cMaxUsers];
    263265    pPool->paPhysExtsR3 = paPhysExts;
    264     pPool->paPhysExtsR0 = MMHyperR3ToR0(pVM, paPhysExts);
     266    pPool->paPhysExtsR0 = pPoolR0 + (uintptr_t)paPhysExts - (uintptr_t)pPool;
    265267    for (unsigned i = 0; i < cMaxPhysExts; i++)
    266268    {
  • trunk/src/VBox/VMM/include/PGMInternal.h

    r93593 r93617  
    19841984    /** The VM handle - R0 Ptr. */
    19851985    R0PTRTYPE(PVMCC)            pVMR0;
     1986    /** The ring-3 pointer to this structure. */
     1987    R3PTRTYPE(struct PGMPOOL *) pPoolR3;
     1988    /** The ring-0 pointer to this structure. */
     1989    R0PTRTYPE(struct PGMPOOL *) pPoolR0;
    19861990    /** The max pool size. This includes the special IDs. */
    19871991    uint16_t                    cMaxPages;
     
    36663670void            pgmPoolResetDirtyPage(PVMCC pVM, RTGCPTR GCPtrPage);
    36673671
     3672/** Gets the ring-0 pointer for the given pool page. */
     3673DECLINLINE(R0PTRTYPE(PPGMPOOLPAGE)) pgmPoolConvertPageToR0(PPGMPOOL pPool, PPGMPOOLPAGE pPage)
     3674{
     3675#ifdef IN_RING3
     3676    size_t offPage = (uintptr_t)pPage - (uintptr_t)pPool;
     3677# ifdef VBOX_STRICT
     3678    size_t iPage   = (offPage - RT_UOFFSETOF(PGMPOOL, aPages)) / sizeof(*pPage);
     3679    AssertReturn(iPage < pPool->cMaxPages, NIL_RTR0PTR);
     3680    AssertReturn(iPage * sizeof(*pPage) + RT_UOFFSETOF(PGMPOOL, aPages) == offPage, NIL_RTR0PTR);
     3681# endif
     3682    return pPool->pPoolR0 + offPage;
     3683#else
     3684    RT_NOREF(pPool);
     3685    return pPage;
     3686#endif
     3687}
     3688
     3689/** Gets the ring-3 pointer for the given pool page. */
     3690DECLINLINE(R3PTRTYPE(PPGMPOOLPAGE)) pgmPoolConvertPageToR3(PPGMPOOL pPool, PPGMPOOLPAGE pPage)
     3691{
     3692#ifdef IN_RING3
     3693    RT_NOREF(pPool);
     3694    return pPage;
     3695#else
     3696    size_t offPage = (uintptr_t)pPage - (uintptr_t)pPool;
     3697# ifdef VBOX_STRICT
     3698    size_t iPage   = (offPage - RT_UOFFSETOF(PGMPOOL, aPages)) / sizeof(*pPage);
     3699    AssertReturn(iPage < pPool->cMaxPages, NIL_RTR3PTR);
     3700    AssertReturn(iPage * sizeof(*pPage) + RT_UOFFSETOF(PGMPOOL, aPages) == offPage, NIL_RTR3PTR);
     3701# endif
     3702    return pPool->pPoolR3 + offPage;
     3703#endif
     3704}
     3705
    36683706int             pgmR3ExitShadowModeBeforePoolFlush(PVMCPU pVCpu);
    36693707int             pgmR3ReEnterShadowModeAfterPoolFlush(PVM pVM, PVMCPU pVCpu);
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