Index: trunk/include/VBox/hwacc_svm.h
===================================================================
--- trunk/include/VBox/hwacc_svm.h	(revision 9007)
+++ trunk/include/VBox/hwacc_svm.h	(revision 9008)
@@ -686,4 +686,17 @@
 DECLASM(void) SVMInvlpgA(RTGCPTR pPageGC, uint32_t u32ASID);
 
+#ifdef IN_RING0
+
+/**
+ * Invalidates a guest page
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ * @param   GCVirt      Page to invalidate
+ */
+HWACCMR0DECL(int) SVMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt);
+
+#endif /* IN_RING0 */
+
 /** @} */
 
Index: trunk/include/VBox/hwaccm.h
===================================================================
--- trunk/include/VBox/hwaccm.h	(revision 9007)
+++ trunk/include/VBox/hwaccm.h	(revision 9008)
@@ -66,4 +66,26 @@
 #define HWACCMIsEnabled(a)    (a->fHWACCMEnabled)
 
+/**
+ * Invalidates a guest page
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ * @param   GCVirt      Page to invalidate
+ */
+HWACCMDECL(int) HWACCMInvalidatePage(PVM pVM, RTGCPTR GCVirt);
+
+#ifndef IN_GC
+/**
+ * Flushes the guest TLB
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
+HWACCMDECL(int) HWACCMFlushTLB(PVM pVM);
+#else
+/* Nop in GC */
+#define HWACCMFlushTLB(pVM)     do { } while (0)
+#endif
+
 #ifdef IN_RING0
 /** @defgroup grp_hwaccm_r0    The VM Hardware Manager API
Index: trunk/src/VBox/VMM/Makefile.kmk
===================================================================
--- trunk/src/VBox/VMM/Makefile.kmk	(revision 9007)
+++ trunk/src/VBox/VMM/Makefile.kmk	(revision 9008)
@@ -102,4 +102,5 @@
 	VMMAll/CPUMAllRegs.cpp \
 	VMMAll/DBGFAll.cpp \
+	VMMAll/HWACCMAll.cpp \
 	VMMAll/IOMAll.cpp \
 	VMMAll/IOMAllMMIO.cpp \
@@ -390,4 +391,5 @@
 	VMMAll/EMAll.cpp \
 	VMMAll/EMAllA.asm \
+	VMMAll/HWACCMAll.cpp \
 	VMMAll/IOMAll.cpp \
 	VMMAll/IOMAllMMIO.cpp \
Index: trunk/src/VBox/VMM/PGMInternal.h
===================================================================
--- trunk/src/VBox/VMM/PGMInternal.h	(revision 9007)
+++ trunk/src/VBox/VMM/PGMInternal.h	(revision 9008)
@@ -268,7 +268,7 @@
 # define PGM_INVL_PG(GCVirt)        ASMInvalidatePage((void *)(GCVirt))
 #elif defined(IN_RING0)
-# define PGM_INVL_PG(GCVirt)        HWACCMR0InvalidatePage(pVM, (RTGCPTR)(GCVirt))
+# define PGM_INVL_PG(GCVirt)        HWACCMInvalidatePage(pVM, (RTGCPTR)(GCVirt))
 #else
-# define PGM_INVL_PG(GCVirt)        ((void)0)
+# define PGM_INVL_PG(GCVirt)        HWACCMInvalidatePage(pVM, (RTGCPTR)(GCVirt))
 #endif
 
@@ -281,7 +281,7 @@
 # define PGM_INVL_BIG_PG(GCVirt)    ASMReloadCR3()
 #elif defined(IN_RING0)
-# define PGM_INVL_BIG_PG(GCVirt)    HWACCMR0FlushTLB(pVM)
+# define PGM_INVL_BIG_PG(GCVirt)    HWACCMFlushTLB(pVM)
 #else
-# define PGM_INVL_BIG_PG(GCVirt)    ((void)0)
+# define PGM_INVL_BIG_PG(GCVirt)    HWACCMFlushTLB(pVM)
 #endif
 
@@ -292,7 +292,7 @@
 # define PGM_INVL_GUEST_TLBS()      ASMReloadCR3()
 #elif defined(IN_RING0)
-# define PGM_INVL_GUEST_TLBS()      HWACCMR0FlushTLB(pVM)
+# define PGM_INVL_GUEST_TLBS()      HWACCMFlushTLB(pVM)
 #else
-# define PGM_INVL_GUEST_TLBS()      ((void)0)
+# define PGM_INVL_GUEST_TLBS()      HWACCMFlushTLB(pVM)
 #endif
 
Index: trunk/src/VBox/VMM/VMMAll/PGMAllHandler.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMAll/PGMAllHandler.cpp	(revision 9007)
+++ trunk/src/VBox/VMM/VMMAll/PGMAllHandler.cpp	(revision 9008)
@@ -166,4 +166,5 @@
         }
         pVM->pgm.s.fPhysCacheFlushPending = true;
+        HWACCMFlushTLB(pVM);
 #ifndef IN_RING3
         REMNotifyHandlerPhysicalRegister(pVM, enmType, GCPhys, GCPhysLast - GCPhys + 1, !!pfnHandlerR3);
@@ -298,4 +299,5 @@
          * Clear the page bits and notify the REM about this change.
          */
+        HWACCMFlushTLB(pVM);
         pgmHandlerPhysicalResetRamFlags(pVM, pCur);
         pgmHandlerPhysicalDeregisterNotifyREM(pVM, pCur);
