Index: /trunk/include/VBox/pgm.h
===================================================================
--- /trunk/include/VBox/pgm.h	(revision 7628)
+++ /trunk/include/VBox/pgm.h	(revision 7629)
@@ -434,5 +434,4 @@
 PGMGCDECL(int)  PGMGCDynMapGCPageEx(PVM pVM, RTGCPHYS GCPhys, void **ppv);
 PGMGCDECL(int)  PGMGCDynMapHCPage(PVM pVM, RTHCPHYS HCPhys, void **ppv);
-PGMGCDECL(int)  PGMGCSyncPT(PVM pVM, unsigned iPD, PVBOXPD pPDSrc);
 PGMGCDECL(int)  PGMGCInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
 /** @} */
@@ -515,5 +514,4 @@
 #endif
 PGMR3DECL(int)  PGMR3DumpHierarchyGC(PVM pVM, uint32_t cr3, uint32_t cr4, RTGCPHYS PhysSearch);
-PGMR3DECL(void) PGMR3DumpPD(PVM pVM, PVBOXPD pPD);
 
 /** @todo r=bird: s/Byte/U8/ s/Word/U16/ s/Dword/U32/ to match other functions names and returned types. */
Index: /trunk/include/VBox/types.h
===================================================================
--- /trunk/include/VBox/types.h	(revision 7628)
+++ /trunk/include/VBox/types.h	(revision 7629)
@@ -466,23 +466,4 @@
 
 /** @} */
-
-
-/** @defgroup grp_types_pg  Page Structures
- * @ingroup grp_types
- * @{
- */
-
-/** These absolete / belong to PGM. Use VBox/x86.h structs everywhere else. */
-#define VBOXPTE     X86PTE
-#define PVBOXPTE    PX86PTE
-#define VBOXPT      X86PT
-#define PVBOXPT     PX86PT
-#define VBOXPDE     X86PDE
-#define PVBOXPDE    PX86PDE
-#define VBOXPD      X86PD
-#define PVBOXPD     PX86PD
-
-/** @} */
-
 
 
Index: /trunk/src/VBox/VMM/PGM.cpp
===================================================================
--- /trunk/src/VBox/VMM/PGM.cpp	(revision 7628)
+++ /trunk/src/VBox/VMM/PGM.cpp	(revision 7629)
@@ -1348,4 +1348,5 @@
     STAM_REG(pVM, &pPGM->StatGCTrap0eUSWrite,               STAMTYPE_COUNTER, "/PGM/GC/Trap0e/User/Write",          STAMUNIT_OCCURENCES,     "Number of user mode write page faults.");
     STAM_REG(pVM, &pPGM->StatGCTrap0eUSReserved,            STAMTYPE_COUNTER, "/PGM/GC/Trap0e/User/Reserved",       STAMUNIT_OCCURENCES,     "Number of user mode reserved bit page faults.");
+    STAM_REG(pVM, &pPGM->StatGCTrap0eUSNXE,                 STAMTYPE_COUNTER, "/PGM/GC/Trap0e/User/NXE",            STAMUNIT_OCCURENCES,     "Number of user mode NXE page faults.");
     STAM_REG(pVM, &pPGM->StatGCTrap0eUSRead,                STAMTYPE_COUNTER, "/PGM/GC/Trap0e/User/Read",           STAMUNIT_OCCURENCES,     "Number of user mode read page faults.");
 
@@ -1354,4 +1355,5 @@
     STAM_REG(pVM, &pPGM->StatGCTrap0eSVWrite,               STAMTYPE_COUNTER, "/PGM/GC/Trap0e/Supervisor/Write",    STAMUNIT_OCCURENCES,     "Number of supervisor mode write page faults.");
     STAM_REG(pVM, &pPGM->StatGCTrap0eSVReserved,            STAMTYPE_COUNTER, "/PGM/GC/Trap0e/Supervisor/Reserved", STAMUNIT_OCCURENCES,     "Number of supervisor mode reserved bit page faults.");
+    STAM_REG(pVM, &pPGM->StatGCTrap0eSNXE,                  STAMTYPE_COUNTER, "/PGM/GC/Trap0e/Supervisor/NXE",      STAMUNIT_OCCURENCES,     "Number of supervisor mode NXE page faults.");
     STAM_REG(pVM, &pPGM->StatGCTrap0eUnhandled,             STAMTYPE_COUNTER, "/PGM/GC/Trap0e/GuestPF/Unhandled",   STAMUNIT_OCCURENCES,     "Number of guest real page faults.");
     STAM_REG(pVM, &pPGM->StatGCTrap0eMap,                   STAMTYPE_COUNTER, "/PGM/GC/Trap0e/GuestPF/Map",         STAMUNIT_OCCURENCES,     "Number of guest page faults due to map accesses.");
