Index: trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp	(revision 87530)
+++ trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp	(revision 87531)
@@ -1980,8 +1980,8 @@
     if (pVM->hm.s.vmx.fUseVmcsShadowing)
     {
-        RTMemFree(pVM->hm.s.vmx.paShadowVmcsFields);
-        pVM->hm.s.vmx.paShadowVmcsFields = NULL;
-        RTMemFree(pVM->hm.s.vmx.paShadowVmcsRoFields);
-        pVM->hm.s.vmx.paShadowVmcsRoFields = NULL;
+        RTMemFree(pVM->hmr0.s.vmx.paShadowVmcsFields);
+        pVM->hmr0.s.vmx.paShadowVmcsFields = NULL;
+        RTMemFree(pVM->hmr0.s.vmx.paShadowVmcsRoFields);
+        pVM->hmr0.s.vmx.paShadowVmcsRoFields = NULL;
     }
 #endif
@@ -2031,9 +2031,9 @@
     VMXPAGEALLOCINFO aAllocInfo[] =
     {
-        { fVirtApicAccess,   0 /* Unused */, &pVM->hm.s.vmx.HCPhysApicAccess,    (PRTR0PTR)&pVM->hm.s.vmx.pbApicAccess },
-        { fUseVmcsShadowing, 0 /* Unused */, &pVM->hm.s.vmx.HCPhysVmreadBitmap,  &pVM->hm.s.vmx.pvVmreadBitmap         },
-        { fUseVmcsShadowing, 0 /* Unused */, &pVM->hm.s.vmx.HCPhysVmwriteBitmap, &pVM->hm.s.vmx.pvVmwriteBitmap        },
+        { fVirtApicAccess,   0 /* Unused */, &pVM->hmr0.s.vmx.HCPhysApicAccess,    (PRTR0PTR)&pVM->hmr0.s.vmx.pbApicAccess },
+        { fUseVmcsShadowing, 0 /* Unused */, &pVM->hmr0.s.vmx.HCPhysVmreadBitmap,  &pVM->hmr0.s.vmx.pvVmreadBitmap         },
+        { fUseVmcsShadowing, 0 /* Unused */, &pVM->hmr0.s.vmx.HCPhysVmwriteBitmap, &pVM->hmr0.s.vmx.pvVmwriteBitmap        },
 #ifdef VBOX_WITH_CRASHDUMP_MAGIC
-        { true,              0 /* Unused */, &pVM->hm.s.vmx.HCPhysScratch,       &(PRTR0PTR)pVM->hm.s.vmx.pbScratch    },
+        { true,              0 /* Unused */, &pVM->hmr0.s.vmx.HCPhysScratch,       (PRTR0PTR)&pVM->hmr0.s.vmx.pbScratch    },
 #endif
     };
@@ -2046,9 +2046,9 @@
         if (fUseVmcsShadowing)
         {
-            Assert(!pVM->hm.s.vmx.cShadowVmcsFields);
-            Assert(!pVM->hm.s.vmx.cShadowVmcsRoFields);
-            pVM->hm.s.vmx.paShadowVmcsFields   = (uint32_t *)RTMemAllocZ(sizeof(g_aVmcsFields));
-            pVM->hm.s.vmx.paShadowVmcsRoFields = (uint32_t *)RTMemAllocZ(sizeof(g_aVmcsFields));
-            if (!pVM->hm.s.vmx.paShadowVmcsFields || !pVM->hm.s.vmx.paShadowVmcsRoFields)
+            Assert(!pVM->hmr0.s.vmx.cShadowVmcsFields);
+            Assert(!pVM->hmr0.s.vmx.cShadowVmcsRoFields);
+            pVM->hmr0.s.vmx.paShadowVmcsFields   = (uint32_t *)RTMemAllocZ(sizeof(g_aVmcsFields));
+            pVM->hmr0.s.vmx.paShadowVmcsRoFields = (uint32_t *)RTMemAllocZ(sizeof(g_aVmcsFields));
+            if (!pVM->hmr0.s.vmx.paShadowVmcsFields || !pVM->hmr0.s.vmx.paShadowVmcsRoFields)
                 rc = VERR_NO_MEMORY;
         }
