Index: /trunk/src/VBox/VMM/HWACCM.cpp
===================================================================
--- /trunk/src/VBox/VMM/HWACCM.cpp	(revision 7495)
+++ /trunk/src/VBox/VMM/HWACCM.cpp	(revision 7496)
@@ -90,49 +90,4 @@
     if (VBOX_FAILURE(rc))
         return rc;
-
-    /* Allocate one page for the VM control structure (VMCS). */
-    pVM->hwaccm.s.vmx.pVMCS = SUPContAlloc(1, &pVM->hwaccm.s.vmx.pVMCSPhys);
-    if (pVM->hwaccm.s.vmx.pVMCS == 0)
-    {
-        AssertMsgFailed(("SUPContAlloc failed!!\n"));
-        return VERR_NO_MEMORY;
-    }
-    memset(pVM->hwaccm.s.vmx.pVMCS, 0, PAGE_SIZE);
-
-    /* Allocate one page for the TSS we need for real mode emulation. */
-    pVM->hwaccm.s.vmx.pRealModeTSS = (PVBOXTSS)SUPContAlloc(1, &pVM->hwaccm.s.vmx.pRealModeTSSPhys);
-    if (pVM->hwaccm.s.vmx.pRealModeTSS == 0)
-    {
-        AssertMsgFailed(("SUPContAlloc failed!!\n"));
-        return VERR_NO_MEMORY;
-    }
-    /* We initialize it properly later as we can reuse it for SVM */
-    memset(pVM->hwaccm.s.vmx.pRealModeTSS, 0, PAGE_SIZE);
-
-    /* Reuse those three pages for AMD SVM. (one is active; never both) */
-    pVM->hwaccm.s.svm.pVMCB         = pVM->hwaccm.s.vmx.pVMCS;
-    pVM->hwaccm.s.svm.pVMCBPhys     = pVM->hwaccm.s.vmx.pVMCSPhys;
-    pVM->hwaccm.s.svm.pVMCBHost     = pVM->hwaccm.s.vmx.pRealModeTSS;
-    pVM->hwaccm.s.svm.pVMCBHostPhys = pVM->hwaccm.s.vmx.pRealModeTSSPhys;
-
-    /* Allocate 12 KB for the IO bitmap (doesn't seem to be a way to convince SVM not to use it) */
-    pVM->hwaccm.s.svm.pIOBitmap = SUPContAlloc(3, &pVM->hwaccm.s.svm.pIOBitmapPhys);
-    if (pVM->hwaccm.s.svm.pIOBitmap == 0)
-    {
-        AssertMsgFailed(("SUPContAlloc failed!!\n"));
-        return VERR_NO_MEMORY;
-    }
-    /* Set all bits to intercept all IO accesses. */
-    memset(pVM->hwaccm.s.svm.pIOBitmap, 0xff, PAGE_SIZE*3);
-
-    /* Allocate 8 KB for the MSR bitmap (doesn't seem to be a way to convince SVM not to use it) */
-    pVM->hwaccm.s.svm.pMSRBitmap = SUPContAlloc(2, &pVM->hwaccm.s.svm.pMSRBitmapPhys);
-    if (pVM->hwaccm.s.svm.pMSRBitmap == 0)
-    {
-        AssertMsgFailed(("SUPContAlloc failed!!\n"));
-        return VERR_NO_MEMORY;
-    }
-    /* Set all bits to intercept all MSR accesses. */
-    memset(pVM->hwaccm.s.svm.pMSRBitmap, 0xff, PAGE_SIZE*2);
 
     /* Misc initialisation. */
@@ -431,10 +386,4 @@
             pVM->hwaccm.s.fInitialized = true;
 
-            /* The I/O bitmap starts right after the virtual interrupt redirection bitmap. Outside the TSS on purpose; the CPU will not check it
-             * for I/O operations. */
-            pVM->hwaccm.s.vmx.pRealModeTSS->offIoBitmap = sizeof(*pVM->hwaccm.s.vmx.pRealModeTSS);
-            /* Bit set to 0 means redirection enabled. */
-            memset(pVM->hwaccm.s.vmx.pRealModeTSS->IntRedirBitmap, 0x0, sizeof(pVM->hwaccm.s.vmx.pRealModeTSS->IntRedirBitmap));
-
             rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_HWACC_SETUP_VM, 0, NULL);
             AssertRC(rc);