@@ -540,4 +542,5 @@
                                                      pCur->Core.KeyLast - GCPhys + 1, !!pCur->pfnHandlerR3, fRestoreAsRAM);
 #endif
+                    HWACCMFlushTLB(pVM);
                     pgmUnlock(pVM);
                     Log(("PGMHandlerPhysicalModify: GCPhysCurrent=%VGp -> GCPhys=%VGp GCPhysLast=%VGp\n",
@@ -631,5 +634,5 @@
 
 /**
- * Splitts a physical access handler in two.
+ * Splits a physical access handler in two.
  *
  * @returns VBox status code.
@@ -813,4 +816,5 @@
                 }
                 pVM->pgm.s.fPhysCacheFlushPending = true;
+                HWACCMFlushTLB(pVM);
 
                 rc = VINF_SUCCESS;
Index: trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp	(revision 9007)
+++ trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp	(revision 9008)
@@ -908,5 +908,5 @@
 static int pgmPoolCacheFreeOne(PPGMPOOL pPool, uint16_t iUser)
 {
-#ifdef IN_RING0
+#ifndef IN_GC
     const PVM pVM = pPool->CTXSUFF(pVM);
 #endif
@@ -1035,5 +1035,5 @@
 static int pgmPoolCacheAlloc(PPGMPOOL pPool, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, uint16_t iUser, uint16_t iUserTable, PPPGMPOOLPAGE ppPage)
 {
-#ifdef IN_RING0
+#ifndef IN_GC
     const PVM pVM = pPool->CTXSUFF(pVM);
 #endif
Index: trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp	(revision 9007)
+++ trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp	(revision 9008)
@@ -812,33 +812,4 @@
         return SVMR0RunGuestCode(pVM, pCtx, &HWACCMR0Globals.aCpuInfo[idCpu]);
     }
-}
-
-/**
- * Invalidates a guest page
- *
- * @returns VBox status code.
- * @param   pVM         The VM to operate on.
- * @param   GCVirt      Page to invalidate
- */
-HWACCMR0DECL(int) HWACCMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt)
-{
-    if (pVM->hwaccm.s.svm.fSupported)
-        return SVMR0InvalidatePage(pVM, GCVirt);
-
-    return VINF_SUCCESS;
-}
-
-/**
- * Flushes the guest TLB
- *
- * @returns VBox status code.
- * @param   pVM         The VM to operate on.
- */
-HWACCMR0DECL(int) HWACCMR0FlushTLB(PVM pVM)
-{
-    if (pVM->hwaccm.s.svm.fSupported)
-        return SVMR0FlushTLB(pVM);
-
-    return VINF_SUCCESS;
 }
 
Index: trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp	(revision 9007)
+++ trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp	(revision 9008)
@@ -266,5 +266,5 @@
         pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(3) | RT_BIT(4) | RT_BIT(8);
     else
-        pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(4) | RT_BIT(8);
+        pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(8);
 
     /* Intercept all DRx reads and writes. */
@@ -1414,4 +1414,5 @@
             break;
         case 4:
+            Assert(!pVM->hwaccm.s.svm.fNestedPaging);
             pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR4;
             break;
@@ -1877,15 +1878,2 @@
 }
 
-/**
- * Flushes the guest TLB
- *
- * @returns VBox status code.
- * @param   pVM         The VM to operate on.
- */
-HWACCMR0DECL(int) SVMR0FlushTLB(PVM pVM)
-{
-    Log2(("SVMR0FlushTLB\n"));
-    pVM->hwaccm.s.svm.fForceTLBFlush = true;
-    STAM_COUNTER_INC(&pVM->hwaccm.s.StatFlushTLBManual);
-    return VINF_SUCCESS;
-}
Index: trunk/src/VBox/VMM/VMMR0/HWSVMR0.h
===================================================================
--- trunk/src/VBox/VMM/VMMR0/HWSVMR0.h	(revision 9007)
+++ trunk/src/VBox/VMM/VMMR0/HWSVMR0.h	(revision 9008)
@@ -127,21 +127,4 @@
 HWACCMR0DECL(int) SVMR0LoadGuestState(PVM pVM, CPUMCTX *pCtx);
 
-/**
- * Invalidates a guest page
- *
- * @returns VBox status code.
- * @param   pVM         The VM to operate on.
- * @param   GCVirt      Page to invalidate
- */
-HWACCMR0DECL(int) SVMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt);
-
-/**
- * Flushes the guest TLB
- *
- * @returns VBox status code.
- * @param   pVM         The VM to operate on.
- */
-HWACCMR0DECL(int) SVMR0FlushTLB(PVM pVM);
-
 
 /* Convert hidden selector attribute word between VMX and SVM formats. */
Index: trunk/src/VBox/VMM/VMMR0/PGMR0.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR0/PGMR0.cpp	(revision 9007)
+++ trunk/src/VBox/VMM/VMMR0/PGMR0.cpp	(revision 9008)
@@ -82,5 +82,5 @@
 
     /* AMD uses the host's paging mode; Intel's version is on the todo list */
-    Assert(enmShwPagingMode == PGMMODE_32_BIT || enmShwPagingMode == PGMMODE_PAE); // || enmShwPagingMode == PGMMODE_AMD64);
+    Assert(enmShwPagingMode == PGMMODE_32_BIT || enmShwPagingMode == PGMMODE_PAE || enmShwPagingMode == PGMMODE_AMD64);
 
 #ifdef VBOX_WITH_STATISTICS
