Index: /trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/GMMR0.cpp	(revision 31349)
+++ /trunk/src/VBox/VMM/VMMR0/GMMR0.cpp	(revision 31350)
@@ -4097,5 +4097,4 @@
 #endif
 
-#ifdef DEBUG_sandervl
 /**
  * Setup for a GMMR0CheckSharedModules call (to allow log flush jumps back to ring 3)
@@ -4142,5 +4141,4 @@
     return VINF_SUCCESS;
 }
-#endif
 
 /**
@@ -4164,11 +4162,4 @@
         return rc;
 
-# ifndef DEBUG_sandervl
-    /*
-     * Take the sempahore and do some more validations.
-     */
-    rc = RTSemFastMutexRequest(pGMM->Mtx);
-    AssertRC(rc);
-# endif
     if (GMM_CHECK_SANITY_UPON_ENTERING(pGMM))
     {
@@ -4191,7 +4182,4 @@
         rc = VERR_INTERNAL_ERROR_5;
 
-# ifndef DEBUG_sandervl
-    RTSemFastMutexRelease(pGMM->Mtx);
-# endif
     return rc;
 #else
Index: /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 31349)
+++ /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 31350)
@@ -965,32 +965,31 @@
             PVMCPU pVCpu = &pVM->aCpus[idCpu];
 
-# ifdef VBOX_WITH_VMMR0_DISABLE_PREEMPTION
-            RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER;
-            RTThreadPreemptDisable(&PreemptState);
-# elif !defined(RT_OS_WINDOWS)
-            RTCCUINTREG uFlags = ASMIntDisableFlags();
-# endif
-            /* Select a valid VCPU context. */
-            ASMAtomicWriteU32(&pVCpu->idHostCpu, RTMpCpuId());
-
-# ifdef DEBUG_sandervl
-            /* 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). */
+            /* 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). 
+             * Also grab the fast mutex before disabling preemption.
+             */
             int rc = GMMR0CheckSharedModulesStart(pVM);
             if (rc == VINF_SUCCESS)
             {
+# ifdef VBOX_WITH_VMMR0_DISABLE_PREEMPTION
+                RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER;
+                RTThreadPreemptDisable(&PreemptState);
+# elif !defined(RT_OS_WINDOWS)
+                RTCCUINTREG uFlags = ASMIntDisableFlags();
+# endif
+                /* Select a valid VCPU context. */
+                ASMAtomicWriteU32(&pVCpu->idHostCpu, RTMpCpuId());
+
                 rc = vmmR0CallRing3SetJmp(&pVCpu->vmm.s.CallRing3JmpBufR0, GMMR0CheckSharedModules, pVM, pVCpu); /* this may resume code. */
+
+                /* Clear the VCPU context. */
+                ASMAtomicWriteU32(&pVCpu->idHostCpu, NIL_RTCPUID);
+# ifdef VBOX_WITH_VMMR0_DISABLE_PREEMPTION
+                RTThreadPreemptRestore(&PreemptState);
+# elif !defined(RT_OS_WINDOWS)
+                ASMSetFlags(uFlags);
+# endif
+
                 GMMR0CheckSharedModulesEnd(pVM);
             }
-# else
-            int rc = GMMR0CheckSharedModules(pVM, pVCpu);
-# endif
-
-            /* Clear the VCPU context. */
-            ASMAtomicWriteU32(&pVCpu->idHostCpu, NIL_RTCPUID);
-# ifdef VBOX_WITH_VMMR0_DISABLE_PREEMPTION
-            RTThreadPreemptRestore(&PreemptState);
-# elif !defined(RT_OS_WINDOWS)
-            ASMSetFlags(uFlags);
-# endif
             return rc;
         }
