Index: /trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp	(revision 79600)
+++ /trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp	(revision 79601)
@@ -153,4 +153,12 @@
                                                               ("fExtrn=%#RX64 fExtrnMbz=%#RX64\n", \
                                                               (a_pVCpu)->cpum.GstCtx.fExtrn, (a_fExtrnMbz)))
+
+/** Log the VM-exit reason with an easily visible marker to identify it in a
+ *  potential sea of logging data. */
+#define HMVMX_LOG_EXIT(a_pVCpu, a_uExitReason) \
+    do { \
+        Log4(("VM-exit: vcpu[%RU32] reason=%#x -v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v\n", \
+             (a_pVCpu)->idCpu, (a_uExitReason))); \
+    } while (0) \
 
 
@@ -5390,5 +5398,5 @@
 
         ASMAtomicUoAndU64(&pVCpu->hm.s.fCtxChanged, ~HM_CHANGED_GUEST_RFLAGS);
-        Log4Func(("EFlags=%#RX32\n", fEFlags.u32));
+        Log4Func(("eflags=%#RX32\n", fEFlags.u32));
     }
     return VINF_SUCCESS;
@@ -9417,4 +9425,10 @@
                 pVCpu->hm.s.Event.fPending = false;
 
+                /*
+                 * If we eventually support nested-guest execution without unrestricted guest execution,
+                 * we should clear fInterceptEvents here.
+                 */
+                Assert(!pVmxTransient->fIsNestedGuest);
+
                 /* If we're stepping and we've changed cs:rip above, bail out of the VMX R0 execution loop. */
                 if (fStepping)
@@ -9638,11 +9652,4 @@
         rcStrict = hmR0VmxInjectEventVmcs(pVCpu, pVmxTransient, &pVCpu->hm.s.Event, fStepping, &fIntrState);
         AssertRCReturn(VBOXSTRICTRC_VAL(rcStrict), rcStrict);
-
-        /*
-         * If we are executing a nested-guest make sure that we should intercept subsequent
-         * events. The one we are injecting might be part of VM-entry.
-         */
-        if (pVmxTransient->fIsNestedGuest)
-            pVCpu->cpum.GstCtx.hwvirt.vmx.fInterceptEvents = true;
 
         if (uIntType == VMX_ENTRY_INT_INFO_TYPE_EXT_INT)
@@ -11253,4 +11260,13 @@
             pVCpu->hm.s.Event.fPending = false;
 
+#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
+            /*
+             * If we are executing a nested-guest make sure that we should intercept subsequent
+             * events. The one we are injecting might be part of VM-entry.
+             */
+            if (pVmxTransient->fIsNestedGuest)
+                pVCpu->cpum.GstCtx.hwvirt.vmx.fInterceptEvents = true;
+#endif
+
             /*
              * We've injected any pending events. This is really the point of no return (to ring-3).
@@ -11508,4 +11524,10 @@
     pVmxTransient->uExitReason    = VMX_EXIT_REASON_BASIC(uExitReason);
     pVmxTransient->fVMEntryFailed = VMX_EXIT_REASON_HAS_ENTRY_FAILED(uExitReason);
+
+    /*
+     * Log the VM-exit before logging anything else as otherwise it might be a
+     * tad confusing what happens before and after the world-switch.
+     */
+    HMVMX_LOG_EXIT(pVCpu, uExitReason);
 
     /*
@@ -13523,5 +13545,5 @@
         HMVMX_ASSERT_PREEMPT_SAFE(a_pVCpu); \
         HMVMX_ASSERT_PREEMPT_CPUID_VAR(); \
-        Log4Func(("vcpu[%RU32] -v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v-v\n", (a_pVCpu)->idCpu)); \
+        Log4Func(("vcpu[%RU32]\n", (a_pVCpu)->idCpu)); \
         HMVMX_ASSERT_PREEMPT_SAFE(a_pVCpu); \
         if (VMMR0IsLogFlushDisabled((a_pVCpu))) \
@@ -16338,6 +16360,8 @@
     if (RT_LIKELY(rcStrict1 == VINF_SUCCESS))
     {
-        /* If event delivery causes an EPT misconfig (MMIO), go back to instruction emulation as otherwise
-           injecting the original pending event would most likely cause the same EPT misconfig VM-exit. */
+        /*
+         * If event delivery causes an EPT misconfig (MMIO), go back to instruction emulation. Otherwise,
+         * injecting the original event would most likely cause the same EPT misconfig VM-exit again.
+         */
         if (RT_UNLIKELY(pVCpu->hm.s.Event.fPending))
         {
@@ -17210,7 +17234,7 @@
                 || iCrReg == 8)
             {
-                static const uint32_t s_aCrXReadIntercepts[] = { 0, 0, 0, VMX_PROC_CTLS_CR3_STORE_EXIT, 0,
-                                                                 0, 0, 0, VMX_PROC_CTLS_CR8_STORE_EXIT };
-                uint32_t const uIntercept = s_aCrXReadIntercepts[iCrReg];
+                static const uint32_t s_auCrXReadIntercepts[] = { 0, 0, 0, VMX_PROC_CTLS_CR3_STORE_EXIT, 0,
+                                                                  0, 0, 0, VMX_PROC_CTLS_CR8_STORE_EXIT };
+                uint32_t const uIntercept = s_auCrXReadIntercepts[iCrReg];
                 if (CPUMIsGuestVmxProcCtlsSet(pVCpu, &pVCpu->cpum.GstCtx, uIntercept))
                 {
