Index: /trunk/include/VBox/vmm/gvm.h
===================================================================
--- /trunk/include/VBox/vmm/gvm.h	(revision 93654)
+++ /trunk/include/VBox/vmm/gvm.h	(revision 93655)
@@ -287,5 +287,5 @@
         TMR0PERVM           s;
 #endif
-        uint8_t             padding[128];
+        uint8_t             padding[192];
     } tmr0;
 
@@ -300,7 +300,7 @@
     /** Padding so aCpus starts on a page boundrary.  */
 #ifdef VBOX_WITH_NEM_R0
-    uint8_t         abPadding2[16384 - 64 - 4352 - 1024 - 256 - 256 - 64 - 3008 - 1920 - 512 - 64 - 1024 - 128 - 704 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
+    uint8_t         abPadding2[16384 - 64 - 4352 - 1024 - 256 - 256 - 64 - 3008 - 1920 - 512 - 64 - 1024 - 192 - 704 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
 #else
-    uint8_t         abPadding2[16384 - 64 - 4352 - 1024 - 256 -       64 - 3008 - 1920 - 512 - 64 - 1024 - 128 - 704 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
+    uint8_t         abPadding2[16384 - 64 - 4352 - 1024 - 256 -       64 - 3008 - 1920 - 512 - 64 - 1024 - 192 - 704 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
 #endif
 
@@ -340,2 +340,3 @@
 #endif /* !VBOX_INCLUDED_vmm_gvm_h */
 
+
Index: /trunk/include/VBox/vmm/vmcc.h
===================================================================
--- /trunk/include/VBox/vmm/vmcc.h	(revision 93654)
+++ /trunk/include/VBox/vmm/vmcc.h	(revision 93655)
@@ -122,4 +122,17 @@
 
 
+/**
+ * Used to pick ring-0 or ring-3 VM component data.
+ *
+ * @code{.cpp}
+ *    pVM->VMCC_CTX(pdm).s.pfnWorker
+ * @endcode
+ */
+#ifdef IN_RING0
+# define VMCC_CTX(a_Name)   a_Name ## r0
+#else
+# define VMCC_CTX(a_Name)   a_Name
+#endif
+
 #endif /* !VBOX_INCLUDED_vmm_vmcc_h */
 
Index: /trunk/src/VBox/VMM/VMMAll/APICAll.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/APICAll.cpp	(revision 93654)
+++ /trunk/src/VBox/VMM/VMMAll/APICAll.cpp	(revision 93655)
@@ -612,4 +612,9 @@
                                  uint32_t uSrcTag, int rcRZ)
 {
+    AssertCompile(sizeof(pVM->apic.s) <= sizeof(pVM->apic.padding));
+    AssertCompile(sizeof(pVCpu->apic.s) <= sizeof(pVCpu->apic.padding));
+#ifdef IN_RING0
+    AssertCompile(sizeof(pVM->apicr0.s) <= sizeof(pVM->apicr0.padding));
+#endif
     VBOXSTRICTRC  rcStrict  = VINF_SUCCESS;
     VMCPUID const cCpus     = pVM->cCpus;
Index: /trunk/src/VBox/VMM/VMMAll/TMAllVirtual.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/TMAllVirtual.cpp	(revision 93654)
+++ /trunk/src/VBox/VMM/VMMAll/TMAllVirtual.cpp	(revision 93655)
@@ -46,5 +46,5 @@
                                                   uint64_t u64PrevNanoTS)
 {
-    PVM pVM = RT_FROM_MEMBER(pData, VM, CTX_SUFF(tm.s.VirtualGetRawData));
+    PVMCC pVM = RT_FROM_MEMBER(pData, VMCC, VMCC_CTX(tm).s.VirtualGetRawData);
     pData->cBadPrev++;
     if ((int64_t)u64DeltaPrev < 0)
@@ -81,5 +81,5 @@
 DECLCALLBACK(DECLEXPORT(uint64_t)) tmVirtualNanoTSRediscover(PRTTIMENANOTSDATA pData, PRTITMENANOTSEXTRA pExtra)
 {
-    PVM                   pVM = RT_FROM_MEMBER(pData, VM, CTX_SUFF(tm.s.VirtualGetRawData));
+    PVMCC                 pVM = RT_FROM_MEMBER(pData, VMCC, VMCC_CTX(tm).s.VirtualGetRawData);
     PFNTIMENANOTSINTERNAL pfnWorker;
 
@@ -166,5 +166,5 @@
      * Update the pfnVirtualGetRaw pointer and call the worker we selected.
      */
-    ASMAtomicWritePtr((void * volatile *)&CTX_SUFF(pVM->tm.s.pfnVirtualGetRaw), (void *)(uintptr_t)pfnWorker);
+    ASMAtomicWritePtr((void * volatile *)&pVM->VMCC_CTX(tm).s.pfnVirtualGetRaw, (void *)(uintptr_t)pfnWorker);
     return pfnWorker(pData, pExtra);
 }
@@ -177,5 +177,5 @@
                                                               uint16_t idApic, uint16_t iCpuSet, uint16_t iGipCpu)
 {
-    PVM pVM = RT_FROM_MEMBER(pData, VM, CTX_SUFF(tm.s.VirtualGetRawData));
+    PVMCC pVM = RT_FROM_MEMBER(pData, VMCC, VMCC_CTX(tm).s.VirtualGetRawData);
     AssertFatalMsgFailed(("pVM=%p idApic=%#x iCpuSet=%#x iGipCpu=%#x pExtra=%p\n", pVM, idApic, iCpuSet, iGipCpu, pExtra));
 #ifndef _MSC_VER
@@ -190,12 +190,14 @@
 DECLINLINE(uint64_t) tmVirtualGetRawNanoTS(PVMCC pVM)
 {
-# ifdef IN_RING3
-    uint64_t u64 = CTXALLSUFF(pVM->tm.s.pfnVirtualGetRaw)(&CTXALLSUFF(pVM->tm.s.VirtualGetRawData), NULL /*pExtra*/);
-# else  /* !IN_RING3 */
-    uint32_t cPrevSteps = pVM->tm.s.CTX_SUFF(VirtualGetRawData).c1nsSteps;
-    uint64_t u64 = pVM->tm.s.CTX_SUFF(pfnVirtualGetRaw)(&pVM->tm.s.CTX_SUFF(VirtualGetRawData), NULL /*pExtra*/);
-    if (cPrevSteps != pVM->tm.s.CTX_SUFF(VirtualGetRawData).c1nsSteps)
+#ifdef IN_RING3
+    uint64_t u64 = pVM->tm.s.pfnVirtualGetRaw(&pVM->tm.s.VirtualGetRawData, NULL /*pExtra*/);
+#elif defined(IN_RING0)
+    uint32_t cPrevSteps = pVM->tmr0.s.VirtualGetRawData.c1nsSteps;
+    uint64_t u64 = pVM->tmr0.s.pfnVirtualGetRaw(&pVM->tmr0.s.VirtualGetRawData, NULL /*pExtra*/);
+    if (cPrevSteps != pVM->tmr0.s.VirtualGetRawData.c1nsSteps)
         VMCPU_FF_SET(VMMGetCpu(pVM), VMCPU_FF_TO_R3);
-# endif /* !IN_RING3 */
+#else
+# error "unsupported context"
+#endif
     /*DBGFTRACE_POS_U64(pVM, u64);*/
     return u64;
@@ -209,12 +211,14 @@
 {
     RTITMENANOTSEXTRA Extra;
-# ifdef IN_RING3
-    uint64_t u64 = CTXALLSUFF(pVM->tm.s.pfnVirtualGetRaw)(&CTXALLSUFF(pVM->tm.s.VirtualGetRawData), &Extra);
-# else  /* !IN_RING3 */
-    uint32_t cPrevSteps = pVM->tm.s.CTX_SUFF(VirtualGetRawData).c1nsSteps;
-    uint64_t u64 = pVM->tm.s.CTX_SUFF(pfnVirtualGetRaw)(&pVM->tm.s.CTX_SUFF(VirtualGetRawData), &Extra);
-    if (cPrevSteps != pVM->tm.s.CTX_SUFF(VirtualGetRawData).c1nsSteps)
+#ifdef IN_RING3
+    uint64_t u64 = pVM->tm.s.pfnVirtualGetRaw(&pVM->tm.s.VirtualGetRawData, &Extra);
+#elif defined(IN_RING0)
+    uint32_t cPrevSteps = pVM->tmr0.s.VirtualGetRawData.c1nsSteps;
+    uint64_t u64 = pVM->tmr0.s.pfnVirtualGetRaw(&pVM->tmr0.s.VirtualGetRawData, &Extra);
+    if (cPrevSteps != pVM->tmr0.s.VirtualGetRawData.c1nsSteps)
         VMCPU_FF_SET(VMMGetCpu(pVM), VMCPU_FF_TO_R3);
-# endif /* !IN_RING3 */
+#else
+# error "unsupported context"
+#endif
     if (puTscNow)
         *puTscNow = Extra.uTSCValue;
Index: /trunk/src/VBox/VMM/VMMR0/DBGFR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/DBGFR0.cpp	(revision 93654)
+++ /trunk/src/VBox/VMM/VMMR0/DBGFR0.cpp	(revision 93655)
@@ -51,4 +51,5 @@
 VMMR0_INT_DECL(void) DBGFR0InitPerVMData(PGVM pGVM)
 {
+    AssertCompile(sizeof(pGVM->dbgfr0.s) <= sizeof(pGVM->dbgfr0.padding));
     pGVM->dbgfr0.s.pTracerR0 = NULL;
 
Index: /trunk/src/VBox/VMM/VMMR0/HMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HMR0.cpp	(revision 93654)
+++ /trunk/src/VBox/VMM/VMMR0/HMR0.cpp	(revision 93655)
@@ -1160,4 +1160,8 @@
 VMMR0_INT_DECL(int) HMR0InitVM(PVMCC pVM)
 {
+    AssertCompile(sizeof(pVM->hm.s) <= sizeof(pVM->hm.padding));
+    AssertCompile(sizeof(pVM->hmr0.s) <= sizeof(pVM->hmr0.padding));
+    AssertCompile(sizeof(pVM->aCpus[0].hm.s) <= sizeof(pVM->aCpus[0].hm.padding));
+    AssertCompile(sizeof(pVM->aCpus[0].hmr0.s) <= sizeof(pVM->aCpus[0].hmr0.padding));
     AssertReturn(pVM, VERR_INVALID_PARAMETER);
 
Index: /trunk/src/VBox/VMM/VMMR0/IEMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/IEMR0.cpp	(revision 93654)
+++ /trunk/src/VBox/VMM/VMMR0/IEMR0.cpp	(revision 93655)
@@ -34,4 +34,7 @@
 VMMR0_INT_DECL(int) IEMR0InitVM(PGVM pGVM)
 {
+    AssertCompile(sizeof(pGVM->iem.s) <= sizeof(pGVM->iem.padding));
+    AssertCompile(sizeof(pGVM->aCpus[0].iem.s) <= sizeof(pGVM->aCpus[0].iem.padding));
+
 #ifdef VBOX_WITH_NESTED_HWVIRT_VMX
     /*
Index: /trunk/src/VBox/VMM/VMMR0/TMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/TMR0.cpp	(revision 93654)
+++ /trunk/src/VBox/VMM/VMMR0/TMR0.cpp	(revision 93655)
@@ -46,4 +46,6 @@
 VMMR0_INT_DECL(void)    TMR0InitPerVMData(PGVM pGVM)
 {
+    AssertCompile(sizeof(pGVM->tmr0.padding) >= sizeof(pGVM->tmr0.s));
+
     for (uint32_t idxQueue = 0; idxQueue < RT_ELEMENTS(pGVM->tmr0.s.aTimerQueues); idxQueue++)
     {
@@ -52,9 +54,9 @@
     }
 
-    pGVM->tm.s.VirtualGetRawDataR0.pu64Prev       = &pGVM->tm.s.u64VirtualRawPrev;
-    pGVM->tm.s.VirtualGetRawDataR0.pfnBad         = tmVirtualNanoTSBad;
-    pGVM->tm.s.VirtualGetRawDataR0.pfnBadCpuIndex = tmVirtualNanoTSBadCpuIndex;
-    pGVM->tm.s.VirtualGetRawDataR0.pfnRediscover  = tmVirtualNanoTSRediscover;
-    pGVM->tm.s.pfnVirtualGetRawR0                 = tmVirtualNanoTSRediscover;
+    pGVM->tmr0.s.VirtualGetRawData.pu64Prev       = &pGVM->tm.s.u64VirtualRawPrev;
+    pGVM->tmr0.s.VirtualGetRawData.pfnBad         = tmVirtualNanoTSBad;
+    pGVM->tmr0.s.VirtualGetRawData.pfnBadCpuIndex = tmVirtualNanoTSBadCpuIndex;
+    pGVM->tmr0.s.VirtualGetRawData.pfnRediscover  = tmVirtualNanoTSRediscover;
+    pGVM->tmr0.s.pfnVirtualGetRaw                 = tmVirtualNanoTSRediscover;
 }
 
Index: /trunk/src/VBox/VMM/VMMR3/TM.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/TM.cpp	(revision 93654)
+++ /trunk/src/VBox/VMM/VMMR3/TM.cpp	(revision 93655)
@@ -287,9 +287,9 @@
      * Setup the VirtualGetRaw backend.
      */
-    pVM->tm.s.pfnVirtualGetRawR3                 = tmVirtualNanoTSRediscover;
-    pVM->tm.s.VirtualGetRawDataR3.pfnRediscover  = tmVirtualNanoTSRediscover;
-    pVM->tm.s.VirtualGetRawDataR3.pfnBad         = tmVirtualNanoTSBad;
-    pVM->tm.s.VirtualGetRawDataR3.pfnBadCpuIndex = tmVirtualNanoTSBadCpuIndex;
-    pVM->tm.s.VirtualGetRawDataR3.pu64Prev       = &pVM->tm.s.u64VirtualRawPrev;
+    pVM->tm.s.pfnVirtualGetRaw                 = tmVirtualNanoTSRediscover;
+    pVM->tm.s.VirtualGetRawData.pfnRediscover  = tmVirtualNanoTSRediscover;
+    pVM->tm.s.VirtualGetRawData.pfnBad         = tmVirtualNanoTSBad;
+    pVM->tm.s.VirtualGetRawData.pfnBadCpuIndex = tmVirtualNanoTSBadCpuIndex;
+    pVM->tm.s.VirtualGetRawData.pu64Prev       = &pVM->tm.s.u64VirtualRawPrev;
 
     /*
@@ -671,8 +671,10 @@
      * Register statistics.
      */
-    STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawDataR3.c1nsSteps,STAMTYPE_U32, "/TM/R3/1nsSteps",                     STAMUNIT_OCCURENCES, "Virtual time 1ns steps (due to TSC / GIP variations).");
-    STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawDataR3.cBadPrev, STAMTYPE_U32, "/TM/R3/cBadPrev",                     STAMUNIT_OCCURENCES, "Times the previous virtual time was considered erratic (shouldn't ever happen).");
+    STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawData.c1nsSteps,STAMTYPE_U32, "/TM/R3/1nsSteps",                     STAMUNIT_OCCURENCES, "Virtual time 1ns steps (due to TSC / GIP variations).");
+    STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawData.cBadPrev, STAMTYPE_U32, "/TM/R3/cBadPrev",                     STAMUNIT_OCCURENCES, "Times the previous virtual time was considered erratic (shouldn't ever happen).");
+#if 0 /** @todo retreive from ring-0 */
     STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawDataR0.c1nsSteps,STAMTYPE_U32, "/TM/R0/1nsSteps",                     STAMUNIT_OCCURENCES, "Virtual time 1ns steps (due to TSC / GIP variations).");
     STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.VirtualGetRawDataR0.cBadPrev, STAMTYPE_U32, "/TM/R0/cBadPrev",                     STAMUNIT_OCCURENCES, "Times the previous virtual time was considered erratic (shouldn't ever happen).");
+#endif
     STAM_REL_REG(     pVM,(void*)&pVM->tm.s.offVirtualSync,               STAMTYPE_U64, "/TM/VirtualSync/CurrentOffset",               STAMUNIT_NS, "The current offset. (subtract GivenUp to get the lag)");
     STAM_REL_REG_USED(pVM,(void*)&pVM->tm.s.offVirtualSyncGivenUp,        STAMTYPE_U64, "/TM/VirtualSync/GivenUp",                     STAMUNIT_NS, "Nanoseconds of the 'CurrentOffset' that's been given up and won't ever be attempted caught up with.");
@@ -686,8 +688,10 @@
 
 #ifdef VBOX_WITH_STATISTICS
-    STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawDataR3.cExpired,    STAMTYPE_U32, "/TM/R3/cExpired",                     STAMUNIT_OCCURENCES, "Times the TSC interval expired (overlaps 1ns steps).");
-    STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawDataR3.cUpdateRaces,STAMTYPE_U32, "/TM/R3/cUpdateRaces",                 STAMUNIT_OCCURENCES, "Thread races when updating the previous timestamp.");
+    STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawData.cExpired,    STAMTYPE_U32, "/TM/R3/cExpired",                     STAMUNIT_OCCURENCES, "Times the TSC interval expired (overlaps 1ns steps).");
+    STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawData.cUpdateRaces,STAMTYPE_U32, "/TM/R3/cUpdateRaces",                 STAMUNIT_OCCURENCES, "Thread races when updating the previous timestamp.");
+# if 0 /** @todo retreive from ring-0 */
     STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawDataR0.cExpired,    STAMTYPE_U32, "/TM/R0/cExpired",                     STAMUNIT_OCCURENCES, "Times the TSC interval expired (overlaps 1ns steps).");
     STAM_REG_USED(pVM,(void *)&pVM->tm.s.VirtualGetRawDataR0.cUpdateRaces,STAMTYPE_U32, "/TM/R0/cUpdateRaces",                 STAMUNIT_OCCURENCES, "Thread races when updating the previous timestamp.");
