Index: /trunk/include/VBox/tm.h
===================================================================
--- /trunk/include/VBox/tm.h	(revision 5508)
+++ /trunk/include/VBox/tm.h	(revision 5509)
@@ -599,4 +599,12 @@
 
 /**
+ * Finalizes the TM initialization.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
+TMR3DECL(int) TMR3InitFinalize(PVM pVM);
+
+/**
  * Applies relocations to data and code managed by this
  * component. This function will be called at init and
Index: /trunk/src/VBox/VMM/TM.cpp
===================================================================
--- /trunk/src/VBox/VMM/TM.cpp	(revision 5508)
+++ /trunk/src/VBox/VMM/TM.cpp	(revision 5509)
@@ -231,50 +231,24 @@
     pVM->tm.s.VirtualGetRawDataR3.pfnBad = tmVirtualNanoTSBad;
     pVM->tm.s.VirtualGetRawDataR3.pfnRediscover = tmVirtualNanoTSRediscover;
+    if (ASMCpuId_EDX(1) & X86_CPUID_FEATURE_EDX_SSE2)
+    {
+        if (g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_SYNC_TSC)
+            pVM->tm.s.pfnVirtualGetRawR3 = RTTimeNanoTSLFenceSync;
+        else
+            pVM->tm.s.pfnVirtualGetRawR3 = RTTimeNanoTSLFenceAsync;
+    }
+    else
+    {
+        if (g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_SYNC_TSC)
+            pVM->tm.s.pfnVirtualGetRawR3 = RTTimeNanoTSLegacySync;
+        else
+            pVM->tm.s.pfnVirtualGetRawR3 = RTTimeNanoTSLegacyAsync;
+    }
 
     pVM->tm.s.VirtualGetRawDataGC.pu64Prev = MMHyperR3ToGC(pVM, (void *)&pVM->tm.s.u64VirtualRawPrev);
-#if 0 /* too early */
-    rc = PDMR3GetSymbolGCLazy(pVM, NULL, "tmVirtualNanoTSBad",          &pVM->tm.s.VirtualGetRawDataGC.pfnBad);
-    AssertRCReturn(rc, rc);
-    rc = PDMR3GetSymbolGCLazy(pVM, NULL, "tmVirtualNanoTSRediscover",   &pVM->tm.s.VirtualGetRawDataGC.pfnRediscover);
-    AssertRCReturn(rc, rc);
-#endif
-
     pVM->tm.s.VirtualGetRawDataR0.pu64Prev = MMHyperR3ToR0(pVM, (void *)&pVM->tm.s.u64VirtualRawPrev);
     AssertReturn(pVM->tm.s.VirtualGetRawDataR0.pu64Prev, VERR_INTERNAL_ERROR);