@@ -545,25 +494,4 @@
         pVM->hwaccm.s.pStatExitReason = 0;
     }
-
-    if (pVM->hwaccm.s.vmx.pVMCS)
-    {
-        SUPContFree(pVM->hwaccm.s.vmx.pVMCS, 1);
-        pVM->hwaccm.s.vmx.pVMCS = 0;
-    }
-    if (pVM->hwaccm.s.vmx.pRealModeTSS)
-    {
-        SUPContFree(pVM->hwaccm.s.vmx.pRealModeTSS, 1);
-        pVM->hwaccm.s.vmx.pRealModeTSS = 0;
-    }
-    if (pVM->hwaccm.s.svm.pIOBitmap)
-    {
-        SUPContFree(pVM->hwaccm.s.svm.pIOBitmap, 3);
-        pVM->hwaccm.s.svm.pIOBitmap = 0;
-    }
-    if (pVM->hwaccm.s.svm.pMSRBitmap)
-    {
-        SUPContFree(pVM->hwaccm.s.svm.pMSRBitmap, 2);
-        pVM->hwaccm.s.svm.pMSRBitmap = 0;
-    }
     return 0;
 }
Index: /trunk/src/VBox/VMM/HWACCMInternal.h
===================================================================
--- /trunk/src/VBox/VMM/HWACCMInternal.h	(revision 7495)
+++ /trunk/src/VBox/VMM/HWACCMInternal.h	(revision 7496)
@@ -26,4 +26,5 @@
 #include <VBox/hwaccm.h>
 #include <VBox/pgm.h>
+#include <iprt/memobj.h>
 
 __BEGIN_DECLS
@@ -149,13 +150,17 @@
         bool                        fResumeVM;
 
+        /** R0 memory object for the VM control structure (VMCS). */
+        RTR0MEMOBJ                  pMemObjVMCS;
         /** Physical address of the VM control structure (VMCS). */
         RTHCPHYS                    pVMCSPhys;
         /** Virtual address of the VM control structure (VMCS). */
-        void                       *pVMCS;
-
+        R0PTRTYPE(void *)           pVMCS;
+
+        /** R0 memory object for the TSS page used for real mode emulation. */
+        RTR0MEMOBJ                  pMemObjRealModeTSS;
         /** Physical address of the TSS page used for real mode emulation. */
         RTHCPHYS                    pRealModeTSSPhys;
         /** Virtual address of the TSS page used for real mode emulation. */
-        PVBOXTSS                    pRealModeTSS;
+        R0PTRTYPE(PVBOXTSS)         pRealModeTSS;
 
         /** Host CR4 value (set by ring-0 VMX init) */
@@ -202,23 +207,31 @@
         bool                        fResumeVM;
 
+        /** R0 memory object for the VM control block (VMCB). */
+        RTR0MEMOBJ                  pMemObjVMCB;
         /** Physical address of the VM control block (VMCB). */
         RTHCPHYS                    pVMCBPhys;
         /** Virtual address of the VM control block (VMCB). */
-        void                       *pVMCB;
-
+        R0PTRTYPE(void *)           pVMCB;
+
+        /** R0 memory object for the host VM control block (VMCB). */
+        RTR0MEMOBJ                  pMemObjVMCBHost;
         /** Physical address of the host VM control block (VMCB). */
         RTHCPHYS                    pVMCBHostPhys;
         /** Virtual address of the host VM control block (VMCB). */
-        void                       *pVMCBHost;
-
+        R0PTRTYPE(void *)           pVMCBHost;
+
+        /** R0 memory object for the IO bitmap (12kb). */
+        RTR0MEMOBJ                  pMemObjIOBitmap;
         /** Physical address of the IO bitmap (12kb). */
         RTHCPHYS                    pIOBitmapPhys;
         /** Virtual address of the IO bitmap. */