@@ -2086,7 +2086,7 @@
 {
     /* Paranoia. */
-    Assert(pVM->hm.s.vmx.pbApicAccess == NULL);
+    Assert(pVM->hmr0.s.vmx.pbApicAccess == NULL);
 #ifdef VBOX_WITH_CRASHDUMP_MAGIC
-    Assert(pVM->hm.s.vmx.pbScratch == NULL);
+    Assert(pVM->hmr0.s.vmx.pbScratch == NULL);
 #endif
 
@@ -2095,9 +2095,9 @@
      */
 #ifdef VBOX_WITH_CRASHDUMP_MAGIC
-    pVM->hm.s.vmx.HCPhysScratch = NIL_RTHCPHYS;
+    pVM->hmr0.s.vmx.HCPhysScratch       = NIL_RTHCPHYS;
 #endif
-    pVM->hm.s.vmx.HCPhysApicAccess    = NIL_RTHCPHYS;
-    pVM->hm.s.vmx.HCPhysVmreadBitmap  = NIL_RTHCPHYS;
-    pVM->hm.s.vmx.HCPhysVmwriteBitmap = NIL_RTHCPHYS;
+    pVM->hmr0.s.vmx.HCPhysApicAccess    = NIL_RTHCPHYS;
+    pVM->hmr0.s.vmx.HCPhysVmreadBitmap  = NIL_RTHCPHYS;
+    pVM->hmr0.s.vmx.HCPhysVmwriteBitmap = NIL_RTHCPHYS;
     for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
     {
@@ -3544,13 +3544,13 @@
             if (   fGstVmwriteAll
                 || !VMXIsVmcsFieldReadOnly(VmcsField.u))
-                pVM->hm.s.vmx.paShadowVmcsFields[cRwFields++] = VmcsField.u;
+                pVM->hmr0.s.vmx.paShadowVmcsFields[cRwFields++] = VmcsField.u;
             else
-                pVM->hm.s.vmx.paShadowVmcsRoFields[cRoFields++] = VmcsField.u;
+                pVM->hmr0.s.vmx.paShadowVmcsRoFields[cRoFields++] = VmcsField.u;
         }
     }
 
     /* Update the counts. */
-    pVM->hm.s.vmx.cShadowVmcsFields   = cRwFields;
-    pVM->hm.s.vmx.cShadowVmcsRoFields = cRoFields;
+    pVM->hmr0.s.vmx.cShadowVmcsFields   = cRwFields;
+    pVM->hmr0.s.vmx.cShadowVmcsRoFields = cRoFields;
     return VINF_SUCCESS;
 }
@@ -3568,6 +3568,6 @@
      */
     uint32_t const cbBitmap        = X86_PAGE_4K_SIZE;
-    uint8_t       *pbVmreadBitmap  = (uint8_t *)pVM->hm.s.vmx.pvVmreadBitmap;
-    uint8_t       *pbVmwriteBitmap = (uint8_t *)pVM->hm.s.vmx.pvVmwriteBitmap;
+    uint8_t       *pbVmreadBitmap  = (uint8_t *)pVM->hmr0.s.vmx.pvVmreadBitmap;
+    uint8_t       *pbVmwriteBitmap = (uint8_t *)pVM->hmr0.s.vmx.pvVmwriteBitmap;
     ASMMemFill32(pbVmreadBitmap,  cbBitmap, UINT32_C(0xffffffff));
     ASMMemFill32(pbVmwriteBitmap, cbBitmap, UINT32_C(0xffffffff));