@@ -2313,5 +2315,5 @@
      * Get page directory addresses.
      */
-    PVBOXPD     pPDSrc = pVM->pgm.s.pGuestPDHC;
+    PX86PD     pPDSrc = pVM->pgm.s.pGuestPDHC;
     Assert(pPDSrc);
     Assert(MMPhysGCPhys2HCVirt(pVM, (RTGCPHYS)(CPUMGetGuestCR3(pVM) & X86_CR3_PAGE_MASK), sizeof(*pPDSrc)) == pPDSrc);
@@ -2322,5 +2324,5 @@
     for (unsigned iPD = 0; iPD < ELEMENTS(pPDSrc->a); iPD++)
     {
-        VBOXPDE PdeSrc = pPDSrc->a[iPD];
+        X86PDE PdeSrc = pPDSrc->a[iPD];
         if (PdeSrc.n.u1Present)
         {
Index: /trunk/src/VBox/VMM/PGMBth.h
===================================================================
--- /trunk/src/VBox/VMM/PGMBth.h	(revision 7628)
+++ /trunk/src/VBox/VMM/PGMBth.h	(revision 7629)
@@ -27,5 +27,5 @@
 PGM_BTH_DECL(int, Trap0eHandler)(PVM pVM, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
 PGM_BTH_DECL(int, SyncCR3)(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal);
-PGM_BTH_DECL(int, SyncPage)(PVM pVM, VBOXPDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError);
+PGM_BTH_DECL(int, SyncPage)(PVM pVM, X86PDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError);
 PGM_BTH_DECL(int, VerifyAccessSyncPage)(PVM pVM, RTGCUINTPTR Addr, unsigned fPage, unsigned uError);
 PGM_BTH_DECL(int, InvalidatePage)(PVM pVM, RTGCPTR GCPtrPage);
Index: /trunk/src/VBox/VMM/PGMInternal.h
===================================================================
--- /trunk/src/VBox/VMM/PGMInternal.h	(revision 7628)
+++ /trunk/src/VBox/VMM/PGMInternal.h	(revision 7629)
@@ -211,4 +211,10 @@
  */
 #define PGM_WITH_PAGING(uType)  ((uType) >= PGM_TYPE_32BIT)
+
+/** Macro for checking if the guest supports the NX bit.
+ * @param uType     PGM_TYPE_*
+ * @remark  ASSUMES certain order of the PGM_TYPE_* values.
+ */
+#define PGM_WITH_NX(uType)  ((uType) >= PGM_TYPE_PAE)
 
 
@@ -342,13 +348,13 @@
         RTHCPHYS                HCPhysPaePT1;
         /** The HC virtual address of the 32-bit page table. */
-        R3PTRTYPE(PVBOXPT)      pPTR3;
+        R3PTRTYPE(PX86PT)       pPTR3;
         /** The HC virtual address of the two PAE page table. (i.e 1024 entries instead of 512) */
         R3PTRTYPE(PX86PTPAE)    paPaePTsR3;
         /** The GC virtual address of the 32-bit page table. */
-        GCPTRTYPE(PVBOXPT)      pPTGC;
+        GCPTRTYPE(PX86PT)       pPTGC;
         /** The GC virtual address of the two PAE page table. */
         GCPTRTYPE(PX86PTPAE)    paPaePTsGC;
         /** The GC virtual address of the 32-bit page table. */
-        R0PTRTYPE(PVBOXPT)      pPTR0;
+        R0PTRTYPE(PX86PT)       pPTR0;
         /** The GC virtual address of the two PAE page table. */
         R0PTRTYPE(PX86PTPAE)    paPaePTsR0;
@@ -1764,5 +1770,5 @@
     DECLR3CALLBACKMEMBER(int,       pfnR3BthInvalidatePage,(PVM pVM, RTGCPTR GCPtrPage));
     DECLR3CALLBACKMEMBER(int,       pfnR3BthSyncCR3,(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal));
-    DECLR3CALLBACKMEMBER(int,       pfnR3BthSyncPage,(PVM pVM, VBOXPDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
+    DECLR3CALLBACKMEMBER(int,       pfnR3BthSyncPage,(PVM pVM, X86PDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
     DECLR3CALLBACKMEMBER(int,       pfnR3BthPrefetchPage,(PVM pVM, RTGCUINTPTR GCPtrPage));
     DECLR3CALLBACKMEMBER(int,       pfnR3BthVerifyAccessSyncPage,(PVM pVM, RTGCUINTPTR GCPtrPage, unsigned fFlags, unsigned uError));
@@ -1774,5 +1780,5 @@
     DECLGCCALLBACKMEMBER(int,       pfnGCBthInvalidatePage,(PVM pVM, RTGCPTR GCPtrPage));
     DECLGCCALLBACKMEMBER(int,       pfnGCBthSyncCR3,(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal));
-    DECLGCCALLBACKMEMBER(int,       pfnGCBthSyncPage,(PVM pVM, VBOXPDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
+    DECLGCCALLBACKMEMBER(int,       pfnGCBthSyncPage,(PVM pVM, X86PDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
     DECLGCCALLBACKMEMBER(int,       pfnGCBthPrefetchPage,(PVM pVM, RTGCUINTPTR GCPtrPage));
     DECLGCCALLBACKMEMBER(int,       pfnGCBthVerifyAccessSyncPage,(PVM pVM, RTGCUINTPTR GCPtrPage, unsigned fFlags, unsigned uError));
@@ -1784,5 +1790,5 @@
     DECLR0CALLBACKMEMBER(int,       pfnR0BthInvalidatePage,(PVM pVM, RTGCPTR GCPtrPage));
     DECLR0CALLBACKMEMBER(int,       pfnR0BthSyncCR3,(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal));
-    DECLR0CALLBACKMEMBER(int,       pfnR0BthSyncPage,(PVM pVM, VBOXPDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
+    DECLR0CALLBACKMEMBER(int,       pfnR0BthSyncPage,(PVM pVM, X86PDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
     DECLR0CALLBACKMEMBER(int,       pfnR0BthPrefetchPage,(PVM pVM, RTGCUINTPTR GCPtrPage));
     DECLR0CALLBACKMEMBER(int,       pfnR0BthVerifyAccessSyncPage,(PVM pVM, RTGCUINTPTR GCPtrPage, unsigned fFlags, unsigned uError));
@@ -1847,7 +1853,7 @@
      * @{ */
     /** The guest's page directory, HC pointer. */
-    R3R0PTRTYPE(PVBOXPD)        pGuestPDHC;
+    R3R0PTRTYPE(PX86PD)         pGuestPDHC;
     /** The guest's page directory, static GC mapping. */
-    GCPTRTYPE(PVBOXPD)          pGuestPDGC;
+    GCPTRTYPE(PX86PD)           pGuestPDGC;
     /** @} */
 
@@ -1993,5 +1999,5 @@
     DECLR3CALLBACKMEMBER(int,       pfnR3BthInvalidatePage,(PVM pVM, RTGCPTR GCPtrPage));
     DECLR3CALLBACKMEMBER(int,       pfnR3BthSyncCR3,(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal));
-    DECLR3CALLBACKMEMBER(int,       pfnR3BthSyncPage,(PVM pVM, VBOXPDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
+    DECLR3CALLBACKMEMBER(int,       pfnR3BthSyncPage,(PVM pVM, X86PDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
     DECLR3CALLBACKMEMBER(int,       pfnR3BthPrefetchPage,(PVM pVM, RTGCUINTPTR GCPtrPage));
     DECLR3CALLBACKMEMBER(int,       pfnR3BthVerifyAccessSyncPage,(PVM pVM, RTGCUINTPTR GCPtrPage, unsigned fFlags, unsigned uError));
@@ -2001,5 +2007,5 @@
     DECLR0CALLBACKMEMBER(int,       pfnR0BthInvalidatePage,(PVM pVM, RTGCPTR GCPtrPage));
     DECLR0CALLBACKMEMBER(int,       pfnR0BthSyncCR3,(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal));
-    DECLR0CALLBACKMEMBER(int,       pfnR0BthSyncPage,(PVM pVM, VBOXPDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
+    DECLR0CALLBACKMEMBER(int,       pfnR0BthSyncPage,(PVM pVM, X86PDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
     DECLR0CALLBACKMEMBER(int,       pfnR0BthPrefetchPage,(PVM pVM, RTGCUINTPTR GCPtrPage));
     DECLR0CALLBACKMEMBER(int,       pfnR0BthVerifyAccessSyncPage,(PVM pVM, RTGCUINTPTR GCPtrPage, unsigned fFlags, unsigned uError));
@@ -2009,5 +2015,5 @@
     DECLGCCALLBACKMEMBER(int,       pfnGCBthInvalidatePage,(PVM pVM, RTGCPTR GCPtrPage));
     DECLGCCALLBACKMEMBER(int,       pfnGCBthSyncCR3,(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal));
-    DECLGCCALLBACKMEMBER(int,       pfnGCBthSyncPage,(PVM pVM, VBOXPDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
+    DECLGCCALLBACKMEMBER(int,       pfnGCBthSyncPage,(PVM pVM, X86PDE PdeSrc, RTGCUINTPTR GCPtrPage, unsigned cPages, unsigned uError));
     DECLGCCALLBACKMEMBER(int,       pfnGCBthPrefetchPage,(PVM pVM, RTGCUINTPTR GCPtrPage));
     DECLGCCALLBACKMEMBER(int,       pfnGCBthVerifyAccessSyncPage,(PVM pVM, RTGCUINTPTR GCPtrPage, unsigned fFlags, unsigned uError));
@@ -2239,4 +2245,5 @@
     STAMCOUNTER     StatGCTrap0eUSWrite;
     STAMCOUNTER     StatGCTrap0eUSReserved;
+    STAMCOUNTER     StatGCTrap0eUSNXE;
     STAMCOUNTER     StatGCTrap0eUSRead;
 
@@ -2245,4 +2252,5 @@
     STAMCOUNTER     StatGCTrap0eSVWrite;
     STAMCOUNTER     StatGCTrap0eSVReserved;
+    STAMCOUNTER     StatGCTrap0eSNXE;
 
     STAMCOUNTER     StatGCTrap0eUnhandled;
@@ -2505,5 +2513,5 @@
 int             pgmR3ChangeMode(PVM pVM, PGMMODE enmGuestMode);
 
-int             pgmR3SyncPTResolveConflict(PVM pVM, PPGMMAPPING pMapping, PVBOXPD pPDSrc, int iPDOld);
+int             pgmR3SyncPTResolveConflict(PVM pVM, PPGMMAPPING pMapping, PX86PD pPDSrc, int iPDOld);
 PPGMMAPPING     pgmGetMapping(PVM pVM, RTGCPTR GCPtr);
 void            pgmR3MapRelocate(PVM pVM, PPGMMAPPING pMapping, int iPDOld, int iPDNew);
@@ -3199,5 +3207,5 @@
         AssertMsgFailed(("Impossible! rc=%d PDPE=%#llx\n", rc, CTXSUFF(pPGM->pGstPaePDPTR)->a[iPdPtr].u));
     }
-    return 0;
+    return 0ULL;
 }
 
Index: /trunk/src/VBox/VMM/PGMMap.cpp
===================================================================
--- /trunk/src/VBox/VMM/PGMMap.cpp	(revision 7628)
+++ /trunk/src/VBox/VMM/PGMMap.cpp	(revision 7629)
@@ -159,5 +159,5 @@
          * 32-bit.
          */
-        pNew->aPTs[i].pPTR3    = (PVBOXPT)pbPTs;
+        pNew->aPTs[i].pPTR3    = (PX86PT)pbPTs;
         pNew->aPTs[i].pPTGC    = MMHyperR3ToGC(pVM, pNew->aPTs[i].pPTR3);
         pNew->aPTs[i].pPTR0    = MMHyperR3ToR0(pVM, pNew->aPTs[i].pPTR3);
@@ -876,5 +876,5 @@
 /**
  * Resolves a conflict between a page table based GC mapping and
- * the Guest OS page tables.
+ * the Guest OS page tables. (32 bits version)
  *
  * @returns VBox status code.
@@ -884,5 +884,5 @@
  * @param   iPDOld      The index to the start of the current mapping.
  */
-int pgmR3SyncPTResolveConflict(PVM pVM, PPGMMAPPING pMapping, PVBOXPD pPDSrc, int iPDOld)
+int pgmR3SyncPTResolveConflict(PVM pVM, PPGMMAPPING pMapping, PX86PD pPDSrc, int iPDOld)
 {
     STAM_PROFILE_START(&pVM->pgm.s.StatHCResolveConflict, a);
@@ -938,5 +938,4 @@
 
 
-
 /**
  * Checks guest PD for conflicts with VMM GC mappings.
@@ -959,7 +958,7 @@
      * Resolve the page directory.
      */
-    PVBOXPD pPD = pVM->pgm.s.pGuestPDHC; /** @todo Fix PAE! */
+    PX86PD pPD = pVM->pgm.s.pGuestPDHC; /** @todo Fix PAE! */
     Assert(pPD);
-    Assert(pPD == (PVBOXPD)MMPhysGCPhys2HCVirt(pVM, cr3 & X86_CR3_PAGE_MASK, sizeof(*pPD)));
+    Assert(pPD == (PX86PD)MMPhysGCPhys2HCVirt(pVM, cr3 & X86_CR3_PAGE_MASK, sizeof(*pPD)));
 
     /*
Index: /trunk/src/VBox/VMM/VMMAll/PGMAll.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/PGMAll.cpp	(revision 7628)
+++ /trunk/src/VBox/VMM/VMMAll/PGMAll.cpp	(revision 7629)
@@ -63,20 +63,4 @@
 *   Internal Functions                                                         *
 *******************************************************************************/
-/** @def DUMP_PDE_BIG
- * Debug routine for dumping a big PDE.
- */
-#ifdef DEBUG_Sander
-/** Debug routine for dumping a big PDE. */
-static void pgmDumpPDEBig(const char *pszPrefix, int iPD, VBOXPDE Pde)
-{
-    Log(("%s: BIG %d u10PageNo=%08X P=%d W=%d U=%d CACHE=%d ACC=%d DIR=%d GBL=%d\n", pszPrefix, iPD, Pde.b.u10PageNo, Pde.b.u1Present, Pde.b.u1Write, Pde.b.u1User, Pde.b.u1CacheDisable, Pde.b.u1Accessed, Pde.b.u1Dirty, Pde.b.u1Global));
-    Log(("%s: BIG %d WRT=%d AVAIL=%X RSV=%X PAT=%d\n", pszPrefix, iPD, Pde.b.u1WriteThru, Pde.b.u3Available, Pde.b.u8PageNoHigh, Pde.b.u1PAT));
-}
-#define DUMP_PDE_BIG(a, b, c) pgmDumpPDEBig(a, b, c)
-#else
-#define DUMP_PDE_BIG(a, b, c) do { } while (0)
-#endif
-
-
 
 #if 1///@todo ndef RT_ARCH_AMD64
@@ -274,9 +258,11 @@
         else if (uErr & X86_TRAP_PF_RSVD)
             STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSReserved);
+        else if (uErr & X86_TRAP_PF_ID)
+            STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSNXE);
         else
             STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSRead);
     }
     else
-    {   //supervisor
+    {   /* Supervisor */
         if (!(uErr & X86_TRAP_PF_P))
         {
@@ -288,4 +274,6 @@
         else if (uErr & X86_TRAP_PF_RW)
             STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eSVWrite);
+        else if (uErr & X86_TRAP_PF_ID)
+            STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eSNXE);
         else if (uErr & X86_TRAP_PF_RSVD)
             STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eSVReserved);
@@ -582,8 +570,4 @@
 PGMDECL(int) PGMInterpretInstruction(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault)
 {
-#ifdef IN_RING0
-    /** @todo */
-    int rc = VINF_EM_RAW_EMULATE_INSTR;
-#else
     uint32_t cb;
     int rc = EMInterpretInstruction(pVM, pRegFrame, pvFault, &cb);
@@ -592,5 +576,4 @@
     if (rc != VINF_SUCCESS)
         Log(("PGMInterpretInstruction: returns %Rrc (pvFault=%VGv)\n", rc, pvFault));
-#endif
     return rc;
 }
Index: /trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/PGMAllBth.h	(revision 7628)
+++ /trunk/src/VBox/VMM/VMMAll/PGMAllBth.h	(revision 7629)
@@ -246,9 +246,9 @@
         else
         {
-            PVBOXPT pPTSrc;
+            PX86PT pPTSrc;
 #  ifdef IN_GC
             rc = PGMGCDynMapGCPage(pVM, PdeSrc.u & GST_PDE_PG_MASK, (void **)&pPTSrc);
 #  else
-            pPTSrc = (PVBOXPT)MMPhysGCPhys2HCVirt(pVM, PdeSrc.u & GST_PDE_PG_MASK, sizeof(*pPTSrc));
+            pPTSrc = (PX86PT)MMPhysGCPhys2HCVirt(pVM, PdeSrc.u & GST_PDE_PG_MASK, sizeof(*pPTSrc));
             if (pPTSrc == 0)
                 rc = VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS;
@@ -611,5 +611,5 @@
                     }
                 }
-#  endif /* PGM_WITH_PAGING(PGM_GST_TYPE) */
+#  endif /* PGM_WITH_PAGING(PGM_GST_TYPE) && !defined(IN_RING0) */
                 rc = PGM_BTH_NAME(SyncPage)(pVM, PdeSrc, (RTGCUINTPTR)pvFault, PGM_SYNC_NR_PAGES, uErr);
                 if (VBOX_SUCCESS(rc))
@@ -755,5 +755,6 @@
 PGM_BTH_DECL(int, InvalidatePage)(PVM pVM, RTGCUINTPTR GCPtrPage)
 {
-#if PGM_GST_TYPE == PGM_TYPE_32BIT
+#if    PGM_GST_TYPE == PGM_TYPE_32BIT \
+    || PGM_GST_TYPE == PGM_TYPE_PAE
 
     LogFlow(("InvalidatePage %x\n", GCPtrPage));
@@ -785,5 +786,5 @@
 #  else /* PAE */
     unsigned        iPDSrc;
-    PX86PD          pPDSrc = pgmGstGetPaePDPtr(&pVM->pgm.s, GCPtrPage, &iPDSrc);
+    PX86PDPAE       pPDSrc = pgmGstGetPaePDPtr(&pVM->pgm.s, GCPtrPage, &iPDSrc);
 
     GSTPDE          PdeSrc;;
@@ -942,5 +943,4 @@
             pPdeDst->u = 0;
             STAM_COUNTER_INC(&pVM->pgm.s.CTXMID(Stat,InvalidatePage4MBPages));
-            DUMP_PDE_BIG("PGMInvalidatePage", iPDSrc, PdeSrc);
             PGM_INVL_BIG_PG(GCPtrPage);
         }
@@ -971,13 +971,4 @@
 # endif
     return VINF_SUCCESS;
-
-#elif PGM_GST_TYPE == PGM_TYPE_PAE
-# if PGM_SHW_TYPE == PGM_TYPE_PAE
-//# error not implemented
-    return VERR_INTERNAL_ERROR;
-
-# else  /* PGM_SHW_TYPE != PGM_TYPE_AMD64 */
-#  error "Guest PAE mode, but not the shadow mode ; 32bit - maybe, but amd64 no."
-# endif /* PGM_SHW_TYPE != PGM_TYPE_AMD64 */
 
 #elif PGM_GST_TYPE == PGM_TYPE_AMD64
@@ -1107,5 +1098,5 @@
  * @remark  Not used for 2/4MB pages!
  */
-DECLINLINE(void) PGM_BTH_NAME(SyncPageWorker)(PVM pVM, PSHWPTE pPteDst, GSTPDE PdeSrc, VBOXPTE PteSrc, PPGMPOOLPAGE pShwPage, unsigned iPTDst)
+DECLINLINE(void) PGM_BTH_NAME(SyncPageWorker)(PVM pVM, PSHWPTE pPteDst, GSTPDE PdeSrc, GSTPTE PteSrc, PPGMPOOLPAGE pShwPage, unsigned iPTDst)
 {
     if (PteSrc.n.u1Present)
@@ -1243,5 +1234,6 @@
     LogFlow(("SyncPage: GCPtrPage=%VGv cPages=%d uErr=%#x\n", GCPtrPage, cPages, uErr));
 
-#if PGM_GST_TYPE == PGM_TYPE_32BIT
+#if    PGM_GST_TYPE == PGM_TYPE_32BIT \
+    || PGM_GST_TYPE == PGM_TYPE_PAE
 
 # if PGM_SHW_TYPE != PGM_TYPE_32BIT && PGM_SHW_TYPE != PGM_TYPE_PAE
@@ -1294,4 +1286,7 @@
         &&  (PdeSrc.n.u1User == PdeDst.n.u1User)
         &&  (PdeSrc.n.u1Write == PdeDst.n.u1Write || !PdeDst.n.u1Write)
+# if PGM_GST_TYPE == PGM_TYPE_PAE
+        &&  (PdeSrc.n.u1NoExecute == PdeDst.n.u1NoExecute)
+# endif
        )
     {
@@ -1311,5 +1306,5 @@
                  * 4KB Page - Map the guest page table.
                  */
-                PVBOXPT pPTSrc;
+                PGSTPT pPTSrc;
                 int rc = PGM_GCPHYS_2_PTR(pVM, PdeSrc.u & GST_PDE_PG_MASK, &pPTSrc);
                 if (VBOX_SUCCESS(rc))
@@ -1341,5 +1336,5 @@
                             if (!pPTDst->a[iPTDst].n.u1Present)
                             {
-                                VBOXPTE PteSrc = pPTSrc->a[offPTSrc + iPTDst];
+                                GSTPTE PteSrc = pPTSrc->a[offPTSrc + iPTDst];
                                 RTGCUINTPTR GCPtrCurPage = ((RTGCUINTPTR)GCPtrPage & ~(RTGCUINTPTR)(GST_PT_MASK << GST_PT_SHIFT)) | ((offPTSrc + iPTDst) << PAGE_SHIFT);
                                 NOREF(GCPtrCurPage);
@@ -1373,5 +1368,5 @@
                     {
                         const unsigned iPTSrc = (GCPtrPage >> GST_PT_SHIFT) & GST_PT_MASK;
-                        VBOXPTE PteSrc = pPTSrc->a[iPTSrc];
+                        GSTPTE PteSrc = pPTSrc->a[iPTSrc];
                         const unsigned iPTDst = (GCPtrPage >> SHW_PT_SHIFT) & SHW_PT_MASK;
                         PGM_BTH_NAME(SyncPageWorker)(pVM, &pPTDst->a[iPTDst], PdeSrc, PteSrc, pShwPage, iPTDst);
@@ -1529,5 +1524,5 @@
             if (!pPTDst->a[iPTDst].n.u1Present)
             {
-                VBOXPTE PteSrc;
+                GSTPTE PteSrc;
 
                 RTGCUINTPTR GCPtrCurPage = ((RTGCUINTPTR)GCPtrPage & ~(RTGCUINTPTR)(GST_PT_MASK << GST_PT_SHIFT)) | ((offPTSrc + iPTDst) << PAGE_SHIFT);
@@ -1556,5 +1551,5 @@
 # endif /* PGM_SYNC_N_PAGES */
     {
-        VBOXPTE PteSrc;
+        GSTPTE PteSrc;
         const unsigned iPTDst = (GCPtrPage >> SHW_PT_SHIFT) & SHW_PT_MASK;
         RTGCUINTPTR GCPtrCurPage = ((RTGCUINTPTR)GCPtrPage & ~(RTGCUINTPTR)(GST_PT_MASK << GST_PT_SHIFT)) | ((offPTSrc + iPTDst) << PAGE_SHIFT);
@@ -1611,7 +1606,7 @@
     if (    (uErr & X86_TRAP_PF_RSVD)
         ||  !pPdeSrc->n.u1Present
-#if PGM_GST_TYPE == PGM_TYPE_PAE
+#  if PGM_WITH_NX(PGM_GST_TYPE)
         ||  ((uErr & X86_TRAP_PF_ID) &&  pPdeSrc->n.u1NoExecute)
-#endif
+#  endif
         ||  ((uErr & X86_TRAP_PF_RW) && !pPdeSrc->n.u1Write)
         ||  ((uErr & X86_TRAP_PF_US) && !pPdeSrc->n.u1User) )
@@ -1701,7 +1696,7 @@
         const GSTPTE   PteSrc = *pPteSrc;
         if (    !PteSrc.n.u1Present
-#if PGM_GST_TYPE == PGM_TYPE_PAE
+#  if PGM_WITH_NX(PGM_GST_TYPE)
             ||  ((uErr & X86_TRAP_PF_ID) && !PteSrc.n.u1NoExecute)
-#endif
+#  endif
             ||  ((uErr & X86_TRAP_PF_RW) && !PteSrc.n.u1Write)
             ||  ((uErr & X86_TRAP_PF_US) && !PteSrc.n.u1User)
@@ -1842,5 +1837,6 @@
     LogFlow(("SyncPT: GCPtrPage=%VGv\n", GCPtrPage));
 
-#if PGM_GST_TYPE == PGM_TYPE_32BIT
+#if    PGM_GST_TYPE == PGM_TYPE_32BIT \
+    || PGM_GST_TYPE == PGM_TYPE_PAE
 
 # if PGM_SHW_TYPE != PGM_TYPE_32BIT && PGM_SHW_TYPE != PGM_TYPE_PAE
@@ -1861,4 +1857,5 @@
     SHWPDE          PdeDst = *pPdeDst;
 
+# if PGM_GST_TYPE == PGM_TYPE_32BIT
     /*
      * Check for conflicts.
@@ -1869,9 +1866,9 @@
     {
         Assert(pgmMapAreMappingsEnabled(&pVM->pgm.s));
-# ifndef IN_RING3
+#  ifndef IN_RING3
         Log(("SyncPT: Conflict at %VGv\n", GCPtrPage));
         STAM_PROFILE_STOP(&pVM->pgm.s.CTXMID(Stat,SyncPT), a);
         return VERR_ADDRESS_CONFLICT;
-# else
+#  else
         PPGMMAPPING pMapping = pgmGetMapping(pVM, (RTGCPTR)GCPtrPage);
         Assert(pMapping);
@@ -1883,6 +1880,10 @@
         }
         PdeDst = *pPdeDst;
-# endif
+#  endif
     }
+# else /* PGM_GST_TYPE == PGM_TYPE_32BIT */
+    /* PAE and AMD64 modes are hardware accelerated only, so there are no mappings. */
+    Assert(!pgmMapAreMappingsEnabled(&pVM->pgm.s));
+# endif /* PGM_GST_TYPE == PGM_TYPE_32BIT */
     Assert(!PdeDst.n.u1Present); /* We're only supposed to call SyncPT on PDE!P and conflicts.*/
 
@@ -2603,4 +2604,5 @@
             &&  (PdeSrc.n.u1User || fRawR0Enabled))
         {
+#  if PGM_GST_TYPE == PGM_TYPE_32BIT
             /*
              * Check for conflicts with GC mappings.
@@ -2619,5 +2621,5 @@
                 }
 
-#ifdef IN_RING3
+#   ifdef IN_RING3
                 int rc = pgmR3SyncPTResolveConflict(pVM, pMapping, pPDSrc, iPD);
                 if (VBOX_FAILURE(rc))
@@ -2631,10 +2633,13 @@
                     pMapping = pMapping->pNextR3;
                 iPdNoMapping = pMapping ? pMapping->GCPtr >> X86_PD_SHIFT : ~0U;
-#else
+#   else
                 LogFlow(("SyncCR3: detected conflict -> VINF_PGM_SYNC_CR3\n"));
                 return VINF_PGM_SYNC_CR3;
-#endif
-            }
-
+#   endif
+            }
+#  else /* PGM_GST_TYPE == PGM_TYPE_32BIT */
+            /* PAE and AMD64 modes are hardware accelerated only, so there are no mappings. */
+            Assert(iPD != iPdNoMapping);
+#  endif /* PGM_GST_TYPE == PGM_TYPE_32BIT */
             /*
              * Sync page directory entry.
@@ -2742,4 +2747,5 @@
         else
         {
+#  if PGM_GST_TYPE == PGM_TYPE_32BIT
             Assert(pgmMapAreMappingsEnabled(&pVM->pgm.s));
             const unsigned cPTs = pMapping->cPTs;
@@ -2763,5 +2769,5 @@
                         &&  (pPDSrc->a[iPD + iPT].n.u1User || fRawR0Enabled))
                     {
-#  ifdef IN_RING3
+#   ifdef IN_RING3
                         int rc = pgmR3SyncPTResolveConflict(pVM, pMapping, pPDSrc, iPD);
                         if (VBOX_FAILURE(rc))
@@ -2776,8 +2782,8 @@
                         iPdNoMapping = pMapping ? pMapping->GCPtr >> X86_PD_SHIFT : ~0U;
                         break;
-#  else
+#   else
                         LogFlow(("SyncCR3: detected conflict -> VINF_PGM_SYNC_CR3\n"));
                         return VINF_PGM_SYNC_CR3;
-#  endif
+#   endif
                     }
                 }
@@ -2788,5 +2794,10 @@
                         iPdNoMapping = pMapping->GCPtr >> X86_PD_SHIFT;
                 }
-            }
+#  else /* PGM_GST_TYPE == PGM_TYPE_32BIT */
+                /* PAE and AMD64 modes are hardware accelerated only, so there are no mappings. */
+                AssertFailed();
+#  endif /* PGM_GST_TYPE == PGM_TYPE_32BIT */
+            }
+
             /* advance. */
             iPD += cPTs - 1;
Index: /trunk/src/VBox/VMM/VMMAll/PGMAllGst.h
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/PGMAllGst.h	(revision 7628)
+++ /trunk/src/VBox/VMM/VMMAll/PGMAllGst.h	(revision 7629)
@@ -134,5 +134,5 @@
    || PGM_GST_TYPE == PGM_TYPE_PAE \
    || PGM_GST_TYPE == PGM_TYPE_AMD64
-
+ 	
 #if PGM_GST_TYPE == PGM_TYPE_AMD64
     /* later */
@@ -179,6 +179,13 @@
          */
         if (pfFlags)
+        {
             *pfFlags = (Pte.u & ~GST_PTE_PG_MASK)
                      & ((Pde.u & (X86_PTE_RW | X86_PTE_US)) | ~(uint64_t)(X86_PTE_RW | X86_PTE_US));
+# if PGM_WITH_NX(PGM_GST_TYPE)
+            /* The NX bit is determined by a bitwise OR between the PT and PD */
+            if (Pde.u & X86_PTE_PAE_NX)
+                *pfFlags |= X86_PTE_PAE_NX;
+# endif
+        }
         if (pGCPhys)
             *pGCPhys = Pte.u & GST_PTE_PG_MASK;
@@ -791,4 +798,5 @@
  || PGM_GST_TYPE == PGM_TYPE_PAE \
  || PGM_GST_TYPE == PGM_TYPE_AMD64
+
 #if PGM_GST_TYPE == PGM_TYPE_AMD64
     AssertFailed();
Index: /trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp	(revision 7628)
+++ /trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp	(revision 7629)
@@ -982,9 +982,9 @@
                 else
                 {   /* (normal page) */
-                    PVBOXPT pPT;
+                    PX86PT pPT;
                     rc = PGM_GCPHYS_2_PTR(pVM, Pde.u & X86_PDE_PG_MASK, &pPT);
                     if (VBOX_SUCCESS(rc))
                     {
-                        VBOXPTE Pte = pPT->a[((RTGCUINTPTR)GCPtr >> X86_PT_SHIFT) & X86_PT_MASK];
+                        X86PTE Pte = pPT->a[((RTGCUINTPTR)GCPtr >> X86_PT_SHIFT) & X86_PT_MASK];
                         if (Pte.n.u1Present)
                             return PGMPhysGCPhys2HCPtr(pVM, (Pte.u & X86_PTE_PG_MASK) | ((RTGCUINTPTR)GCPtr & PAGE_OFFSET_MASK), 1 /* we always stay within one page */, pHCPtr);
Index: /trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp	(revision 7628)
+++ /trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp	(revision 7629)
@@ -106,6 +106,4 @@
     CHECK_SIZE(VBOXIDTR, 6);
     CHECK_SIZE(VBOXGDTR, 6);
-    CHECK_SIZE(VBOXPTE, 4);
-    CHECK_SIZE(VBOXPDE, 4);
     CHECK_SIZE(VBOXTSS, 136);
     CHECK_SIZE(X86FXSTATE, 512);
