VirtualBox

Changeset 31066 in vbox


Ignore:
Timestamp:
Jul 23, 2010 2:48:24 PM (15 years ago)
Author:
vboxsync
Message:

PGM: A couple of simplifications and optimizations.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PGM.cpp

    r30908 r31066  
    31183118    }
    31193119    /* Override the shadow mode is nested paging is active. */
    3120     if (HWACCMIsNestedPagingActive(pVM))
     3120    pVM->pgm.s.fNestedPaging = HWACCMIsNestedPagingActive(pVM);
     3121    if (pVM->pgm.s.fNestedPaging)
    31213122        enmShadowMode = HWACCMGetShwPagingMode(pVM);
    31223123
  • trunk/src/VBox/VMM/PGMBth.h

    r28800 r31066  
    136136          || PGM_GST_TYPE == PGM_TYPE_PROT))
    137137
    138     PVM pVM   = pVCpu->pVMR3;
    139 
    140     Assert(!HWACCMIsNestedPagingActive(pVM));
     138    PVM pVM = pVCpu->pVMR3;
     139
     140    Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     141    Assert(!pVM->pgm.s.fNestedPaging);
    141142
    142143    pgmLock(pVM);
  • trunk/src/VBox/VMM/PGMGstDefs.h

    r30889 r31066  
    8484#  define GST_IS_NX_ACTIVE(pVCpu)               (CPUMIsGuestNXEnabled(pVCpu)) /** @todo shadow this variable */
    8585#  if PGM_GST_TYPE == PGM_TYPE_PROT             /* (comment at top of PGMAllBth.h) */
    86 #   define BTH_IS_NP_ACTIVE(pVM)                HWACCMIsNestedPagingActive(pVM)
     86#   define BTH_IS_NP_ACTIVE(pVM)                (pVM->pgm.s.fNestedPaging)
    8787#  else
    8888#   define BTH_IS_NP_ACTIVE(pVM)                (false)
  • trunk/src/VBox/VMM/PGMInternal.h

    r31054 r31066  
    26462646     * This is used  */
    26472647    bool                            fLessThan52PhysicalAddressBits;
    2648     /** Alignment padding. */
    2649     bool                            afAlignment0[1];
    2650 
    2651     /*
    2652      * This will be redefined at least two more times before we're done, I'm sure.
    2653      * The current code is only to get on with the coding.
    2654      *   - 2004-06-10: initial version, bird.
    2655      *   - 2004-07-02: 1st time, bird.
    2656      *   - 2004-10-18: 2nd time, bird.
    2657      *   - 2005-07-xx: 3rd time, bird.
    2658      */
    2659 
     2648    /** Set when nested paging is active.
     2649     * This is meant to save calls to HWACCMIsNestedPagingActive and let the
     2650     * compilers optimize the code better.  Whether we use nested paging or
     2651     * not is something we find out during VMM initialization and we won't
     2652     * change this later on. */
     2653    bool                            fNestedPaging;
    26602654    /** The host paging mode. (This is what SUPLib reports.) */
    26612655    SUPPAGINGMODE                   enmHostMode;
     
    36453639int             pgmMapDeactivateCR3(PVM pVM, PPGMPOOLPAGE pShwPageCR3);
    36463640
    3647 int             pgmShwSyncPaePDPtr(PVMCPU pVCpu, RTGCPTR GCPtr, PX86PDPE pGstPdpe, PX86PDPAE *ppPD);
    3648 #ifndef IN_RC
    3649 int             pgmShwSyncLongModePDPtr(PVMCPU pVCpu, RTGCPTR64 GCPtr, PX86PML4E pGstPml4e, PX86PDPE pGstPdpe, PX86PDPAE *ppPD);
    3650 #endif
    3651 int             pgmShwGetEPTPDPtr(PVMCPU pVCpu, RTGCPTR64 GCPtr, PEPTPDPT *ppPdpt, PEPTPD *ppPD);
     3641int             pgmShwSyncPaePDPtr(PVMCPU pVCpu, RTGCPTR GCPtr, PCX86PDPE pGstPdpe, PX86PDPAE *ppPD);
    36523642
    36533643int             pgmGstLazyMap32BitPD(PVMCPU pVCpu, PX86PD *ppPd);
  • trunk/src/VBox/VMM/PGMShw.h

    r30326 r31066  
    188188    PPGMPOOL     pPool     = pVM->pgm.s.CTX_SUFF(pPool);
    189189
    190     Assert(HWACCMIsNestedPagingActive(pVM));
     190    Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     191    Assert(pVM->pgm.s.fNestedPaging);
    191192    Assert(!pVCpu->pgm.s.pShwPageCR3R3);
    192193
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r31054 r31066  
    7070DECLINLINE(int) pgmShwGetLongModePDPtr(PVMCPU pVCpu, RTGCPTR64 GCPtr, PX86PML4E *ppPml4e, PX86PDPT *ppPdpt, PX86PDPAE *ppPD);
    7171DECLINLINE(int) pgmShwGetPaePoolPagePD(PPGMCPU pPGM, RTGCPTR GCPtr, PPGMPOOLPAGE *ppShwPde);
     72#ifndef IN_RC
     73static int      pgmShwSyncLongModePDPtr(PVMCPU pVCpu, RTGCPTR64 GCPtr, PCX86PML4E pGstPml4e, PCX86PDPE pGstPdpe, PX86PDPAE *ppPD);
     74static int      pgmShwGetEPTPDPtr(PVMCPU pVCpu, RTGCPTR64 GCPtr, PEPTPDPT *ppPdpt, PEPTPD *ppPD);
     75#endif
     76
    7277
    7378/*
     
    623628    }
    624629
    625     if (!HWACCMIsNestedPagingActive(pVM))
     630    Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     631    if (!pVM->pgm.s.fNestedPaging)
    626632    {
    627633        /*
     
    912918 * @param   ppPD        Receives address of page directory
    913919 */
    914 int pgmShwSyncPaePDPtr(PVMCPU pVCpu, RTGCPTR GCPtr, PX86PDPE pGstPdpe, PX86PDPAE *ppPD)
     920int pgmShwSyncPaePDPtr(PVMCPU pVCpu, RTGCPTR GCPtr, PCX86PDPE pGstPdpe, PX86PDPAE *ppPD)
    915921{
    916922    const unsigned iPdPt    = (GCPtr >> X86_PDPT_SHIFT) & X86_PDPT_MASK_PAE;
     
    930936        RTGCPTR64   GCPdPt;
    931937        PGMPOOLKIND enmKind;
     938        Assert(pGstPdpe);
     939        X86PDPE     GstPdpe = *pGstPdpe;
    932940
    933941# if defined(IN_RC)
     
    936944# endif
    937945
    938         if (HWACCMIsNestedPagingActive(pVM) || !CPUMIsGuestPagingEnabled(pVCpu))
     946        Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     947        if (pVM->pgm.s.fNestedPaging || !CPUMIsGuestPagingEnabled(pVCpu))
    939948        {
    940949            /* AMD-V nested paging or real/protected mode without paging. */
     
    944953        else
    945954        {
    946             Assert(pGstPdpe);
    947 
    948955            if (CPUMGetGuestCR4(pVCpu) & X86_CR4_PAE)
    949956            {
    950                 if (!pGstPdpe->n.u1Present)
     957                if (!GstPdpe.n.u1Present)
    951958                {
    952959                    /* PD not present; guest must reload CR3 to change it.
     
    955962                    Assert(!HWACCMIsEnabled(pVM));
    956963
    957                     GCPdPt  = pGstPdpe->u & X86_PDPE_PG_MASK;
     964                    GCPdPt  = GstPdpe.u & X86_PDPE_PG_MASK;
    958965                    enmKind = PGMPOOLKIND_PAE_PD_PHYS;
    959                     pGstPdpe->n.u1Present = 1;
     966                    GstPdpe.n.u1Present = 1;
    960967                }
    961968                else
    962969                {
    963                     GCPdPt  = pGstPdpe->u & X86_PDPE_PG_MASK;
     970                    GCPdPt  = GstPdpe.u & X86_PDPE_PG_MASK;
    964971                    enmKind = PGMPOOLKIND_PAE_PD_FOR_PAE_PD;
    965972                }
     
    978985        /* The PD was cached or created; hook it up now. */
    979986        pPdpe->u |= pShwPage->Core.Key
    980                  | (pGstPdpe->u & ~(X86_PDPE_PG_MASK | X86_PDPE_AVL_MASK | X86_PDPE_PCD | X86_PDPE_PWT));
     987                 | (GstPdpe.u & ~(X86_PDPE_PG_MASK | X86_PDPE_AVL_MASK | X86_PDPE_PCD | X86_PDPE_PWT));
    981988
    982989# if defined(IN_RC)
     
    10511058 * @param   ppPD        Receives address of page directory
    10521059 */
    1053 int pgmShwSyncLongModePDPtr(PVMCPU pVCpu, RTGCPTR64 GCPtr, PX86PML4E pGstPml4e, PX86PDPE pGstPdpe, PX86PDPAE *ppPD)
     1060static int pgmShwSyncLongModePDPtr(PVMCPU pVCpu, RTGCPTR64 GCPtr, PCX86PML4E pGstPml4e, PCX86PDPE pGstPdpe, PX86PDPAE *ppPD)
    10541061{
    10551062    PPGMCPU        pPGM          = &pVCpu->pgm.s;
     
    10581065    const unsigned iPml4         = (GCPtr >> X86_PML4_SHIFT) & X86_PML4_MASK;
    10591066    PX86PML4E      pPml4e        = pgmShwGetLongModePML4EPtr(pPGM, iPml4);
    1060     bool           fNestedPagingOrNoGstPaging = HWACCMIsNestedPagingActive(pVM) || !CPUMIsGuestPagingEnabled(pVCpu);
     1067    Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     1068    bool           fNestedPagingOrNoGstPaging = pVM->pgm.s.fNestedPaging || !CPUMIsGuestPagingEnabled(pVCpu);
    10611069    PPGMPOOLPAGE   pShwPage;
    10621070    int            rc;
     
    12011209 * @param   ppPD        Receives address of page directory
    12021210 */
    1203 int pgmShwGetEPTPDPtr(PVMCPU pVCpu, RTGCPTR64 GCPtr, PEPTPDPT *ppPdpt, PEPTPD *ppPD)
     1211static int pgmShwGetEPTPDPtr(PVMCPU pVCpu, RTGCPTR64 GCPtr, PEPTPDPT *ppPdpt, PEPTPD *ppPD)
    12041212{
    12051213    PPGMCPU        pPGM  = &pVCpu->pgm.s;
     
    12121220    int            rc;
    12131221
    1214     Assert(HWACCMIsNestedPagingActive(pVM));
     1222    Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     1223    Assert(pVM->pgm.s.fNestedPaging);
    12151224    Assert(PGMIsLockOwner(pVM));
    12161225
     
    18291838
    18301839    /* We assume we're only called in nested paging mode. */
    1831     Assert(HWACCMIsNestedPagingActive(pVM) || pVCpu->pgm.s.enmShadowMode == PGMMODE_EPT);
     1840    Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     1841    Assert(pVM->pgm.s.fNestedPaging || pVCpu->pgm.s.enmShadowMode == PGMMODE_EPT);
    18321842    Assert(pVM->pgm.s.fMappingsDisabled);
    18331843    Assert(!(pVCpu->pgm.s.fSyncFlags & PGM_SYNC_MONITOR_CR3));
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r30895 r31066  
    906906                        RTGCPHYS GCPhys2;
    907907                        uint64_t fPageGst;
    908                         if (!HWACCMIsNestedPagingActive(pVM))
     908                        Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     909                        if (!pVM->pgm.s.fNestedPaging)
    909910                        {
    910911                            rc = PGMGstGetPage(pVCpu, pvFault, &fPageGst, &GCPhys2);
     
    11241125    unsigned        iPDSrc = 0;
    11251126#  if PGM_GST_TYPE == PGM_TYPE_PAE
    1126     X86PDPE         PdpeSrc;
    1127     PX86PDPAE       pPDSrc      = pgmGstGetPaePDPtr(pVCpu, GCPtrPage, &iPDSrc, &PdpeSrc);
     1127    X86PDPE         PdpeSrcIgn;
     1128    PX86PDPAE       pPDSrc      = pgmGstGetPaePDPtr(pVCpu, GCPtrPage, &iPDSrc, &PdpeSrcIgn);
    11281129#  else /* AMD64 */
    1129     PX86PML4E       pPml4eSrc;
    1130     X86PDPE         PdpeSrc;
    1131     PX86PDPAE       pPDSrc      = pgmGstGetLongModePDPtr(pVCpu, GCPtrPage, &pPml4eSrc, &PdpeSrc, &iPDSrc);
     1130    PX86PML4E       pPml4eSrcIgn;
     1131    X86PDPE         PdpeSrcIgn;
     1132    PX86PDPAE       pPDSrc      = pgmGstGetLongModePDPtr(pVCpu, GCPtrPage, &pPml4eSrcIgn, &PdpeSrcIgn, &iPDSrc);
    11321133#  endif
    11331134    GSTPDE          PdeSrc;
     
    20792080    if (PdeDst.n.u1Size)
    20802081    {
    2081         Assert(HWACCMIsNestedPagingActive(pVM));
     2082        Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     2083        Assert(pVM->pgm.s.fNestedPaging);
    20822084        Log(("CPU%d: SyncPage: Pde (big:%RX64) at %RGv changed behind our back!\n", pVCpu->idCpu, PdeDst.u, GCPtrPage));
    20832085        return VINF_SUCCESS;
     
    34593461    LogFlow(("VerifyAccessSyncPage: GCPtrPage=%RGv fPage=%#x uErr=%#x\n", GCPtrPage, fPage, uErr));
    34603462
    3461     Assert(!HWACCMIsNestedPagingActive(pVM));
     3463    Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     3464    Assert(!pVM->pgm.s.fNestedPaging);
    34623465#if   (   PGM_GST_TYPE == PGM_TYPE_32BIT \
    34633466       || PGM_GST_TYPE == PGM_TYPE_REAL \
     
    46514654           && PGM_GST_TYPE != PGM_TYPE_PROT))
    46524655
    4653     Assert(!HWACCMIsNestedPagingActive(pVM));
     4656    Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     4657    Assert(!pVM->pgm.s.fNestedPaging);
    46544658
    46554659    /*
     
    47984802
    47994803#  if PGM_GST_TYPE != PGM_TYPE_REAL
    4800     Assert(!HWACCMIsNestedPagingActive(pVM));
     4804    Assert(HWACCMIsNestedPagingActive(pVM) == pVM->pgm.s.fNestedPaging);
     4805    Assert(!pVM->pgm.s.fNestedPaging);
    48014806#  endif
    48024807
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r30372 r31066  
    31243124        case PGMPOOLKIND_EPT_PD_FOR_PHYS:
    31253125        {
    3126             Assert(HWACCMIsNestedPagingActive(pVM));
     3126            Assert(pVM->pgm.s.fNestedPaging);
    31273127
    31283128            const uint64_t  u64 = PGM_PAGE_GET_HCPHYS(pPhysPage) | X86_PDE4M_P | X86_PDE4M_PS;
     
    31583158        case PGMPOOLKIND_PAE_PD_PHYS:
    31593159        {
    3160             Assert(HWACCMIsNestedPagingActive(pVM));
     3160            Assert(pVM->pgm.s.fNestedPaging);
    31613161
    31623162            const uint64_t  u64 = PGM_PAGE_GET_HCPHYS(pPhysPage) | X86_PDE4M_P | X86_PDE4M_PS;
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