-        void                       *pIOBitmap;
-
+        R0PTRTYPE(void *)           pIOBitmap;
+
+        /** R0 memory object for the MSR bitmap (8kb). */
+        RTR0MEMOBJ                  pMemObjMSRBitmap;
         /** Physical address of the MSR bitmap (8kb). */
         RTHCPHYS                    pMSRBitmapPhys;
         /** Virtual address of the MSR bitmap. */
-        void                       *pMSRBitmap;
+        R0PTRTYPE(void *)           pMSRBitmap;
 
         /** SVM revision. */
Index: /trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp	(revision 7495)
+++ /trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp	(revision 7496)
@@ -586,8 +586,14 @@
 HWACCMR0DECL(int) HWACCMR0InitVM(PVM pVM)
 {
-    LogComFlow(("HWACCMR0Init: %p\n", pVM));
-
-    pVM->hwaccm.s.vmx.fSupported = HWACCMR0Globals.vmx.fSupported;
-    pVM->hwaccm.s.svm.fSupported = HWACCMR0Globals.svm.fSupported;
+    int rc = VINF_SUCCESS;
+
+    AssertReturn(pVM, VERR_INVALID_PARAMETER);
+
+#ifdef LOG_ENABLED
+    SUPR0Printf("HWACCMR0InitVM: %p\n", pVM);
+#endif
+
+    pVM->hwaccm.s.vmx.fSupported            = HWACCMR0Globals.vmx.fSupported;
+    pVM->hwaccm.s.svm.fSupported            = HWACCMR0Globals.svm.fSupported;
 
     pVM->hwaccm.s.vmx.msr.feature_ctrl      = HWACCMR0Globals.vmx.msr.feature_ctrl;
@@ -609,26 +615,64 @@
     pVM->hwaccm.s.cpuid.u32AMDFeatureEDX    = HWACCMR0Globals.cpuid.u32AMDFeatureEDX;
     pVM->hwaccm.s.lLastError                = HWACCMR0Globals.lLastError;
-    return VINF_SUCCESS;
-}
-
-
-
-/**
- * Sets up a VT-x or AMD-V session
+
+    /* Init a VT-x or AMD-V VM. */
+    if (pVM->hwaccm.s.vmx.fSupported)
+        rc = VMXR0InitVM(pVM);
+    else
+    if (pVM->hwaccm.s.svm.fSupported)
+        rc = SVMR0InitVM(pVM);
+
+    return rc;
+}
+
+
+/**
+ * Does Ring-0 per VM HWACCM termination.
  *
  * @returns VBox status code.
  * @param   pVM         The VM to operate on.
  */
+HWACCMR0DECL(int) HWACCMR0TermVM(PVM pVM)
+{
+    int rc = VINF_SUCCESS;
+
+    AssertReturn(pVM, VERR_INVALID_PARAMETER);
+
+#ifdef LOG_ENABLED
+    SUPR0Printf("HWACCMR0TermVM: %p\n", pVM);
+#endif
+
+    /* Terminate a VT-x or AMD-V VM. */
+    if (pVM->hwaccm.s.vmx.fSupported)
+        rc = VMXR0TermVM(pVM);
+    else
+    if (pVM->hwaccm.s.svm.fSupported)
+        rc = SVMR0TermVM(pVM);
+
+    return rc;
+}
+
+
+/**
+ * Sets up a VT-x or AMD-V session
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
 HWACCMR0DECL(int) HWACCMR0SetupVM(PVM pVM)
 {
     int rc = VINF_SUCCESS;
 
-    if (pVM == NULL)
-        return VERR_INVALID_PARAMETER;
-
-    /* Setup Intel VMX. */
+    AssertReturn(pVM, VERR_INVALID_PARAMETER);
+
+#ifdef LOG_ENABLED
+    SUPR0Printf("HWACCMR0SetupVM: %p\n", pVM);
+#endif
+
+    /* Setup VT-x or AMD-V. */
     if (pVM->hwaccm.s.vmx.fSupported)
         rc = VMXR0SetupVM(pVM);
     else
+    if (pVM->hwaccm.s.svm.fSupported)
         rc = SVMR0SetupVM(pVM);
 