@@ -3578,6 +3578,6 @@
      */
     {
-        uint32_t const *paShadowVmcsFields = pVM->hm.s.vmx.paShadowVmcsFields;
-        uint32_t const  cShadowVmcsFields  = pVM->hm.s.vmx.cShadowVmcsFields;
+        uint32_t const *paShadowVmcsFields = pVM->hmr0.s.vmx.paShadowVmcsFields;
+        uint32_t const  cShadowVmcsFields  = pVM->hmr0.s.vmx.cShadowVmcsFields;
         for (uint32_t i = 0; i < cShadowVmcsFields; i++)
         {
@@ -3596,6 +3596,6 @@
     if (pVM->hm.s.vmx.Msrs.u64Misc & VMX_MISC_VMWRITE_ALL)
     {
-        uint32_t const *paShadowVmcsRoFields = pVM->hm.s.vmx.paShadowVmcsRoFields;
-        uint32_t const  cShadowVmcsRoFields  = pVM->hm.s.vmx.cShadowVmcsRoFields;
+        uint32_t const *paShadowVmcsRoFields = pVM->hmr0.s.vmx.paShadowVmcsRoFields;
+        uint32_t const  cShadowVmcsRoFields  = pVM->hmr0.s.vmx.cShadowVmcsRoFields;
         for (uint32_t i = 0; i < cShadowVmcsRoFields; i++)
         {
@@ -3647,5 +3647,5 @@
 DECLINLINE(void) hmR0VmxSetupVmcsApicAccessAddr(PVMCPUCC pVCpu)
 {
-    RTHCPHYS const HCPhysApicAccess = pVCpu->CTX_SUFF(pVM)->hm.s.vmx.HCPhysApicAccess;
+    RTHCPHYS const HCPhysApicAccess = pVCpu->CTX_SUFF(pVM)->hmr0.s.vmx.HCPhysApicAccess;
     Assert(HCPhysApicAccess != NIL_RTHCPHYS);
     Assert(!(HCPhysApicAccess & 0xfff));                     /* Bits 11:0 MBZ. */
@@ -3663,5 +3663,5 @@
 DECLINLINE(void) hmR0VmxSetupVmcsVmreadBitmapAddr(PVMCPUCC pVCpu)
 {
-    RTHCPHYS const HCPhysVmreadBitmap = pVCpu->CTX_SUFF(pVM)->hm.s.vmx.HCPhysVmreadBitmap;
+    RTHCPHYS const HCPhysVmreadBitmap = pVCpu->CTX_SUFF(pVM)->hmr0.s.vmx.HCPhysVmreadBitmap;
     Assert(HCPhysVmreadBitmap != NIL_RTHCPHYS);
     Assert(!(HCPhysVmreadBitmap & 0xfff));                     /* Bits 11:0 MBZ. */
@@ -3678,5 +3678,5 @@
 DECLINLINE(void) hmR0VmxSetupVmcsVmwriteBitmapAddr(PVMCPUCC pVCpu)
 {
-    RTHCPHYS const HCPhysVmwriteBitmap = pVCpu->CTX_SUFF(pVM)->hm.s.vmx.HCPhysVmwriteBitmap;
+    RTHCPHYS const HCPhysVmwriteBitmap = pVCpu->CTX_SUFF(pVM)->hmr0.s.vmx.HCPhysVmwriteBitmap;
     Assert(HCPhysVmwriteBitmap != NIL_RTHCPHYS);
     Assert(!(HCPhysVmwriteBitmap & 0xfff));                     /* Bits 11:0 MBZ. */
@@ -4453,6 +4453,6 @@
     /* Setup the crash dump page. */
 #ifdef VBOX_WITH_CRASHDUMP_MAGIC
-    strcpy((char *)pVM->hm.s.vmx.pbScratch, "SCRATCH Magic");
-    *(uint64_t *)(pVM->hm.s.vmx.pbScratch + 16) = UINT64_C(0xdeadbeefdeadbeef);
+    strcpy((char *)pVM->hmr0.s.vmx.pbScratch, "SCRATCH Magic");
+    *(uint64_t *)(pVM->hmr0.s.vmx.pbScratch + 16) = UINT64_C(0xdeadbeefdeadbeef);
 #endif
     return VINF_SUCCESS;
@@ -4472,9 +4472,6 @@
 
 #ifdef VBOX_WITH_CRASHDUMP_MAGIC
-    if (pVM->hm.s.vmx.hMemObjScratch != NIL_RTR0MEMOBJ)
-    {
-        Assert(pVM->hm.s.vmx.pvScratch);
-        ASMMemZero32(pVM->hm.s.vmx.pvScratch, X86_PAGE_4K_SIZE);
-    }
+    if (pVM->hmr0.s.vmx.pbScratch)
+        RT_BZERO(pVM->hmr0.s.vmx.pbScratch, X86_PAGE_4K_SIZE);
 #endif
     hmR0VmxStructsFree(pVM);
@@ -5436,9 +5433,9 @@
          * like hardware errors.
          */
-        uint32_t const cShadowVmcsFields = pVM->hm.s.vmx.cShadowVmcsFields;
+        uint32_t const cShadowVmcsFields = pVM->hmr0.s.vmx.cShadowVmcsFields;
         for (uint32_t i = 0; i < cShadowVmcsFields; i++)
         {
             uint64_t       u64Val;
-            uint32_t const uVmcsField = pVM->hm.s.vmx.paShadowVmcsFields[i];
+            uint32_t const uVmcsField = pVM->hmr0.s.vmx.paShadowVmcsFields[i];
             IEMReadVmxVmcsField(pVmcsNstGst, uVmcsField, &u64Val);
             VMXWriteVmcs64(uVmcsField, u64Val);
@@ -5451,9 +5448,9 @@
         if (pVM->hm.s.vmx.Msrs.u64Misc & VMX_MISC_VMWRITE_ALL)
         {
-            uint32_t const cShadowVmcsRoFields = pVM->hm.s.vmx.cShadowVmcsRoFields;
+            uint32_t const cShadowVmcsRoFields = pVM->hmr0.s.vmx.cShadowVmcsRoFields;
             for (uint32_t i = 0; i < cShadowVmcsRoFields; i++)
             {
                 uint64_t       u64Val;
-                uint32_t const uVmcsField = pVM->hm.s.vmx.paShadowVmcsRoFields[i];
+                uint32_t const uVmcsField = pVM->hmr0.s.vmx.paShadowVmcsRoFields[i];
                 IEMReadVmxVmcsField(pVmcsNstGst, uVmcsField, &u64Val);
                 VMXWriteVmcs64(uVmcsField, u64Val);
@@ -5496,9 +5493,9 @@
          * like hardware errors.
          */
-        uint32_t const cShadowVmcsFields = pVM->hm.s.vmx.cShadowVmcsFields;
+        uint32_t const cShadowVmcsFields = pVM->hmr0.s.vmx.cShadowVmcsFields;
         for (uint32_t i = 0; i < cShadowVmcsFields; i++)
         {
             uint64_t       u64Val;
-            uint32_t const uVmcsField = pVM->hm.s.vmx.paShadowVmcsFields[i];
+            uint32_t const uVmcsField = pVM->hmr0.s.vmx.paShadowVmcsFields[i];
             VMXReadVmcs64(uVmcsField, &u64Val);
             IEMWriteVmxVmcsField(pVmcsNstGst, uVmcsField, u64Val);
@@ -10243,6 +10240,6 @@
 
     /* Map the HC APIC-access page in place of the MMIO page, also updates the shadow page tables if necessary. */
-    Assert(pVM->hm.s.vmx.HCPhysApicAccess != NIL_RTHCPHYS);
-    rc = IOMR0MmioMapMmioHCPage(pVM, pVCpu, GCPhysApicBase, pVM->hm.s.vmx.HCPhysApicAccess, X86_PTE_RW | X86_PTE_P);
+    Assert(pVM->hmr0.s.vmx.HCPhysApicAccess != NIL_RTHCPHYS);
+    rc = IOMR0MmioMapMmioHCPage(pVM, pVCpu, GCPhysApicBase, pVM->hmr0.s.vmx.HCPhysApicAccess, X86_PTE_RW | X86_PTE_P);
     AssertRCReturn(rc, rc);
 
