VirtualBox

Changeset 86476 in vbox for trunk/src


Ignore:
Timestamp:
Oct 7, 2020 7:53:07 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
140786
Message:

VMM/PGM: Working on eliminating page table bitfield use. bugref:9841 bugref:9746

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r86466 r86476  
    14281428                AssertReturn(pPde, VERR_INTERNAL_ERROR_3);
    14291429                Log(("pgmShwMakePageSupervisorAndWritable: PDE=%#llx", pPde->u));
    1430                 pPde->n.u1Write = 1;
     1430                pPde->u |= X86_PDE_RW;
    14311431                Log(("-> PDE=%#llx (PAE)\n", pPde->u));
    14321432                break;
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r86468 r86476  
    467467     * Set the accessed and dirty flags.
    468468     */
     469/** @todo Use atomics here as we don't own the lock and stuff: */
    469470#   if PGM_GST_TYPE == PGM_TYPE_AMD64
    470471    GstWalk.Pml4e.u     |= X86_PML4E_A;
     
    475476    if (GstWalk.Core.fBigPage)
    476477    {
    477         Assert(GstWalk.Pde.b.u1Size);
     478        Assert(GstWalk.Pde.u & X86_PDE_PS);
    478479        if (uErr & X86_TRAP_PF_RW)
    479480        {
     
    489490    else
    490491    {
    491         Assert(!GstWalk.Pde.b.u1Size);
     492        Assert(!(GstWalk.Pde.u & X86_PDE_PS));
    492493        GstWalk.Pde.u   |= X86_PDE_A;
    493494        GstWalk.pPde->u |= X86_PDE_A;
     
    629630     */
    630631#  if PGM_WITH_PAGING(PGM_GST_TYPE, PGM_SHW_TYPE)
    631     Assert(GstWalk.Pde.n.u1Present);
     632    Assert(GstWalk.Pde.u & X86_PDE_P);
    632633#  endif
    633634    if (    !(uErr & X86_TRAP_PF_P) /* not set means page not present instead of page protection violation */
     
    835836                if (   GstWalk.Core.fEffectiveUS
    836837                    && !GstWalk.Core.fEffectiveRW
    837                     && (GstWalk.Core.fBigPage || GstWalk.Pde.n.u1Write)
     838                    && (GstWalk.Core.fBigPage || (GstWalk.Pde.u & X86_PDE_RW))
    838839                    && pVM->cCpus == 1 /* Sorry, no go on SMP. Add CFGM option? */)
    839840                {
     
    918919        else if (    GstWalk.Core.fEffectiveUS
    919920                 && !GstWalk.Core.fEffectiveRW
    920                  && (GstWalk.Core.fBigPage || GstWalk.Pde.n.u1Write)
     921                 && (GstWalk.Core.fBigPage || (GstWalk.Pde.u & X86_PDE_RW))
    921922                 &&  pVCpu->pgm.s.cNetwareWp0Hacks > 0
    922923                 &&  (CPUMGetGuestCR0(pVCpu) & (X86_CR0_WP | X86_CR0_PG)) == X86_CR0_PG
     
    11171118
    11181119    const SHWPDE PdeDst = *pPdeDst;
    1119     if (!PdeDst.n.u1Present)
     1120    if (!(PdeDst.u & X86_PDE_P))
    11201121    {
    11211122        STAM_COUNTER_INC(&pVCpu->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,InvalidatePageSkipped));
     
    11491150# endif /* PGM_GST_TYPE != PGM_TYPE_32BIT */
    11501151    const bool      fWasBigPage = RT_BOOL(PdeDst.u & PGM_PDFLAGS_BIG_PAGE);
    1151     const bool      fIsBigPage  = PdeSrc.b.u1Size && GST_IS_PSE_ACTIVE(pVCpu);
     1152    const bool      fIsBigPage  = (PdeSrc.u & X86_PDE_PS) && GST_IS_PSE_ACTIVE(pVCpu);
    11521153    if (fWasBigPage != fIsBigPage)
    11531154        STAM_COUNTER_INC(&pVCpu->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,InvalidatePageSkipped));
     
    11631164        || (   VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL)
    11641165            && fIsBigPage
    1165             && PdeSrc.b.u1Global
     1166            && (PdeSrc.u & X86_PDE4M_G)
    11661167           )
    11671168       )
     
    11791180     */
    11801181    rc = VINF_SUCCESS;
    1181     if (PdeSrc.n.u1Present)
    1182     {
    1183         Assert(     PdeSrc.n.u1User == PdeDst.n.u1User
    1184                &&   (PdeSrc.n.u1Write || !PdeDst.n.u1Write || pVCpu->pgm.s.cNetwareWp0Hacks > 0));
     1182    if (PdeSrc.u & X86_PDE_P)
     1183    {
     1184        Assert(    (PdeSrc.u & X86_PDE_US) == (PdeDst.u & X86_PDE_US)
     1185               &&  ((PdeSrc.u & X86_PDE_RW) || !(PdeDst.u & X86_PDE_RW) || pVCpu->pgm.s.cNetwareWp0Hacks > 0));
    11851186# ifndef PGM_WITHOUT_MAPPINGS
    11861187        if (PdeDst.u & PGM_PDFLAGS_MAPPING)
     
    12641265                if (        (PdeSrc.u & (X86_PDE_P | X86_PDE_RW | X86_PDE_US))
    12651266                        ==  (PdeDst.u & (X86_PDE_P | X86_PDE_RW | X86_PDE_US))
    1266                     &&  (   PdeSrc.b.u1Dirty /** @todo rainy day: What about read-only 4M pages? not very common, but still... */
     1267                    &&  (   (PdeSrc.u & X86_PDE4M_D) /** @todo rainy day: What about read-only 4M pages? not very common, but still... */
    12671268                         || (PdeDst.u & PGM_PDFLAGS_TRACK_DIRTY)))
    12681269                {
     
    16151616                 * we mark the page not present.
    16161617                 */
    1617                 if (!PteSrc.n.u1Accessed || !PdeSrc.n.u1Accessed)
     1618                if (!(PteSrc.u & X86_PTE_A) || !(PdeSrc.u & X86_PDE_A))
    16181619                {
    16191620                    LogFlow(("SyncPageWorker: page and or page directory not accessed -> mark not present\n"));
     
    16251626                 * when the page is modified.
    16261627                 */
    1627                 else if (!PteSrc.n.u1Dirty && (PdeSrc.n.u1Write & PteSrc.n.u1Write))
     1628                else if (!(PteSrc.u & X86_PTE_D) && (PdeSrc.u & PteSrc.u & X86_PTE_RW))
    16281629                {
     1630                    AssertCompile(X86_PTE_RW == X86_PDE_RW);
    16291631                    STAM_COUNTER_INC(&pVCpu->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,DirtyPage));
    16301632                    SHW_PTE_SET(PteDst,
     
    17471749     * Assert preconditions.
    17481750     */
    1749     Assert(PdeSrc.n.u1Present);
     1751    Assert(PdeSrc.u & X86_PDE_P);
    17501752    Assert(cPages);
    17511753#  if 0 /* rarely useful; leave for debugging. */
     
    17981800     *   the modified entry, we may end up here with a "stale" TLB entry.
    17991801     */
    1800     if (!PdeDst.n.u1Present)
     1802    if (!(PdeDst.u & X86_PDE_P))
    18011803    {
    18021804        Log(("CPU%u: SyncPage: Pde at %RGv changed behind our back? (pPdeDst=%p/%RX64) uErr=%#x\n", pVCpu->idCpu, GCPtrPage, pPdeDst, (uint64_t)PdeDst.u, (uint32_t)uErr));
     
    18201822     * Check that the page is present and that the shadow PDE isn't out of sync.
    18211823     */
    1822     const bool      fBigPage  = PdeSrc.b.u1Size && GST_IS_PSE_ACTIVE(pVCpu);
     1824    const bool      fBigPage  = (PdeSrc.u & X86_PDE_PS) && GST_IS_PSE_ACTIVE(pVCpu);
    18231825    const bool      fPdeValid = !fBigPage ? GST_IS_PDE_VALID(pVCpu, PdeSrc) : GST_IS_BIG_PDE_VALID(pVCpu, PdeSrc);
    18241826    RTGCPHYS        GCPhys;
     
    18401842    }
    18411843    /** @todo This doesn't check the G bit of 2/4MB pages. FIXME */
    1842     if (    fPdeValid
    1843         &&  pShwPage->GCPhys == GCPhys
    1844         &&  PdeSrc.n.u1Present
    1845         &&  PdeSrc.n.u1User == PdeDst.n.u1User
    1846         &&  (PdeSrc.n.u1Write == PdeDst.n.u1Write || !PdeDst.n.u1Write)
     1844    if (   fPdeValid
     1845        && pShwPage->GCPhys == GCPhys
     1846        && (PdeSrc.u & X86_PDE_P)
     1847        && (PdeSrc.u & X86_PDE_US) == (PdeDst.u & X86_PDE_US)
     1848        && ((PdeSrc.u & X86_PDE_RW) == (PdeDst.u & X86_PDE_RW) || !(PdeDst.u & X86_PDE_RW))
    18471849#  if PGM_WITH_NX(PGM_GST_TYPE, PGM_SHW_TYPE)
    1848         &&  (PdeSrc.n.u1NoExecute == PdeDst.n.u1NoExecute || !GST_IS_NX_ACTIVE(pVCpu))
     1850        && ((PdeSrc.u & X86_PDE_PAE_NX) == (PdeDst.u & X86_PDE_PAE_NX) || !GST_IS_NX_ACTIVE(pVCpu))
    18491851#  endif
    18501852       )
     
    18551857         * check is only meant for dealing with non-#PF'ing paths.
    18561858         */
    1857         if (PdeSrc.n.u1Accessed)
     1859        if (PdeSrc.u & X86_PDE_A)
    18581860        {
    18591861            PSHWPT pPTDst = (PSHWPT)PGMPOOL_PAGE_2_PTR_V2(pVM, pVCpu, pShwPage);
     
    19541956                    if (    PGM_PAGE_GET_TYPE(pPage)  == PGMPAGETYPE_RAM
    19551957                        &&  (   PGM_PAGE_IS_ZERO(pPage)
    1956                              || (   PdeSrc.n.u1Write
     1958                             || (   (PdeSrc.u & X86_PDE_RW)
    19571959                                 && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_ALLOCATED
    19581960#   ifdef VBOX_WITH_REAL_WRITE_MONITORED_PAGES
     
    20082010                     * As for invlpg, it simply frees the whole shadow PT.
    20092011                     * ...It's possibly because the guest clears it and the guest doesn't really tell us... */
    2010                     if (    !PdeSrc.b.u1Dirty
    2011                         &&  PdeSrc.b.u1Write)
     2012                    if ((PdeSrc.u & (X86_PDE4M_D | X86_PDE_RW)) == X86_PDE_RW)
    20122013                    {
    20132014                        STAM_COUNTER_INC(&pVCpu->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,DirtyPageBig));
    20142015                        PdeDst.u |= PGM_PDFLAGS_TRACK_DIRTY;
    2015                         PdeDst.n.u1Write = 0;
     2016                        PdeDst.u &= ~(SHWUINT)X86_PDE_RW;
    20162017                    }
    20172018                    else
    20182019                    {
    2019                         PdeDst.au32[0] &= ~PGM_PDFLAGS_TRACK_DIRTY;
    2020                         PdeDst.n.u1Write = PdeSrc.n.u1Write;
     2020                        PdeDst.u &= ~(SHWUINT)(PGM_PDFLAGS_TRACK_DIRTY | X86_PDE_RW);
     2021                        PdeDst.u |= PdeSrc.u & X86_PDE_RW;
    20212022                    }
    20222023                    SHW_PDE_ATOMIC_SET2(*pPdeDst, PdeDst);
     
    22832284     * Handle big page.
    22842285     */
    2285     if (pPdeSrc->b.u1Size && GST_IS_PSE_ACTIVE(pVCpu))
    2286     {
    2287         if (    pPdeDst->n.u1Present
    2288             &&  (pPdeDst->u & PGM_PDFLAGS_TRACK_DIRTY))
    2289         {
     2286    if ((pPdeSrc->u & X86_PDE_PS) && GST_IS_PSE_ACTIVE(pVCpu))
     2287    {
     2288        if ((pPdeSrc->u & (X86_PDE_P | PGM_PDFLAGS_TRACK_DIRTY)) == (X86_PDE_P | PGM_PDFLAGS_TRACK_DIRTY))
     2289        {
     2290            STAM_COUNTER_INC(&pVCpu->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,DirtyPageTrap));
     2291            Assert(pPdeSrc->u & X86_PDE_RW);
     2292
     2293            /* Note: No need to invalidate this entry on other VCPUs as a stale TLB entry will not harm; write access will simply
     2294             *       fault again and take this path to only invalidate the entry (see below). */
    22902295            SHWPDE PdeDst = *pPdeDst;
    2291 
    2292             STAM_COUNTER_INC(&pVCpu->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,DirtyPageTrap));
    2293             Assert(pPdeSrc->b.u1Write);
    2294 
    2295             /* Note: No need to invalidate this entry on other VCPUs as a stale TLB entry will not harm; write access will simply
    2296              *       fault again and take this path to only invalidate the entry (see below).
    2297              */
    2298             PdeDst.n.u1Write      = 1;
    2299             PdeDst.n.u1Accessed   = 1;
    2300             PdeDst.au32[0]       &= ~PGM_PDFLAGS_TRACK_DIRTY;
     2296            PdeDst.u &= ~(SHWUINT)PGM_PDFLAGS_TRACK_DIRTY;
     2297            PdeDst.u |= X86_PDE_RW | X86_PDE_A;
    23012298            SHW_PDE_ATOMIC_SET2(*pPdeDst, PdeDst);
    23022299            PGM_INVL_BIG_PG(pVCpu, GCPtrPage);
     
    23062303# ifdef IN_RING0
    23072304        /* Check for stale TLB entry; only applies to the SMP guest case. */
    2308         if (    pVM->cCpus > 1
    2309             &&  pPdeDst->n.u1Write
    2310             &&  pPdeDst->n.u1Accessed)
     2305        if (   pVM->cCpus > 1
     2306            && (pPdeDst->u & (X86_PDE_P | X86_PDE_RW | X86_PDE_A)) == (X86_PDE_P | X86_PDE_RW | X86_PDE_A))
    23112307        {
    23122308            PPGMPOOLPAGE    pShwPage = pgmPoolGetPage(pPool, pPdeDst->u & SHW_PDE_PG_MASK);
     
    23332329    PGSTPT pPTSrc;
    23342330    int rc = PGM_GCPHYS_2_PTR_V2(pVM, pVCpu, GST_GET_PDE_GCPHYS(*pPdeSrc), &pPTSrc);
    2335     if (RT_FAILURE(rc))
    2336     {
    2337         AssertRC(rc);
    2338         return rc;
    2339     }
    2340 
    2341     if (pPdeDst->n.u1Present)
     2331    AssertRCReturn(rc, rc);
     2332
     2333    if (SHW_PDE_IS_P(*pPdeDst))
    23422334    {
    23432335        GSTPTE const  *pPteSrc = &pPTSrc->a[(GCPtrPage >> GST_PT_SHIFT) & GST_PT_MASK];
     
    25512543    }
    25522544# endif /* !PGM_WITHOUT_MAPPINGS */
    2553     Assert(!PdeDst.n.u1Present); /* We're only supposed to call SyncPT on PDE!P and conflicts.*/
     2545    Assert(!SHW_PDE_IS_P(PdeDst)); /* We're only supposed to call SyncPT on PDE!P and conflicts.*/
    25542546
    25552547    /*
     
    25572549     */
    25582550    GSTPDE      PdeSrc = pPDSrc->a[iPDSrc];
    2559     const bool  fPageTable = !PdeSrc.b.u1Size || !GST_IS_PSE_ACTIVE(pVCpu);
    2560     if (   PdeSrc.n.u1Present
     2551    const bool  fPageTable = !(PdeSrc.u & X86_PDE_PS) || !GST_IS_PSE_ACTIVE(pVCpu);
     2552    if (   (PdeSrc.u & X86_PDE_P)
    25612553        && (fPageTable ? GST_IS_PDE_VALID(pVCpu, PdeSrc) : GST_IS_BIG_PDE_VALID(pVCpu, PdeSrc)) )
    25622554    {
     
    25822574            PGMPOOLACCESS enmAccess;
    25832575# if PGM_WITH_NX(PGM_GST_TYPE, PGM_SHW_TYPE)
    2584             const bool  fNoExecute = PdeSrc.n.u1NoExecute && GST_IS_NX_ACTIVE(pVCpu);
     2576            const bool  fNoExecute = (PdeSrc.u & X86_PDE_PAE_NX) && GST_IS_NX_ACTIVE(pVCpu);
    25852577# else
    25862578            const bool  fNoExecute = false;
     
    25932585# endif
    25942586            /* Determine the right kind of large page to avoid incorrect cached entry reuse. */
    2595             if (PdeSrc.n.u1User)
     2587            if (PdeSrc.u & X86_PDE_US)
    25962588            {
    2597                 if (PdeSrc.n.u1Write)
     2589                if (PdeSrc.u & X86_PDE_RW)
    25982590                    enmAccess = (fNoExecute) ? PGMPOOLACCESS_USER_RW_NX : PGMPOOLACCESS_USER_RW;
    25992591                else
     
    26022594            else
    26032595            {
    2604                 if (PdeSrc.n.u1Write)
     2596                if (PdeSrc.u & X86_PDE_RW)
    26052597                    enmAccess = (fNoExecute) ? PGMPOOLACCESS_SUPERVISOR_RW_NX : PGMPOOLACCESS_SUPERVISOR_RW;
    26062598                else
     
    26242616                PdeDst.u = pShwPage->Core.Key | GST_GET_BIG_PDE_SHW_FLAGS(pVCpu, PdeSrc);
    26252617                /* (see explanation and assumptions further down.) */
    2626                 if (    !PdeSrc.b.u1Dirty
    2627                     &&  PdeSrc.b.u1Write)
     2618                if ((PdeSrc.u & (X86_PDE_RW | X86_PDE4M_D)) == X86_PDE_RW)
    26282619                {
    26292620                    STAM_COUNTER_INC(&pVCpu->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,DirtyPageBig));
    26302621                    PdeDst.u |= PGM_PDFLAGS_TRACK_DIRTY;
    2631                     PdeDst.b.u1Write = 0;
     2622                    PdeDst.u &= ~(SHWUINT)X86_PDE_RW;
    26322623                }
    26332624            }
     
    26552646         * The best idea is to leave this change to the caller and add an
    26562647         * assertion that it's set already. */
    2657         pPDSrc->a[iPDSrc].n.u1Accessed = 1;
     2648        pPDSrc->a[iPDSrc].u |= X86_PDE_A;
    26582649        if (fPageTable)
    26592650        {
     
    27632754            /** @todo move the above stuff to a section in the PGM documentation. */
    27642755            Assert(!(PdeDst.u & PGM_PDFLAGS_TRACK_DIRTY));
    2765             if (    !PdeSrc.b.u1Dirty
    2766                 &&  PdeSrc.b.u1Write)
     2756            if ((PdeSrc.u & (X86_PDE_RW | X86_PDE4M_D)) == X86_PDE_RW)
    27672757            {
    27682758                STAM_COUNTER_INC(&pVCpu->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,DirtyPageBig));
    27692759                PdeDst.u |= PGM_PDFLAGS_TRACK_DIRTY;
    2770                 PdeDst.b.u1Write = 0;
     2760                PdeDst.u &= ~(SHWUINT)X86_PDE_RW;
    27712761            }
    27722762            SHW_PDE_ATOMIC_SET2(*pPdeDst, PdeDst);
     
    28902880    }
    28912881    else
    2892         AssertRelease(!PdeDst.n.u1Present);
     2882        AssertRelease(!SHW_PDE_IS_P(PdeDst));
    28932883
    28942884    STAM_PROFILE_STOP(&pVCpu->pgm.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,SyncPT), a);
     
    30293019                         | (PdeDst.u & X86_PDE_AVL_MASK) /** @todo do we need this? */;
    30303020#  else
    3031                 PdeDst.u &= X86_PDE_AVL_MASK;
    3032                 PdeDst.n.u1Present   = 1;
    3033                 PdeDst.n.u1Write     = 1;
    3034                 PdeDst.b.u1Size      = 1;
    3035                 PdeDst.n.u1User      = 1;
    3036                 PdeDst.u |= HCPhys; /* Note! Must be done last of gcc v10.2.1 20200723 (Red Hat 10.2.1-1) may drop the top 32 bits. */
     3021                PdeDst.u = HCPhys | X86_PDE_P | X86_PDE_RW | X86_PDE_US | X86_PDE_PS
     3022                         | (PdeDst.u & X86_PDE_AVL_MASK) /** @todo PGM_PD_FLAGS? */;
    30373023#  endif
    30383024                SHW_PDE_ATOMIC_SET2(*pPdeDst, PdeDst);
     
    31013087             | (PdeDst.u & X86_PDE_AVL_MASK /** @todo do we really need this? */);
    31023088# else
    3103     PdeDst.u &= X86_PDE_AVL_MASK;
    3104     PdeDst.n.u1Present  = 1;
    3105     PdeDst.n.u1Write    = 1;
    3106     PdeDst.n.u1User     = 1;
    3107     PdeDst.n.u1Accessed = 1;
    3108     PdeDst.u |= pShwPage->Core.Key; /* Note! Must be done last of gcc v10.2.1 20200723 (Red Hat 10.2.1-1) drops the top 32 bits. */
    3109     /** @todo r=bird: Stop using bitfields.  But we need to defined/find the EPT flags then. */
     3089    PdeDst.u = pShwPage->Core.Key | X86_PDE_P | X86_PDE_RW | X86_PDE_US | X86_PDE_A
     3090             | (PdeDst.u & X86_PDE_AVL_MASK /** @todo use a PGM_PD_FLAGS define */);
    31103091# endif
    31113092    SHW_PDE_ATOMIC_SET2(*pPdeDst, PdeDst);
     
    31713152    PGSTPD          pPDSrc = NULL;
    31723153    const unsigned  iPDSrc = 0;
    3173     GSTPDE          PdeSrc;
    3174 
    3175     PdeSrc.u            = 0; /* faked so we don't have to #ifdef everything */
    3176     PdeSrc.n.u1Present  = 1;
    3177     PdeSrc.n.u1Write    = 1;
    3178     PdeSrc.n.u1Accessed = 1;
    3179     PdeSrc.n.u1User     = 1;
    3180 # endif
    3181 
    3182     if (PdeSrc.n.u1Present && PdeSrc.n.u1Accessed)
     3154    GSTPDE const    PdeSrc = { X86_PDE_P | X86_PDE_RW | X86_PDE_US | X86_PDE_A }; /* faked so we don't have to #ifdef everything */
     3155# endif
     3156
     3157    if ((PdeSrc.u & (X86_PDE_P | X86_PDE_A)) == (X86_PDE_P | X86_PDE_A))
    31833158    {
    31843159        PVMCC pVM = pVCpu->CTX_SUFF(pVM);
     
    32373212# endif
    32383213        {
    3239             if (!PdeDst.n.u1Present)
     3214            if (!(PdeDst.u & X86_PDE_P))
    32403215            {
    32413216                /** @todo r=bird: This guy will set the A bit on the PDE,
     
    33863361# endif
    33873362
    3388     if (!pPdeDst->n.u1Present)
     3363    if (!(pPdeDst->u & X86_PDE_P))
    33893364    {
    33903365        rc = PGM_BTH_NAME(SyncPT)(pVCpu, iPDSrc, pPDSrc, GCPtrPage);
     
    34093384        GSTPDE PdeSrc       = pPDSrc->a[iPDSrc];
    34103385# else
    3411         GSTPDE PdeSrc;
    3412         PdeSrc.u            = 0; /* faked so we don't have to #ifdef everything */
    3413         PdeSrc.n.u1Present  = 1;
    3414         PdeSrc.n.u1Write    = 1;
    3415         PdeSrc.n.u1Accessed = 1;
    3416         PdeSrc.n.u1User     = 1;
     3386        GSTPDE const PdeSrc = { X86_PDE_P | X86_PDE_RW | X86_PDE_US | X86_PDE_A }; /* faked so we don't have to #ifdef everything */
    34173387# endif
    34183388
     
    38093779
    38103780                    const GSTPDE PdeSrc = pPDSrc->a[(iPDDst >> (GST_PD_SHIFT - SHW_PD_SHIFT)) & GST_PD_MASK];
    3811                     if (!PdeSrc.n.u1Present)
     3781                    if (!(PdeSrc.u & X86_PDE_P))
    38123782                    {
    38133783                        AssertMsgFailed(("Guest PDE at %RGv is not present! PdeDst=%#RX64 PdeSrc=%#RX64\n",
     
    38173787                    }
    38183788
    3819                     if (    !PdeSrc.b.u1Size
    3820                         ||  !fBigPagesSupported)
     3789                    if (   !(PdeSrc.u & X86_PDE_PS)
     3790                        || !fBigPagesSupported)
    38213791                    {
    38223792                        GCPhysGst = GST_GET_PDE_GCPHYS(PdeSrc);
     
    38423812                    }
    38433813
    3844                     if (    pPoolPage->enmKind
    3845                         !=  (!PdeSrc.b.u1Size || !fBigPagesSupported ? BTH_PGMPOOLKIND_PT_FOR_PT : BTH_PGMPOOLKIND_PT_FOR_BIG))
     3814                    if (   pPoolPage->enmKind
     3815                        != (!(PdeSrc.u & X86_PDE_PS) || !fBigPagesSupported ? BTH_PGMPOOLKIND_PT_FOR_PT : BTH_PGMPOOLKIND_PT_FOR_BIG))
    38463816                    {
    38473817                        AssertMsgFailed(("Invalid shadow page table kind %d at %RGv! PdeSrc=%#RX64\n",
     
    38673837                    }
    38683838
    3869                     if (    !PdeSrc.b.u1Size
     3839                    if (    !(PdeSrc.u & X86_PDE_PS)
    38703840                        ||  !fBigPagesSupported)
    38713841                    {
     
    41004070                        */
    41014071                        uint64_t fIgnoreFlags = X86_PDE_AVL_MASK | GST_PDE_PG_MASK | X86_PDE4M_G | X86_PDE4M_D | X86_PDE4M_PS | X86_PDE4M_PWT | X86_PDE4M_PCD;
    4102                         if (!PdeSrc.b.u1Dirty && PdeSrc.b.u1Write)
     4072                        if ((PdeSrc.u & (X86_PDE_RW | X86_PDE4M_D)) == X86_PDE_RW)
    41034073                        {
    4104                             if (PdeDst.n.u1Write)
     4074                            if (PdeDst.u & X86_PDE_RW)
    41054075                            {
    41064076                                AssertMsgFailed(("!DIRTY page at %RGv is writable! PdeSrc=%#RX64 PdeDst=%#RX64\n",
     
    41314101                        {
    41324102                            /* access bit emulation (not implemented). */
    4133                             if (PdeSrc.b.u1Accessed || PdeDst.n.u1Present)
     4103                            if ((PdeSrc.u & X86_PDE_A) || SHW_PDE_IS_P(PdeDst))
    41344104                            {
    41354105                                AssertMsgFailed(("PGM_PDFLAGS_TRACK_DIRTY set at %RGv but no accessed bit emulation! PdeSrc=%#RX64 PdeDst=%#RX64\n",
     
    41384108                                continue;
    41394109                            }
    4140                             if (!PdeDst.n.u1Accessed)
     4110                            if (!SHW_PDE_IS_A(PdeDst))
    41414111                            {
    41424112                                AssertMsgFailed(("!ACCESSED page at %RGv is has the accessed bit set! PdeSrc=%#RX64 PdeDst=%#RX64\n",
  • trunk/src/VBox/VMM/VMMAll/PGMAllGst.h

    r86466 r86476  
    208208        GSTPDE  Pde;
    209209        pWalk->Pde.u = Pde.u = pPde->u;
    210         if (Pde.n.u1Present) { /* probable */ }
     210        if (Pde.u & X86_PDE_P) { /* probable */ }
    211211        else return PGM_GST_NAME(WalkReturnNotPresent)(pVCpu, pWalk, 2);
    212         if (Pde.n.u1Size && GST_IS_PSE_ACTIVE(pVCpu))
     212        if ((Pde.u & X86_PDE_PS) && GST_IS_PSE_ACTIVE(pVCpu))
    213213        {
    214214            if (RT_LIKELY(GST_IS_BIG_PDE_VALID(pVCpu, Pde))) { /* likely */ }
  • trunk/src/VBox/VMM/VMMAll/PGMAllShw.h

    r86466 r86476  
    2020*   Defined Constants And Macros                                                                                                 *
    2121*********************************************************************************************************************************/
     22#undef SHWUINT
    2223#undef SHWPT
    2324#undef PSHWPT
     
    3435#undef SHW_PDE_ATOMIC_SET2
    3536#undef SHW_PDE_IS_P
     37#undef SHW_PDE_IS_A
    3638#undef SHW_PDE_IS_BIG
    3739#undef SHW_PTE_PG_MASK
     
    5961
    6062#if PGM_SHW_TYPE == PGM_TYPE_32BIT || PGM_SHW_TYPE == PGM_TYPE_NESTED_32BIT
     63# define SHWUINT                        uint32_t
    6164# define SHWPT                          X86PT
    6265# define PSHWPT                         PX86PT
     
    7275# define SHW_TOTAL_PD_ENTRIES           X86_PG_ENTRIES
    7376# define SHW_PDE_IS_P(Pde)              ( (Pde).n.u1Present )
     77# define SHW_PDE_IS_A(Pde)              ( (Pde).n.u1Accessed )
    7478# define SHW_PDE_IS_BIG(Pde)            ( (Pde).b.u1Size )
    7579# define SHW_PDE_ATOMIC_SET(Pde, uNew)  do { ASMAtomicWriteU32(&(Pde).u, (uNew)); } while (0)
     
    9599
    96100#elif PGM_SHW_TYPE == PGM_TYPE_EPT
     101# define SHWUINT                        uint64_t
    97102# define SHWPT                          EPTPT
    98103# define PSHWPT                         PEPTPT
     
    107112# define SHW_PD_MASK                    EPT_PD_MASK
    108113# define SHW_PDE_IS_P(Pde)              ( (Pde).u & EPT_E_READ /* always set*/ )
     114# define SHW_PDE_IS_A(Pde)              ( 1 ) /* We don't use EPT_E_ACCESSED, use with care! */
    109115# define SHW_PDE_IS_BIG(Pde)            ( (Pde).u & EPT_E_LEAF )
    110116# define SHW_PDE_ATOMIC_SET(Pde, uNew)  do { ASMAtomicWriteU64(&(Pde).u, (uNew)); } while (0)
     
    134140
    135141#else
     142# define SHWUINT                        uint64_t
    136143# define SHWPT                          PGMSHWPTPAE
    137144# define PSHWPT                         PPGMSHWPTPAE
     
    146153# define SHW_PD_MASK                    X86_PD_PAE_MASK
    147154# define SHW_PDE_IS_P(Pde)              ( (Pde).u & X86_PDE_P )
     155# define SHW_PDE_IS_A(Pde)              ( (Pde).u & X86_PDE_A )
    148156# define SHW_PDE_IS_BIG(Pde)            ( (Pde).u & X86_PDE_PS )
    149157# define SHW_PDE_ATOMIC_SET(Pde, uNew)  do { ASMAtomicWriteU64(&(Pde).u, (uNew)); } while (0)
Note: See TracChangeset for help on using the changeset viewer.

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