VirtualBox

Changeset 31775 in vbox for trunk/src/VBox/VMM/PGMInternal.h


Ignore:
Timestamp:
Aug 19, 2010 9:48:24 AM (14 years ago)
Author:
vboxsync
Message:

PGM: Wrap up all access to PAE/LM PTEs so that we can treat the invalid entries used by PGM_WITH_MMIO_OPTIMIZATIONS as not-present.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PGMInternal.h

    r31657 r31775  
    413413# define PGM_INVL_ALL_VCPU_TLBS(pVM)            HWACCMFlushTLBOnAllVCpus(pVM)
    414414#endif
     415
     416
     417/** @name Safer Shadow PAE PT/PTE
     418 * For helping avoid misinterpreting invalid PAE/AMD64 page table entries as
     419 * present.
     420 *
     421 * @{
     422 */
     423#if 1
     424/**
     425 * For making sure that u1Present and X86_PTE_P checks doesn't mistake
     426 * invalid entries for present.
     427 * @sa X86PTEPAE.
     428 */
     429typedef union PGMSHWPTEPAE
     430{
     431    /** Unsigned integer view */
     432    X86PGPAEUINT    uCareful;
     433#if 0
     434    /* Not bit field view. */
     435    /** 32-bit view. */
     436    uint32_t        au32[2];
     437    /** 16-bit view. */
     438    uint16_t        au16[4];
     439    /** 8-bit view. */
     440    uint8_t         au8[8];
     441#endif
     442} PGMSHWPTEPAE;
     443
     444# define PGMSHWPTEPAE_IS_P(Pte)                 ( ((Pte).uCareful & (X86_PTE_P | X86_PTE_PAE_MBZ_MASK_NX)) == X86_PTE_P )
     445# define PGMSHWPTEPAE_IS_RW(Pte)                ( !!((Pte).uCareful & X86_PTE_RW))
     446# define PGMSHWPTEPAE_IS_US(Pte)                ( !!((Pte).uCareful & X86_PTE_US))
     447# define PGMSHWPTEPAE_IS_A(Pte)                 ( !!((Pte).uCareful & X86_PTE_A))
     448# define PGMSHWPTEPAE_IS_D(Pte)                 ( !!((Pte).uCareful & X86_PTE_D))
     449# define PGMSHWPTEPAE_IS_TRACK_DIRTY(Pte)       ( !!((Pte).uCareful & PGM_PTFLAGS_TRACK_DIRTY) )
     450# define PGMSHWPTEPAE_IS_P_RW(Pte)              ( ((Pte).uCareful & (X86_PTE_P | X86_PTE_RW | X86_PTE_PAE_MBZ_MASK_NX)) == (X86_PTE_P | X86_PTE_RW) )
     451# define PGMSHWPTEPAE_GET_LOG(Pte)              ( (Pte).uCareful )
     452# define PGMSHWPTEPAE_GET_HCPHYS(Pte)           ( (Pte).uCareful & X86_PTE_PAE_PG_MASK )
     453# define PGMSHWPTEPAE_GET_U(Pte)                ( (Pte).uCareful ) /**< Use with care. */
     454# define PGMSHWPTEPAE_SET(Pte, uVal)            do { (Pte).uCareful = (uVal); } while (0)
     455# define PGMSHWPTEPAE_SET2(Pte, Pte2)           do { (Pte).uCareful = (Pte2).uCareful; } while (0)
     456# define PGMSHWPTEPAE_ATOMIC_SET(Pte, uVal)     do { ASMAtomicWriteU64(&(Pte).uCareful, (uVal)); } while (0)
     457# define PGMSHWPTEPAE_ATOMIC_SET2(Pte, Pte2)    do { ASMAtomicWriteU64(&(Pte).uCareful, (Pte2).uCareful); } while (0)
     458# define PGMSHWPTEPAE_SET_RO(Pte)               do { (Pte).uCareful &= ~(X86PGPAEUINT)X86_PTE_RW; } while (0)
     459# define PGMSHWPTEPAE_SET_RW(Pte)               do { (Pte).uCareful |= X86_PTE_RW; } while (0)
     460
     461/**
     462 * For making sure that u1Present and X86_PTE_P checks doesn't mistake
     463 * invalid entries for present.
     464 * @sa X86PTPAE.
     465 */
     466typedef struct PGMSHWPTPAE
     467{
     468    PGMSHWPTEPAE  a[X86_PG_PAE_ENTRIES];
     469} PGMSHWPTPAE;
     470
     471#else
     472typedef X86PTEPAE           PGMSHWPTEPAE;
     473typedef X86PTPAE            PGMSHWPTPAE;
     474# define PGMSHWPTEPAE_IS_P(Pte)                 ( (Pte).n.u1Present )
     475# define PGMSHWPTEPAE_IS_RW(Pte)                ( (Pte).n.u1Write )
     476# define PGMSHWPTEPAE_IS_US(Pte)                ( (Pte).n.u1User )
     477# define PGMSHWPTEPAE_IS_A(Pte)                 ( (Pte).n.u1Accessed )
     478# define PGMSHWPTEPAE_IS_D(Pte)                 ( (Pte).n.u1Dirty )
     479# define PGMSHWPTEPAE_IS_TRACK_DIRTY(Pte)       ( !!((Pte).u & PGM_PTFLAGS_TRACK_DIRTY) )
     480# define PGMSHWPTEPAE_IS_P_RW(Pte)              ( ((Pte).u & (X86_PTE_P | X86_PTE_RW)) == (X86_PTE_P | X86_PTE_RW) )
     481# define PGMSHWPTEPAE_GET_LOG(Pte)              ( (Pte).u )
     482# define PGMSHWPTEPAE_GET_HCPHYS(Pte)           ( (Pte).u & X86_PTE_PAE_PG_MASK )
     483# define PGMSHWPTEPAE_GET_U(Pte)                ( (Pte).u ) /**< Use with care. */
     484# define PGMSHWPTEPAE_SET(Pte, uVal)            do { (Pte).u = (uVal); } while (0)
     485# define PGMSHWPTEPAE_SET2(Pte, Pte2)           do { (Pte).u = (Pte2).u; } while (0)
     486# define PGMSHWPTEPAE_ATOMIC_SET(Pte, uVal)     do { ASMAtomicWriteU64(&(Pte).u, (uVal)); } while (0)
     487# define PGMSHWPTEPAE_ATOMIC_SET2(Pte, Pte2)    do { ASMAtomicWriteU64(&(Pte).u, (Pte2).u); } while (0)
     488# define PGMSHWPTEPAE_SET_RO(Pte)               do { (Pte).u &= ~(X86PGPAEUINT)X86_PTE_RW; } while (0)
     489# define PGMSHWPTEPAE_SET_RW(Pte)               do { (Pte).u |= X86_PTE_RW; } while (0)
     490
     491#endif
     492
     493/** Pointer to a shadow PAE PTE.  */
     494typedef PGMSHWPTEPAE       *PPGMSHWPTEPAE;
     495/** Pointer to a const shadow PAE PTE.  */
     496typedef PGMSHWPTEPAE const *PCPGMSHWPTEPAE;
     497
     498/** Pointer to a shadow PAE page table.  */
     499typedef PGMSHWPTPAE        *PPGMSHWPTPAE;
     500/** Pointer to a const shadow PAE page table.  */
     501typedef PGMSHWPTPAE const  *PCPGMSHWPTPAE;
     502/** @}  */
     503
    415504
    416505/** Size of the GCPtrConflict array in PGMMAPPING.
     
    467556        R3PTRTYPE(PX86PT)               pPTR3;
    468557        /** The HC virtual address of the two PAE page table. (i.e 1024 entries instead of 512) */
    469         R3PTRTYPE(PX86PTPAE)            paPaePTsR3;
     558        R3PTRTYPE(PPGMSHWPTPAE)         paPaePTsR3;
    470559        /** The RC virtual address of the 32-bit page table. */
    471560        RCPTRTYPE(PX86PT)               pPTRC;
    472561        /** The RC virtual address of the two PAE page table. */
    473         RCPTRTYPE(PX86PTPAE)            paPaePTsRC;
     562        RCPTRTYPE(PPGMSHWPTPAE)         paPaePTsRC;
    474563        /** The R0 virtual address of the 32-bit page table. */
    475564        R0PTRTYPE(PX86PT)               pPTR0;
    476565        /** The R0 virtual address of the two PAE page table. */
    477         R0PTRTYPE(PX86PTPAE)            paPaePTsR0;
     566        R0PTRTYPE(PPGMSHWPTPAE)         paPaePTsR0;
    478567    } aPTs[1];
    479568} PGMMAPPING;
     
    23182407 * PGMPOOL_TD_CREFS_SHIFT. */
    23192408#define PGMPOOL_TD_CREFS_MASK           0x3
    2320 /** The cRef value used to indiciate that the idx is the head of a
     2409/** The cRefs value used to indiciate that the idx is the head of a
    23212410 * physical cross reference list. */
    23222411#define PGMPOOL_TD_CREFS_PHYSEXT        PGMPOOL_TD_CREFS_MASK
     
    29173006    RCPTRTYPE(PX86PTE)              paDynPageMap32BitPTEsGC;
    29183007    /** Pointer to the page table entries for the dynamic page mapping area - GCPtr. */
    2919     RCPTRTYPE(PX86PTEPAE)           paDynPageMapPaePTEsGC;
     3008    RCPTRTYPE(PPGMSHWPTEPAE)        paDynPageMapPaePTEsGC;
    29203009
    29213010
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