-    rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "tmVirtualNanoTSBad",          &pVM->tm.s.VirtualGetRawDataR0.pfnBad);
-    AssertRCReturn(rc, rc);
-    rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "tmVirtualNanoTSRediscover",   &pVM->tm.s.VirtualGetRawDataR0.pfnRediscover);
-    AssertRCReturn(rc, rc);
-
-    if (ASMCpuId_EDX(1) & X86_CPUID_FEATURE_EDX_SSE2)
-    {
-        if (g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_SYNC_TSC)
-        {
-            pVM->tm.s.pfnVirtualGetRawR3 = RTTimeNanoTSLFenceSync;
-            rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "RTTimeNanoTSLFenceSync", &pVM->tm.s.pfnVirtualGetRawR0);
-            AssertRCReturn(rc, rc);
-        }
-        else
-        {
-            pVM->tm.s.pfnVirtualGetRawR3 = RTTimeNanoTSLFenceAsync;
-            rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "RTTimeNanoTSLFenceAsync", &pVM->tm.s.pfnVirtualGetRawR0);
-            AssertRCReturn(rc, rc);
-        }
-    }
-    else
-    {
-        if (g_pSUPGlobalInfoPage->u32Mode == SUPGIPMODE_SYNC_TSC)
-        {
-            pVM->tm.s.pfnVirtualGetRawR3 = RTTimeNanoTSLegacySync;
-            rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "RTTimeNanoTSLegacySync", &pVM->tm.s.pfnVirtualGetRawR0);
-            AssertRCReturn(rc, rc);
-        }
-        else
-        {
-            pVM->tm.s.pfnVirtualGetRawR3 = RTTimeNanoTSLegacyAsync;
-            rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "RTTimeNanoTSLegacyAsync", &pVM->tm.s.pfnVirtualGetRawR0);
-            AssertRCReturn(rc, rc);
-        }
-    }
+    /* The rest is done in TMR3InitFinalize since it's too early to call PDM. */
+
 
     /*
@@ -717,27 +691,17 @@
 
 /**
- * Applies relocations to data and code managed by this
- * component. This function will be called at init and
- * whenever the VMM need to relocate it self inside the GC.
- *
- * @param   pVM     The VM.
- * @param   offDelta    Relocation delta relative to old location.
- */
-TMR3DECL(void) TMR3Relocate(PVM pVM, RTGCINTPTR offDelta)
+ * Finalizes the TM initialization.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM to operate on.
+ */
+TMR3DECL(int) TMR3InitFinalize(PVM pVM)
 {
     int rc;
-    LogFlow(("TMR3Relocate\n"));
-
-    pVM->tm.s.pvGIPGC = MMHyperR3ToGC(pVM, pVM->tm.s.pvGIPR3);
-    pVM->tm.s.paTimerQueuesGC = MMHyperR3ToGC(pVM, pVM->tm.s.paTimerQueuesR3);
-    pVM->tm.s.paTimerQueuesR0 = MMHyperR3ToR0(pVM, pVM->tm.s.paTimerQueuesR3);
-
-    pVM->tm.s.VirtualGetRawDataGC.pu64Prev = MMHyperR3ToGC(pVM, (void *)&pVM->tm.s.u64VirtualRawPrev);
-    AssertFatal(pVM->tm.s.VirtualGetRawDataGC.pu64Prev);
+
     rc = PDMR3GetSymbolGCLazy(pVM, NULL, "tmVirtualNanoTSBad",          &pVM->tm.s.VirtualGetRawDataGC.pfnBad);
-    AssertFatalRC(rc);
+    AssertRCReturn(rc, rc);
     rc = PDMR3GetSymbolGCLazy(pVM, NULL, "tmVirtualNanoTSRediscover",   &pVM->tm.s.VirtualGetRawDataGC.pfnRediscover);
-    AssertFatalRC(rc);
-
+    AssertRCReturn(rc, rc);
     if (pVM->tm.s.pfnVirtualGetRawR3       == RTTimeNanoTSLFenceSync)
         rc = PDMR3GetSymbolGCLazy(pVM, NULL, "RTTimeNanoTSLFenceSync",  &pVM->tm.s.pfnVirtualGetRawGC);
@@ -750,4 +714,61 @@
     else
         AssertFatalFailed();
+    AssertRCReturn(rc, rc);
+
+    rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "tmVirtualNanoTSBad",          &pVM->tm.s.VirtualGetRawDataR0.pfnBad);
+    AssertRCReturn(rc, rc);
+    rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "tmVirtualNanoTSRediscover",   &pVM->tm.s.VirtualGetRawDataR0.pfnRediscover);
+    AssertRCReturn(rc, rc);
+    if (pVM->tm.s.pfnVirtualGetRawR3       == RTTimeNanoTSLFenceSync)
+        rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "RTTimeNanoTSLFenceSync",  &pVM->tm.s.pfnVirtualGetRawR0);
+    else if (pVM->tm.s.pfnVirtualGetRawR3  == RTTimeNanoTSLFenceAsync)
+        rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "RTTimeNanoTSLFenceAsync", &pVM->tm.s.pfnVirtualGetRawR0);
+    else if (pVM->tm.s.pfnVirtualGetRawR3  == RTTimeNanoTSLegacySync)
+        rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "RTTimeNanoTSLegacySync",  &pVM->tm.s.pfnVirtualGetRawR0);
+    else if (pVM->tm.s.pfnVirtualGetRawR3  == RTTimeNanoTSLegacyAsync)
+        rc = PDMR3GetSymbolR0Lazy(pVM, NULL, "RTTimeNanoTSLegacyAsync", &pVM->tm.s.pfnVirtualGetRawR0);
+    else
+        AssertFatalFailed();
+    AssertRCReturn(rc, rc);
+
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * Applies relocations to data and code managed by this
+ * component. This function will be called at init and
+ * whenever the VMM need to relocate it self inside the GC.
+ *
+ * @param   pVM     The VM.
+ * @param   offDelta    Relocation delta relative to old location.
+ */
+TMR3DECL(void) TMR3Relocate(PVM pVM, RTGCINTPTR offDelta)
+{
+    int rc;
+    LogFlow(("TMR3Relocate\n"));
+
+    pVM->tm.s.pvGIPGC = MMHyperR3ToGC(pVM, pVM->tm.s.pvGIPR3);
+    pVM->tm.s.paTimerQueuesGC = MMHyperR3ToGC(pVM, pVM->tm.s.paTimerQueuesR3);
+    pVM->tm.s.paTimerQueuesR0 = MMHyperR3ToR0(pVM, pVM->tm.s.paTimerQueuesR3);
+
+    pVM->tm.s.VirtualGetRawDataGC.pu64Prev = MMHyperR3ToGC(pVM, (void *)&pVM->tm.s.u64VirtualRawPrev);
+    AssertFatal(pVM->tm.s.VirtualGetRawDataGC.pu64Prev);
+    rc = PDMR3GetSymbolGCLazy(pVM, NULL, "tmVirtualNanoTSBad",          &pVM->tm.s.VirtualGetRawDataGC.pfnBad);
+    AssertFatalRC(rc);
+    rc = PDMR3GetSymbolGCLazy(pVM, NULL, "tmVirtualNanoTSRediscover",   &pVM->tm.s.VirtualGetRawDataGC.pfnRediscover);
+    AssertFatalRC(rc);
+
+    if (pVM->tm.s.pfnVirtualGetRawR3       == RTTimeNanoTSLFenceSync)
+        rc = PDMR3GetSymbolGCLazy(pVM, NULL, "RTTimeNanoTSLFenceSync",  &pVM->tm.s.pfnVirtualGetRawGC);
+    else if (pVM->tm.s.pfnVirtualGetRawR3  == RTTimeNanoTSLFenceAsync)
+        rc = PDMR3GetSymbolGCLazy(pVM, NULL, "RTTimeNanoTSLFenceAsync", &pVM->tm.s.pfnVirtualGetRawGC);
+    else if (pVM->tm.s.pfnVirtualGetRawR3  == RTTimeNanoTSLegacySync)
+        rc = PDMR3GetSymbolGCLazy(pVM, NULL, "RTTimeNanoTSLegacySync",  &pVM->tm.s.pfnVirtualGetRawGC);
+    else if (pVM->tm.s.pfnVirtualGetRawR3  == RTTimeNanoTSLegacyAsync)
+        rc = PDMR3GetSymbolGCLazy(pVM, NULL, "RTTimeNanoTSLegacyAsync", &pVM->tm.s.pfnVirtualGetRawGC);
+    else
+        AssertFatalFailed();
+    AssertFatalRC(rc);
 
     /*
Index: /trunk/src/VBox/VMM/VM.cpp
===================================================================
--- /trunk/src/VBox/VMM/VM.cpp	(revision 5508)
+++ /trunk/src/VBox/VMM/VM.cpp	(revision 5509)
@@ -587,4 +587,6 @@
                                                                     rc = SELMR3InitFinalize(pVM);
                                                                 if (VBOX_SUCCESS(rc))
+                                                                    rc = TMR3InitFinalize(pVM);
+                                                                if (VBOX_SUCCESS(rc))
                                                                     rc = VMMR3InitFinalize(pVM);
                                                                 if (VBOX_SUCCESS(rc))