+# endif
     STAM_REG(pVM, &pVM->tm.s.StatDoQueues,                            STAMTYPE_PROFILE, "/TM/DoQueues",                    STAMUNIT_TICKS_PER_CALL, "Profiling timer TMR3TimerQueuesDo.");
     STAM_REG(pVM, &pVM->tm.s.aTimerQueues[TMCLOCK_VIRTUAL].StatDo,    STAMTYPE_PROFILE, "/TM/DoQueues/Virtual",            STAMUNIT_TICKS_PER_CALL, "Time spent on the virtual clock queue.");
Index: /trunk/src/VBox/VMM/include/TMInternal.h
===================================================================
--- /trunk/src/VBox/VMM/include/TMInternal.h	(revision 93654)
+++ /trunk/src/VBox/VMM/include/TMInternal.h	(revision 93655)
@@ -489,11 +489,7 @@
     uint64_t volatile           u64VirtualRawPrev;
     /** The ring-3 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */
-    RTTIMENANOTSDATAR3          VirtualGetRawDataR3;
-    /** The ring-0 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */
-    RTTIMENANOTSDATAR0          VirtualGetRawDataR0;
+    RTTIMENANOTSDATAR3          VirtualGetRawData;
     /** Pointer to the ring-3 tmVirtualGetRawNanoTS worker function. */
-    R3PTRTYPE(PFNTIMENANOTSINTERNAL) pfnVirtualGetRawR3;
-    /** Pointer to the ring-0 tmVirtualGetRawNanoTS worker function. */
-    R0PTRTYPE(PFNTIMENANOTSINTERNAL) pfnVirtualGetRawR0;
+    R3PTRTYPE(PFNTIMENANOTSINTERNAL) pfnVirtualGetRaw;
     /** The guest virtual timer synchronous time when fVirtualSyncTicking is cleared.
      * When fVirtualSyncTicking is set it holds the last time returned to
@@ -846,4 +842,9 @@
     /** Timer queues for the different clock types. */
     TMTIMERQUEUER0              aTimerQueues[TMCLOCK_MAX];
+
+    /** The ring-0 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */
+    RTTIMENANOTSDATAR0          VirtualGetRawData;
+    /** Pointer to the ring-0 tmVirtualGetRawNanoTS worker function. */
+    R0PTRTYPE(PFNTIMENANOTSINTERNAL) pfnVirtualGetRaw;
 } TMR0PERVM;
 
