Index: trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp	(revision 71152)
+++ trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp	(revision 71184)
@@ -210,4 +210,9 @@
 # define WHvGetVirtualProcessorRegisters            g_pfnWHvGetVirtualProcessorRegisters
 # define WHvSetVirtualProcessorRegisters            g_pfnWHvSetVirtualProcessorRegisters
+
+# define VidMessageSlotHandleAndGetNext             g_pfnVidMessageSlotHandleAndGetNext
+# define VidStartVirtualProcessor                    g_pfnVidStartVirtualProcessor
+# define VidStopVirtualProcessor                    g_pfnVidStopVirtualProcessor
+
 #endif
 
@@ -1337,7 +1342,7 @@
 }
 
-
-#ifdef LOG_ENABLED
-
+#ifndef NEM_WIN_USE_OUR_OWN_RUN_API
+
+# ifdef LOG_ENABLED
 /**
  * Log the full details of an exit reason.
@@ -1392,5 +1397,5 @@
             break;
 
-# if 0
+#  if 0
         case WHvRunVpExitReasonUnrecoverableException:
         case WHvRunVpExitReasonInvalidVpRegisterValue:
@@ -1410,5 +1415,5 @@
             WHV_X64_UNSUPPORTED_FEATURE_CONTEXT UnsupportedFeature;
             WHV_RUN_VP_CANCELED_CONTEXT CancelReason;
-#endif
+#  endif
 
         case WHvRunVpExitReasonNone:
@@ -1455,6 +1460,29 @@
     }
 }
-
-#endif /* LOG_ENABLED */
+# endif /* LOG_ENABLED */
+
+
+/**
+ * Advances the guest RIP and clear EFLAGS.RF.
+ *
+ * This may clear VMCPU_FF_INHIBIT_INTERRUPTS.
+ *
+ * @param   pVCpu           The cross context virtual CPU structure.
+ * @param   pCtx            The CPU context to update.
+ * @param   pExitCtx        The exit context.
+ */
+DECLINLINE(void) nemR3WinAdvanceGuestRipAndClearRF(PVMCPU pVCpu, PCPUMCTX pCtx, WHV_VP_EXIT_CONTEXT const *pExitCtx)
+{
+    /* Advance the RIP. */
+    Assert(pExitCtx->InstructionLength > 0 && pExitCtx->InstructionLength < 16);
+    pCtx->rip += pExitCtx->InstructionLength;
+    pCtx->rflags.Bits.u1RF = 0;
+
+    /* Update interrupt inhibition. */
+    if (!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS))
+    { /* likely */ }
+    else if (pCtx->rip != EMGetInhibitInterruptsPC(pVCpu))
+        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS);
+}
 
 
@@ -1467,5 +1495,5 @@
 
 
-#ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
 /**
  * @callback_method_impl{FNPGMPHYSNEMENUMCALLBACK,
@@ -1493,5 +1521,5 @@
     return VINF_SUCCESS;
 }
-#endif /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
+# endif /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
 
 
@@ -1587,5 +1615,5 @@
                                       pIoPortCtx->AccessInfo.AccessSize);
             if (IOM_SUCCESS(rcStrict))
-                nemHCWinAdvanceGuestRipAndClearRF(pVCpu, pCtx, &pIoPortCtx->VpContext);
+                nemR3WinAdvanceGuestRipAndClearRF(pVCpu, pCtx, &pIoPortCtx->VpContext);
         }
         else
@@ -1597,5 +1625,5 @@
             {
                 pCtx->eax = (pCtx->eax & ~fAndMask) | (uValue & fAndMask);
-                nemHCWinAdvanceGuestRipAndClearRF(pVCpu, pCtx, &pIoPortCtx->VpContext);
+                nemR3WinAdvanceGuestRipAndClearRF(pVCpu, pCtx, &pIoPortCtx->VpContext);
             }
         }
@@ -1692,5 +1720,5 @@
 VBOXSTRICTRC nemR3WinWHvRunGC(PVM pVM, PVMCPU pVCpu)
 {
-#ifdef LOG_ENABLED
+# ifdef LOG_ENABLED
     if (LogIs3Enabled())
     {
@@ -1698,5 +1726,5 @@
         nemHCWinLogState(pVM, pVCpu);
     }
-#endif
+# endif
 
     /*
@@ -1725,8 +1753,4 @@
             && !VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_HM_TO_R3_MASK))
         {
-#ifdef NEM_WIN_USE_OUR_OWN_RUN_API
-            int rc2 = nemHCWinRunVirtualProcessor(pVM, pVCpu, &ExitReason, sizeof(ExitReason));
-            AssertRCBreakStmt(rc2, rcStrict = rc2);
-#else
             Log8(("Calling WHvRunVirtualProcessor\n"));
             VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC_NEM, VMCPUSTATE_STARTED);
@@ -1739,5 +1763,4 @@
             Log2(("WHvRunVirtualProcessor -> %#x; exit code %#x (%d) (cpu status %u)\n",
                   hrc, ExitReason.ExitReason, ExitReason.ExitReason, nemR3WinCpuGetRunningStatus(pVCpu) ));
-#endif
         }
         else
@@ -1753,5 +1776,5 @@
         AssertRCBreakStmt(rc2, rcStrict = rc2);
 
-#ifdef LOG_ENABLED
+# ifdef LOG_ENABLED
         /*
          * Do some logging.
@@ -1761,7 +1784,7 @@
         if (LogIs3Enabled())
             nemHCWinLogState(pVM, pVCpu);
-#endif
-
-#ifdef VBOX_STRICT
+# endif
+
+# ifdef VBOX_STRICT
         /* Assert that the VpContext field makes sense. */
         switch (ExitReason.ExitReason)
@@ -1792,5 +1815,5 @@
             default: break; /* shut up compiler. */
         }
-#endif
+# endif
 
         /*
@@ -1859,5 +1882,5 @@
         }
 
-#ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
         /* Hack alert! */
         uint32_t const cMappedPages = pVM->nem.s.cMappedPages;
@@ -1869,5 +1892,5 @@
             Log(("nemR3NativeRunGC: Unmapped all; cMappedPages=%u -> %u\n", cMappedPages, pVM->nem.s.cMappedPages));
         }
-#endif
+# endif
 
         /* If any FF is pending, return to the EM loops.  That's okay for the
@@ -1884,8 +1907,10 @@
 }
 
+#endif /* !NEM_WIN_USE_OUR_OWN_RUN_API */
+
 
 VBOXSTRICTRC nemR3NativeRunGC(PVM pVM, PVMCPU pVCpu)
 {
-#if 1
+#ifndef NEM_WIN_USE_OUR_OWN_RUN_API
     return nemR3WinWHvRunGC(pVM, pVCpu);
 #elif 1