Index: /trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp	(revision 7495)
+++ /trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp	(revision 7496)
@@ -92,5 +92,95 @@
 
 /**
- * Sets up SVM for the specified VM
+ * Does Ring-0 per VM AMD-V init.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
+HWACCMR0DECL(int) SVMR0InitVM(PVM pVM)
+{
+    int rc;
+
+    /* Allocate one page for the VM control block (VMCB). */
+    rc = RTR0MemObjAllocCont(&pVM->hwaccm.s.svm.pMemObjVMCB, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    pVM->hwaccm.s.svm.pVMCB     = RTR0MemObjAddress(pVM->hwaccm.s.svm.pMemObjVMCB);
+    pVM->hwaccm.s.svm.pVMCBPhys = RTR0MemObjGetPagePhysAddr(pVM->hwaccm.s.svm.pMemObjVMCB, 0);
+    ASMMemZero32(pVM->hwaccm.s.svm.pVMCB, PAGE_SIZE);
+
+    /* Allocate one page for the host context */
+    rc = RTR0MemObjAllocCont(&pVM->hwaccm.s.svm.pMemObjVMCBHost, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    pVM->hwaccm.s.svm.pVMCBHost     = RTR0MemObjAddress(pVM->hwaccm.s.svm.pMemObjVMCBHost);
+    pVM->hwaccm.s.svm.pVMCBHostPhys = RTR0MemObjGetPagePhysAddr(pVM->hwaccm.s.svm.pMemObjVMCBHost, 0);
+    ASMMemZero32(pVM->hwaccm.s.svm.pVMCBHost, PAGE_SIZE);
+
+    /* Allocate 12 KB for the IO bitmap (doesn't seem to be a way to convince SVM not to use it) */
+    rc = RTR0MemObjAllocCont(&pVM->hwaccm.s.svm.pMemObjIOBitmap, 3 << PAGE_SHIFT, true /* executable R0 mapping */);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    pVM->hwaccm.s.svm.pIOBitmap     = RTR0MemObjAddress(pVM->hwaccm.s.svm.pMemObjIOBitmap);
+    pVM->hwaccm.s.svm.pIOBitmapPhys = RTR0MemObjGetPagePhysAddr(pVM->hwaccm.s.svm.pMemObjIOBitmap, 0);
+    /* Set all bits to intercept all IO accesses. */
+    ASMMemFill32(pVM->hwaccm.s.svm.pIOBitmap, PAGE_SIZE*3, 0xffffffff);
+
+    /* Allocate 8 KB for the MSR bitmap (doesn't seem to be a way to convince SVM not to use it) */
+    rc = RTR0MemObjAllocCont(&pVM->hwaccm.s.svm.pMemObjMSRBitmap, 2 << PAGE_SHIFT, true /* executable R0 mapping */);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    pVM->hwaccm.s.svm.pMSRBitmap     = RTR0MemObjAddress(pVM->hwaccm.s.svm.pMemObjMSRBitmap);
+    pVM->hwaccm.s.svm.pMSRBitmapPhys = RTR0MemObjGetPagePhysAddr(pVM->hwaccm.s.svm.pMemObjMSRBitmap, 0);
+    /* Set all bits to intercept all MSR accesses. */
+    ASMMemFill32(pVM->hwaccm.s.svm.pMSRBitmap, PAGE_SIZE*2, 0xffffffff);
+
+    return VINF_SUCCESS;
+}
+
+/**
+ * Does Ring-0 per VM AMD-V termination.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
+HWACCMR0DECL(int) SVMR0TermVM(PVM pVM)
+{
+    if (pVM->hwaccm.s.svm.pMemObjVMCB)
+    {
+        RTR0MemObjFree(pVM->hwaccm.s.svm.pMemObjVMCB, false);
+        pVM->hwaccm.s.svm.pVMCB       = 0;
+        pVM->hwaccm.s.svm.pVMCBPhys   = 0;
+        pVM->hwaccm.s.svm.pMemObjVMCB = 0;
+    }
+    if (pVM->hwaccm.s.svm.pMemObjVMCBHost)
+    {
+        RTR0MemObjFree(pVM->hwaccm.s.svm.pMemObjVMCBHost, false);
+        pVM->hwaccm.s.svm.pVMCBHost       = 0;
+        pVM->hwaccm.s.svm.pVMCBHostPhys   = 0;
+        pVM->hwaccm.s.svm.pMemObjVMCBHost = 0;
+    }
+    if (pVM->hwaccm.s.svm.pMemObjIOBitmap)
+    {
+        RTR0MemObjFree(pVM->hwaccm.s.svm.pMemObjIOBitmap, false);
+        pVM->hwaccm.s.svm.pIOBitmap       = 0;
+        pVM->hwaccm.s.svm.pIOBitmapPhys   = 0;
+        pVM->hwaccm.s.svm.pMemObjIOBitmap = 0;
+    }
+    if (pVM->hwaccm.s.svm.pMemObjMSRBitmap)
+    {
+        RTR0MemObjFree(pVM->hwaccm.s.svm.pMemObjMSRBitmap, false);
+        pVM->hwaccm.s.svm.pMSRBitmap       = 0;
+        pVM->hwaccm.s.svm.pMSRBitmapPhys   = 0;
+        pVM->hwaccm.s.svm.pMemObjMSRBitmap = 0;
+    }
+    return VINF_SUCCESS;
+}
+
+/**
+ * Sets up AMD-V for the specified VM
  *
  * @returns VBox status code.
@@ -102,8 +192,6 @@
     SVM_VMCB   *pVMCB;
 
-    if (pVM == NULL)
-        return VERR_INVALID_PARAMETER;
-
-    /* Setup AMD SVM. */
+    AssertReturn(pVM, VERR_INVALID_PARAMETER);
+
     Assert(pVM->hwaccm.s.svm.fSupported);
 
@@ -1469,6 +1557,4 @@
 HWACCMR0DECL(int) SVMR0Enter(PVM pVM)
 {
-    uint64_t val;
-
     Assert(pVM->hwaccm.s.svm.fSupported);
 
Index: /trunk/src/VBox/VMM/VMMR0/HWSVMR0.h
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HWSVMR0.h	(revision 7495)
+++ /trunk/src/VBox/VMM/VMMR0/HWSVMR0.h	(revision 7496)
@@ -76,4 +76,20 @@
 
 /**
+ * Does Ring-0 per VM AMD-V init.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
+HWACCMR0DECL(int) SVMR0InitVM(PVM pVM);
+
+/**
+ * Does Ring-0 per VM AMD-V termination.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
+HWACCMR0DECL(int) SVMR0TermVM(PVM pVM);
+
+/**
  * Sets up AMD-V for the specified VM
  *
Index: /trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp	(revision 7495)
+++ /trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp	(revision 7496)
@@ -34,4 +34,5 @@
 #include <iprt/assert.h>
 #include <iprt/asm.h>
+#include <iprt/string.h>
 #include "HWVMXR0.h"
 
@@ -122,4 +123,75 @@
 
 /**
+ * Does Ring-0 per VM VT-x init.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
+HWACCMR0DECL(int) VMXR0InitVM(PVM pVM)
+{
+    int rc;
+
+#ifdef LOG_ENABLED
+    SUPR0Printf("VMXR0InitVM %x\n", pVM);
+#endif
+
+    /* Allocate one page for the VM control structure (VMCS). */
+    rc = RTR0MemObjAllocCont(&pVM->hwaccm.s.vmx.pMemObjVMCS, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
+    AssertRC(rc);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    pVM->hwaccm.s.vmx.pVMCS     = RTR0MemObjAddress(pVM->hwaccm.s.vmx.pMemObjVMCS);
+    pVM->hwaccm.s.vmx.pVMCSPhys = RTR0MemObjGetPagePhysAddr(pVM->hwaccm.s.vmx.pMemObjVMCS, 0);
+    ASMMemZero32(pVM->hwaccm.s.vmx.pVMCS, PAGE_SIZE);
+
+    /* Allocate one page for the TSS we need for real mode emulation. */
+    rc = RTR0MemObjAllocCont(&pVM->hwaccm.s.vmx.pMemObjRealModeTSS, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
+    AssertRC(rc);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    pVM->hwaccm.s.vmx.pRealModeTSS     = (PVBOXTSS)RTR0MemObjAddress(pVM->hwaccm.s.vmx.pMemObjRealModeTSS);
+    pVM->hwaccm.s.vmx.pRealModeTSSPhys = RTR0MemObjGetPagePhysAddr(pVM->hwaccm.s.vmx.pMemObjRealModeTSS, 0);
+
+    /* The I/O bitmap starts right after the virtual interrupt redirection bitmap. Outside the TSS on purpose; the CPU will not check it
+     * for I/O operations. */
+    ASMMemZero32(pVM->hwaccm.s.vmx.pRealModeTSS, PAGE_SIZE);
+    pVM->hwaccm.s.vmx.pRealModeTSS->offIoBitmap = sizeof(*pVM->hwaccm.s.vmx.pRealModeTSS);
+    /* Bit set to 0 means redirection enabled. */
+    memset(pVM->hwaccm.s.vmx.pRealModeTSS->IntRedirBitmap, 0x0, sizeof(pVM->hwaccm.s.vmx.pRealModeTSS->IntRedirBitmap));
+
+#ifdef LOG_ENABLED
+    SUPR0Printf("VMXR0InitVM %x VMCS=%x (%x) RealModeTSS=%x (%x)\n", pVM, pVM->hwaccm.s.vmx.pVMCS, (uint32_t)pVM->hwaccm.s.vmx.pVMCSPhys, pVM->hwaccm.s.vmx.pRealModeTSS, (uint32_t)pVM->hwaccm.s.vmx.pRealModeTSSPhys);
+#endif
+    return VINF_SUCCESS;
+}
+
+/**
+ * Does Ring-0 per VM VT-x termination.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
+HWACCMR0DECL(int) VMXR0TermVM(PVM pVM)
+{
+    if (pVM->hwaccm.s.vmx.pMemObjVMCS)
+    {
+        RTR0MemObjFree(pVM->hwaccm.s.vmx.pMemObjVMCS, false);
+        pVM->hwaccm.s.vmx.pMemObjVMCS = 0;
+        pVM->hwaccm.s.vmx.pVMCS       = 0;
+        pVM->hwaccm.s.vmx.pVMCSPhys   = 0;
+    }
+    if (pVM->hwaccm.s.vmx.pMemObjRealModeTSS)
+    {
+        RTR0MemObjFree(pVM->hwaccm.s.vmx.pMemObjRealModeTSS, false);
+        pVM->hwaccm.s.vmx.pMemObjRealModeTSS = 0;
+        pVM->hwaccm.s.vmx.pRealModeTSS       = 0;
+        pVM->hwaccm.s.vmx.pRealModeTSSPhys   = 0;
+    }
+    return VINF_SUCCESS;
+}
+
+/**
  * Sets up VT-x for the specified VM
  *
@@ -132,6 +204,6 @@
     uint32_t val;
 
-    if (pVM == NULL)
-        return VERR_INVALID_PARAMETER;
+    AssertReturn(pVM, VERR_INVALID_PARAMETER);
+    Assert(pVM->hwaccm.s.vmx.pVMCS);
 
     /* Set revision dword at the beginning of the VMCS structure. */
Index: /trunk/src/VBox/VMM/VMMR0/HWVMXR0.h
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HWVMXR0.h	(revision 7495)
+++ /trunk/src/VBox/VMM/VMMR0/HWVMXR0.h	(revision 7496)
@@ -77,4 +77,20 @@
 
 /**
+ * Does Ring-0 per VM VT-x init.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
+HWACCMR0DECL(int) VMXR0InitVM(PVM pVM);
+
+/**
+ * Does Ring-0 per VM VT-x termination.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
+HWACCMR0DECL(int) VMXR0TermVM(PVM pVM);
+
+/**
  * Sets up VT-x for the specified VM
  *
Index: /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 7495)
+++ /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 7496)
@@ -251,4 +251,6 @@
 static int VMMR0Term(PVM pVM)
 {
+    HWACCMR0TermVM(pVM);
+
     /*
      * Deregister the logger.
