Index: /trunk/src/VBox/VMM/VMMAll/VMMAll.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/VMMAll.cpp	(revision 31360)
+++ /trunk/src/VBox/VMM/VMMAll/VMMAll.cpp	(revision 31361)
@@ -84,5 +84,5 @@
         PVMCPU pVCpu = &pVM->aCpus[idCpu];
 
-        if (pVCpu->hNativeThread == hThread)
+        if (pVCpu->hNativeThreadR0 == hThread)
             return pVCpu->idCpu;
     }
@@ -139,5 +139,5 @@
         PVMCPU pVCpu = &pVM->aCpus[idCpu];
 
-        if (pVCpu->hNativeThread == hThread)
+        if (pVCpu->hNativeThreadR0 == hThread)
             return pVCpu;
     }
Index: /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 31360)
+++ /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 31361)
@@ -965,4 +965,8 @@
             PVMCPU pVCpu = &pVM->aCpus[idCpu];
 
+            /* Initialize the r0 native thread handle on the fly. */
+            if (pVCpu->hNativeThreadR0 == NIL_RTNATIVETHREAD) 
+                pVCpu->hNativeThreadR0 = RTThreadNativeSelf(); 
+
             /* Make sure that log flushes can jump back to ring-3; annoying to get an incomplete log (this is risky though as the code doesn't take this into account). */
             int rc = GMMR0CheckSharedModulesStart(pVM);
