Index: trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h
===================================================================
--- trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h	(revision 93350)
+++ trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h	(revision 93351)
@@ -105,71 +105,8 @@
 
 
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-
-/**
- * Wrapper around VMMR0_DO_NEM_MAP_PAGES for a single page.
- *
- * @returns VBox status code.
- * @param   pVM         The cross context VM structure.
- * @param   pVCpu       The cross context virtual CPU structure of the caller.
- * @param   GCPhysSrc   The source page.  Does not need to be page aligned.
- * @param   GCPhysDst   The destination page.  Same as @a GCPhysSrc except for
- *                      when A20 is disabled.
- * @param   fFlags      HV_MAP_GPA_XXX.
- */
-DECLINLINE(int) nemHCWinHypercallMapPage(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhysSrc, RTGCPHYS GCPhysDst, uint32_t fFlags)
-{
-#ifdef IN_RING0
-    /** @todo optimize further, caller generally has the physical address. */
-    return nemR0WinMapPages(pVM, pVCpu,
-                            GCPhysSrc & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK,
-                            GCPhysDst & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK,
-                            1, fFlags);
-#else
-    pVCpu->nem.s.Hypercall.MapPages.GCPhysSrc   = GCPhysSrc & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK;
-    pVCpu->nem.s.Hypercall.MapPages.GCPhysDst   = GCPhysDst & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK;
-    pVCpu->nem.s.Hypercall.MapPages.cPages      = 1;
-    pVCpu->nem.s.Hypercall.MapPages.fFlags      = fFlags;
-    return VMMR3CallR0Emt(pVM, pVCpu, VMMR0_DO_NEM_MAP_PAGES, 0, NULL);
-#endif
-}
-
-
-/**
- * Wrapper around VMMR0_DO_NEM_UNMAP_PAGES for a single page.
- *
- * @returns VBox status code.
- * @param   pVM         The cross context VM structure.
- * @param   pVCpu       The cross context virtual CPU structure of the caller.
- * @param   GCPhys      The page to unmap.  Does not need to be page aligned.
- */
-DECLINLINE(int) nemHCWinHypercallUnmapPage(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys)
-{
-# ifdef IN_RING0
-    return nemR0WinUnmapPages(pVM, pVCpu, GCPhys & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK, 1);
-# else
-    pVCpu->nem.s.Hypercall.UnmapPages.GCPhys    = GCPhys & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK;
-    pVCpu->nem.s.Hypercall.UnmapPages.cPages    = 1;
-    return VMMR3CallR0Emt(pVM, pVCpu, VMMR0_DO_NEM_UNMAP_PAGES, 0, NULL);
-# endif
-}
-
-#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
 #ifndef IN_RING0
 
 NEM_TMPL_STATIC int nemHCWinCopyStateToHyperV(PVMCC pVM, PVMCPUCC pVCpu)
 {
-# if defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS) || defined(NEM_WIN_WITH_RING0_RUNLOOP)
-#  if !defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS) && defined(NEM_WIN_WITH_RING0_RUNLOOP)
-    if (pVM->nem.s.fUseRing0Runloop)
-#  endif
-    {
-        int rc = VMMR3CallR0Emt(pVM, pVCpu, VMMR0_DO_NEM_EXPORT_STATE, 0, NULL);
-        AssertLogRelRCReturn(rc, rc);
-        return rc;
-    }
-# endif
-# ifndef NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS
-
     /*
      * The following is very similar to what nemR0WinExportState() does.
@@ -492,6 +429,4 @@
 #  undef ADD_REG128
 #  undef ADD_SEG
-
-# endif /* !NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS */
 }
 
@@ -499,23 +434,4 @@
 NEM_TMPL_STATIC int nemHCWinCopyStateFromHyperV(PVMCC pVM, PVMCPUCC pVCpu, uint64_t fWhat)
 {
-# if defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS) || defined(NEM_WIN_WITH_RING0_RUNLOOP)
-#  if !defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS) && defined(NEM_WIN_WITH_RING0_RUNLOOP)
-    if (pVM->nem.s.fUseRing0Runloop)
-#  endif
-    {
-        /* See NEMR0ImportState */
-        int rc = VMMR3CallR0Emt(pVM, pVCpu, VMMR0_DO_NEM_IMPORT_STATE, fWhat, NULL);
-        if (RT_SUCCESS(rc))
-            return rc;
-        if (rc == VERR_NEM_FLUSH_TLB)
-        {
-            rc = PGMFlushTLB(pVCpu, pVCpu->cpum.GstCtx.cr3, true /*fGlobal*/);
-            return rc;
-        }
-        AssertLogRelRCReturn(rc, rc);
-        return rc;
-    }
-# endif
-# ifndef NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS
     WHV_REGISTER_NAME  aenmNames[128];
 
@@ -1138,5 +1054,4 @@
 
     return VINF_SUCCESS;
-# endif /* !NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS */
 }
 
@@ -1156,10 +1071,6 @@
 
 #ifdef IN_RING0
-# ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    return nemR0WinImportState(pVCpu->pGVM, pVCpu, &pVCpu->cpum.GstCtx, fWhat, true /*fCanUpdateCr3*/);
-# else
     RT_NOREF(pVCpu, fWhat);
     return VERR_NOT_IMPLEMENTED;
-# endif
 #else
     return nemHCWinCopyStateFromHyperV(pVCpu->pVMR3, pVCpu, fWhat);
@@ -1185,20 +1096,4 @@
     AssertReturn(VM_IS_NEM_ENABLED(pVM), VERR_NEM_IPE_9);
 
-# if defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS) || defined(NEM_WIN_WITH_RING0_RUNLOOP)
-#  if !defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS) && defined(NEM_WIN_WITH_RING0_RUNLOOP)
-    if (pVM->nem.s.fUseRing0Runloop)
-#  endif
-    {
-        /* Call ring-0 and get the values. */
-        int rc = VMMR3CallR0Emt(pVM, pVCpu, VMMR0_DO_NEM_QUERY_CPU_TICK, 0, NULL);
-        AssertLogRelRCReturn(rc, rc);
-        *pcTicks = pVCpu->nem.s.Hypercall.QueryCpuTick.cTicks;
-        if (puAux)
-            *puAux = pVCpu->cpum.GstCtx.fExtrn & CPUMCTX_EXTRN_TSC_AUX
-                   ? pVCpu->nem.s.Hypercall.QueryCpuTick.uAux : CPUMGetGuestTscAux(pVCpu);
-        return VINF_SUCCESS;
-    }
-# endif
-# ifndef NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS
     /* Call the offical API. */
     WHV_REGISTER_NAME  aenmNames[2] = { WHvX64RegisterTsc, WHvX64RegisterTscAux };
@@ -1214,15 +1109,7 @@
         *pcTicks = pVCpu->cpum.GstCtx.fExtrn & CPUMCTX_EXTRN_TSC_AUX ? aValues[0].Reg64 : CPUMGetGuestTscAux(pVCpu);
     return VINF_SUCCESS;
-# endif /* !NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS */
 #else  /* IN_RING0 */
-# ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    int rc = nemR0WinQueryCpuTick(pVCpu->pGVM, pVCpu, pcTicks, puAux);
-    if (RT_SUCCESS(rc) && puAux && !(pVCpu->cpum.GstCtx.fExtrn & CPUMCTX_EXTRN_TSC_AUX))
-        *puAux = CPUMGetGuestTscAux(pVCpu);
-    return rc;
-# else
     RT_NOREF(pVCpu, pcTicks, puAux);
     return VERR_NOT_IMPLEMENTED;
-# endif
 #endif /* IN_RING0 */
 }
@@ -1242,24 +1129,10 @@
 {
 #ifdef IN_RING0
-# ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    return nemR0WinResumeCpuTickOnAll(pVM, pVCpu, uPausedTscValue);
-# else
     RT_NOREF(pVM, pVCpu, uPausedTscValue);
     return VERR_NOT_IMPLEMENTED;
-# endif
 #else  /* IN_RING3 */
     VMCPU_ASSERT_EMT_RETURN(pVCpu, VERR_VM_THREAD_NOT_EMT);
     AssertReturn(VM_IS_NEM_ENABLED(pVM), VERR_NEM_IPE_9);
 
-# if defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS) || defined(NEM_WIN_WITH_RING0_RUNLOOP)
-#  if !defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS) && defined(NEM_WIN_WITH_RING0_RUNLOOP)
-    if (pVM->nem.s.fUseRing0Runloop)
-#  endif
-    {
-        /* Call ring-0 and do it all there. */
-        return VMMR3CallR0Emt(pVM, pVCpu, VMMR0_DO_NEM_RESUME_CPU_TICK_ON_ALL, uPausedTscValue, NULL);
-    }
-# endif
-# ifndef NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS
     /*
      * Call the offical API to do the job.
@@ -1294,59 +1167,6 @@
 
     return VINF_SUCCESS;
-# endif /* !NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS */
 #endif /* IN_RING3 */
 }
-
-#ifdef NEMWIN_NEED_GET_REGISTER
-# if defined(IN_RING0) || defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
-/** Worker for assertion macro. */
-NEM_TMPL_STATIC int nemHCWinGetRegister(PVMCPUCC pVCpu, PGVMCPU pGVCpu, uint32_t enmReg, HV_REGISTER_VALUE *pRetValue)
-{
-    RT_ZERO(*pRetValue);
-#  ifdef IN_RING3
-    RT_NOREF(pVCpu, pGVCpu, enmReg);
-    return VERR_NOT_IMPLEMENTED;
-#  else
-    NOREF(pVCpu);
-
-    /*
-     * Hypercall parameters.
-     */
-    HV_INPUT_GET_VP_REGISTERS *pInput = (HV_INPUT_GET_VP_REGISTERS *)pGVCpu->nem.s.HypercallData.pbPage;
-    AssertPtrReturn(pInput, VERR_INTERNAL_ERROR_3);
-    AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API);
-
-    pInput->PartitionId = pVCpu->pGVM->nemr0.s.idHvPartition;
-    pInput->VpIndex     = pVCpu->idCpu;
-    pInput->fFlags      = 0;
-    pInput->Names[0]    = (HV_REGISTER_NAME)enmReg;
-
-    size_t const cbInput = RT_ALIGN_Z(RT_UOFFSETOF(HV_INPUT_GET_VP_REGISTERS, Names[1]), 32);
-    HV_REGISTER_VALUE *paValues = (HV_REGISTER_VALUE *)((uint8_t *)pInput + cbInput);
-    RT_BZERO(paValues, sizeof(paValues[0]) * 1);
-
-    /*
-     * Make the hypercall and copy out the value.
-     */
-    uint64_t uResult = g_pfnHvlInvokeHypercall(HV_MAKE_CALL_INFO(HvCallGetVpRegisters, 1),
-                                               pGVCpu->nem.s.HypercallData.HCPhysPage,
-                                               pGVCpu->nem.s.HypercallData.HCPhysPage + cbInput);
-    AssertLogRelMsgReturn(uResult == HV_MAKE_CALL_REP_RET(1), ("uResult=%RX64 cRegs=%#x\n", uResult, 1),
-                          VERR_NEM_GET_REGISTERS_FAILED);
-
-    *pRetValue = paValues[0];
-    return VINF_SUCCESS;
-#  endif
-}
-# else
-/** Worker for assertion macro. */
-NEM_TMPL_STATIC int nemR3WinGetRegister(PVMCPUCC a_pVCpu, uint32_t a_enmReg, WHV_REGISTER_VALUE pValue)
-{
-    RT_ZERO(*pRetValue);
-    RT_NOREF(pVCpu, pGVCpu, enmReg);
-    return VERR_NOT_IMPLEMENTED;
-}
-# endif
-#endif
 
 
@@ -1379,6 +1199,6 @@
 
 
-#if defined(NEM_WIN_USE_OUR_OWN_RUN_API) || defined(NEM_WIN_WITH_RING0_RUNLOOP)
-# ifdef IN_RING3 /* hopefully not needed in ring-0, as we'd need KTHREADs and KeAlertThread. */
+#if defined(NEM_WIN_USE_OUR_OWN_RUN_API)
+# ifdef IN_RING3 /* hopefully not needed in ring-0, as we'd need KETHREADs and KeAlertThread. */
 /**
  * Our own WHvCancelRunVirtualProcessor that can later be moved to ring-0.
@@ -1446,5 +1266,5 @@
 }
 # endif /* IN_RING3 */
-#endif /* NEM_WIN_USE_OUR_OWN_RUN_API || NEM_WIN_WITH_RING0_RUNLOOP */
+#endif /* NEM_WIN_USE_OUR_OWN_RUN_API */
 
 
@@ -1612,21 +1432,14 @@
 #endif /* IN_RING3 && !NEM_WIN_TEMPLATE_MODE_OWN_RUN_API */
 
-#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3)
+#if defined(IN_RING3)
 
 NEM_TMPL_STATIC DECLCALLBACK(int)
 nemHCWinUnmapOnePageCallback(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, uint8_t *pu2NemState, void *pvUser)
 {
-    RT_NOREF_PV(pvUser);
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys);
-    AssertRC(rc);
-    if (RT_SUCCESS(rc))
-# else
-    RT_NOREF_PV(pVCpu);
+    RT_NOREF(pvUser, pVCpu);
     STAM_REL_PROFILE_START(&pVM->nem.s.StatProfUnmapGpaRangePage, a);
     HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE);
     STAM_REL_PROFILE_STOP(&pVM->nem.s.StatProfUnmapGpaRangePage, a);
     if (SUCCEEDED(hrc))
-# endif
     {
         Log5(("NEM GPA unmap all: %RGp (cMappedPages=%u)\n", GCPhys, pVM->nem.s.cMappedPages - 1));
@@ -1636,11 +1449,7 @@
     else
     {
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-        LogRel(("nemHCWinUnmapOnePageCallback: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc));
-# else
         LogRel(("nemHCWinUnmapOnePageCallback: GCPhys=%RGp %s hrc=%Rhrc (%#x) Last=%#x/%u (cMappedPages=%u)\n",
                 GCPhys, g_apszPageStates[*pu2NemState], hrc, hrc, RTNtLastStatusValue(),
                 RTNtLastErrorValue(), pVM->nem.s.cMappedPages));
-# endif
         *pu2NemState = NEM_WIN_PAGE_STATE_NOT_SET;
         STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
@@ -1704,5 +1513,4 @@
      * We don't really consider downgrades here, as they shouldn't happen.
      */
-# ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     /** @todo Someone at microsoft please explain:
      * I'm not sure WTF was going on, but I ended up in a loop if I remapped a
@@ -1713,5 +1521,4 @@
      * with new protection or backing.
      */
-# endif
     int rc;
     switch (u2State)
@@ -1756,36 +1563,5 @@
             }
 
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-            /* Upgrade page to writable. */
-/** @todo test this*/
-            if (   (pInfo->fNemProt & NEM_PAGE_PROT_WRITE)
-                && pState->fWriteAccess)
-            {
-                rc = nemHCWinHypercallMapPage(pVM, pVCpu, GCPhysSrc, GCPhys,
-                                              HV_MAP_GPA_READABLE   | HV_MAP_GPA_WRITABLE
-                                              | HV_MAP_GPA_EXECUTABLE | HV_MAP_GPA_EXECUTABLE_AGAIN);
-                AssertRC(rc);
-                if (RT_SUCCESS(rc))
-                {
-                    STAM_REL_COUNTER_INC(&pVM->nem.s.StatRemapPage);
-                    pInfo->u2NemState = NEM_WIN_PAGE_STATE_WRITABLE;
-                    pState->fDidSomething = true;
-                    pState->fCanResume    = true;
-                    Log5(("NEM GPA write-upgrade/exit: %RGp (was %s, cMappedPages=%u)\n",
-                          GCPhys, g_apszPageStates[u2State], pVM->nem.s.cMappedPages));
-                }
-                else
-                    STAM_REL_COUNTER_INC(&pVM->nem.s.StatRemapPageFailed);
-            }
-            else
-            {
-                /* Need to emulate the acces. */
-                AssertBreak(pInfo->fNemProt != NEM_PAGE_PROT_NONE); /* There should be no downgrades. */
-                rc = VINF_SUCCESS;
-            }
-            return rc;
-# else
             break;
-# endif
 
         case NEM_WIN_PAGE_STATE_WRITABLE:
@@ -1802,7 +1578,4 @@
                 return VINF_SUCCESS;
             }
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-            AssertFailed(); /* There should be no downgrades. */
-# endif
             break;
 
@@ -1815,9 +1588,4 @@
      * If this fails, which it does every so often, just unmap everything for now.
      */
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys);
-    AssertRC(rc);
-    if (RT_SUCCESS(rc))
-# else
     /** @todo figure out whether we mess up the state or if it's WHv.   */
     STAM_REL_PROFILE_START(&pVM->nem.s.StatProfUnmapGpaRangePage, a);
@@ -1825,5 +1593,4 @@
     STAM_REL_PROFILE_STOP(&pVM->nem.s.StatProfUnmapGpaRangePage, a);
     if (SUCCEEDED(hrc))
-# endif
     {
         pState->fDidSomething = true;
@@ -1836,8 +1603,5 @@
     }
     STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    LogRel(("nemHCWinHandleMemoryAccessPageCheckerCallback/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhys, rc));
-    return rc;
-# elif defined(VBOX_WITH_PGM_NEM_MODE)
+# if defined(VBOX_WITH_PGM_NEM_MODE)
     LogRel(("nemHCWinHandleMemoryAccessPageCheckerCallback/unmap: GCPhysDst=%RGp %s hrc=%Rhrc (%#x)\n",
             GCPhys, g_apszPageStates[u2State], hrc, hrc));
@@ -1859,5 +1623,5 @@
 }
 
-#endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) */
+#endif /* defined(IN_RING3) */
 
 
@@ -3877,55 +3641,4 @@
 
 
-#if defined(IN_RING0) && defined(NEM_WIN_WITH_RING0_RUNLOOP)
-/**
- * Perform an I/O control operation on the partition handle (VID.SYS),
- * restarting on alert-like behaviour.
- *
- * @returns NT status code.
- * @param   pGVM            The ring-0 VM structure.
- * @param   pGVCpu          The global (ring-0) per CPU structure.
- * @param   fFlags          The wait flags.
- * @param   cMillies        The timeout in milliseconds
- */
-static NTSTATUS nemR0NtPerformIoCtlMessageSlotHandleAndGetNext(PGVM pGVM, PGVMCPU pGVCpu, uint32_t fFlags, uint32_t cMillies)
-{
-    pGVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.iCpu     = pGVCpu->idCpu;
-    pGVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.fFlags   = fFlags;
-    pGVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.cMillies = cMillies;
-    NTSTATUS rcNt = nemR0NtPerformIoControl(pGVM, pGVCpu, pGVM->nemr0.s.IoCtlMessageSlotHandleAndGetNext.uFunction,
-                                            &pGVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext,
-                                            pGVM->nemr0.s.IoCtlMessageSlotHandleAndGetNext.cbInput,
-                                            NULL, 0);
-    if (rcNt == STATUS_SUCCESS)
-    { /* likely */ }
-    /*
-     * Generally, if we get down here, we have been interrupted between ACK'ing
-     * a message and waiting for the next due to a NtAlertThread call.  So, we
-     * should stop ACK'ing the previous message and get on waiting on the next.
-     * See similar stuff in nemHCWinRunGC().
-     */
-    else if (   rcNt == STATUS_TIMEOUT
-             || rcNt == STATUS_ALERTED    /* just in case */
-             || rcNt == STATUS_KERNEL_APC /* just in case */
-             || rcNt == STATUS_USER_APC   /* just in case */)
-    {
-        DBGFTRACE_CUSTOM(pGVCpu->CTX_SUFF(pVM), "IoCtlMessageSlotHandleAndGetNextRestart/1 %#x (f=%#x)", rcNt, fFlags);
-        STAM_REL_COUNTER_INC(&pGVCpu->nem.s.StatStopCpuPendingAlerts);
-        Assert(fFlags & VID_MSHAGN_F_GET_NEXT_MESSAGE);
-
-        pGVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.iCpu     = pGVCpu->idCpu;
-        pGVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.fFlags   = fFlags & ~VID_MSHAGN_F_HANDLE_MESSAGE;
-        pGVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.cMillies = cMillies;
-        rcNt = nemR0NtPerformIoControl(pGVM, pGVCpu, pGVM->nemr0.s.IoCtlMessageSlotHandleAndGetNext.uFunction,
-                                       &pGVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext,
-                                       pGVM->nemr0.s.IoCtlMessageSlotHandleAndGetNext.cbInput,
-                                       NULL, 0);
-        DBGFTRACE_CUSTOM(pGVM, "IoCtlMessageSlotHandleAndGetNextRestart/2 %#x", rcNt);
-    }
-    return rcNt;
-}
-#endif /* IN_RING0 */
-
-
 #ifdef NEM_WIN_TEMPLATE_MODE_OWN_RUN_API
 /**
@@ -4252,5 +3965,5 @@
     for (unsigned iLoop = 0;; iLoop++)
     {
-# if !defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) && !defined(VBOX_WITH_PGM_NEM_MODE)
+# ifndef VBOX_WITH_PGM_NEM_MODE
         /*
          * Hack alert!
@@ -4598,5 +4311,5 @@
 
 #endif /* defined(NEM_WIN_TEMPLATE_MODE_OWN_RUN_API) || defined(IN_RING3) */
-#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3)
+#ifdef IN_RING3
 
 /**
@@ -4609,12 +4322,6 @@
     if (pInfo->u2NemState > NEM_WIN_PAGE_STATE_UNMAPPED)
     {
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-        int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys);
-        AssertRC(rc);
-        if (RT_SUCCESS(rc))
-# else
         HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE);
         if (SUCCEEDED(hrc))
-# endif
         {
             STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
@@ -4626,12 +4333,7 @@
         {
             STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-            LogRel(("nemHCWinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc));
-            return rc;
-# else
             LogRel(("nemHCWinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp hrc=%Rhrc (%#x) Last=%#x/%u\n",
                     GCPhys, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue()));
             return VERR_NEM_IPE_2;
-# endif
         }
     }
@@ -4672,5 +4374,5 @@
 
     *pu2State = UINT8_MAX;
-#if !defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) && defined(VBOX_WITH_PGM_NEM_MODE) && defined(IN_RING3)
+#if defined(VBOX_WITH_PGM_NEM_MODE) && defined(IN_RING3)
     if (pvMemR3)
     {
@@ -4701,5 +4403,5 @@
 
 
-#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3)
+#ifdef IN_RING3
 /**
  * Worker that maps pages into Hyper-V.
@@ -4723,87 +4425,4 @@
                                            uint32_t fPageProt, uint8_t *pu2State, bool fBackingChanged)
 {
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    /*
-     * When using the hypercalls instead of the ring-3 APIs, we don't need to
-     * unmap memory before modifying it.  We still want to track the state though,
-     * since unmap will fail when called an unmapped page and we don't want to redo
-     * upgrades/downgrades.
-     */
-    uint8_t const u2OldState = *pu2State;
-    int rc;
-    if (fPageProt == NEM_PAGE_PROT_NONE)
-    {
-        if (u2OldState > NEM_WIN_PAGE_STATE_UNMAPPED)
-        {
-            rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhysDst);
-            if (RT_SUCCESS(rc))
-            {
-                *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED;
-                STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
-                uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
-                Log5(("NEM GPA unmapped/set: %RGp (was %s, cMappedPages=%u)\n", GCPhysDst, g_apszPageStates[u2OldState], cMappedPages));
-            }
-            else
-            {
-                STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
-                AssertLogRelMsgFailed(("nemHCNativeSetPhysPage/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
-            }
-        }
-        else
-            rc = VINF_SUCCESS;
-    }
-    else if (fPageProt & NEM_PAGE_PROT_WRITE)
-    {
-        if (u2OldState != NEM_WIN_PAGE_STATE_WRITABLE || fBackingChanged)
-        {
-            rc = nemHCWinHypercallMapPage(pVM, pVCpu, GCPhysSrc, GCPhysDst,
-                                            HV_MAP_GPA_READABLE   | HV_MAP_GPA_WRITABLE
-                                          | HV_MAP_GPA_EXECUTABLE | HV_MAP_GPA_EXECUTABLE_AGAIN);
-            if (RT_SUCCESS(rc))
-            {
-                *pu2State = NEM_WIN_PAGE_STATE_WRITABLE;
-                STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage);
-                uint32_t cMappedPages = u2OldState <= NEM_WIN_PAGE_STATE_UNMAPPED
-                                      ? ASMAtomicIncU32(&pVM->nem.s.cMappedPages) : pVM->nem.s.cMappedPages;
-                Log5(("NEM GPA writable/set: %RGp (was %s, cMappedPages=%u)\n", GCPhysDst, g_apszPageStates[u2OldState], cMappedPages));
-                NOREF(cMappedPages);
-            }
-            else
-            {
-                STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed);
-                AssertLogRelMsgFailed(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
-            }
-        }
-        else
-            rc = VINF_SUCCESS;
-    }
-    else
-    {
-        if (u2OldState != NEM_WIN_PAGE_STATE_READABLE || fBackingChanged)
-        {
-            rc = nemHCWinHypercallMapPage(pVM, pVCpu, GCPhysSrc, GCPhysDst,
-                                          HV_MAP_GPA_READABLE | HV_MAP_GPA_EXECUTABLE | HV_MAP_GPA_EXECUTABLE_AGAIN);
-            if (RT_SUCCESS(rc))
-            {
-                *pu2State = NEM_WIN_PAGE_STATE_READABLE;
-                STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage);
-                uint32_t cMappedPages = u2OldState <= NEM_WIN_PAGE_STATE_UNMAPPED
-                                      ? ASMAtomicIncU32(&pVM->nem.s.cMappedPages) : pVM->nem.s.cMappedPages;
-                Log5(("NEM GPA read+exec/set: %RGp (was %s, cMappedPages=%u)\n", GCPhysDst, g_apszPageStates[u2OldState], cMappedPages));
-                NOREF(cMappedPages);
-            }
-            else
-            {
-                STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed);
-                AssertLogRelMsgFailed(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
-            }
-        }
-        else
-            rc = VINF_SUCCESS;
-    }
-
-    return VINF_SUCCESS;
-
-# else /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
     /*
      * Looks like we need to unmap a page before we can change the backing
@@ -4820,26 +4439,4 @@
         if (u2OldState > NEM_WIN_PAGE_STATE_UNMAPPED)
         {
-#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-            int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhysDst);
-            AssertRC(rc);
-            if (RT_SUCCESS(rc))
-            {
-                *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED;
-                STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
-                uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
-                if (u2NewState == NEM_WIN_PAGE_STATE_UNMAPPED)
-                {
-                    Log5(("NEM GPA unmapped/set: %RGp (was %s, cMappedPages=%u)\n",
-                          GCPhysDst, g_apszPageStates[u2OldState], cMappedPages));
-                    return VINF_SUCCESS;
-                }
-            }
-            else
-            {
-                STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
-                LogRel(("nemHCNativeSetPhysPage/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
-                return rc;
-            }
-#  else
             STAM_REL_PROFILE_START(&pVM->nem.s.StatProfUnmapGpaRangePage, a);
             HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhysDst, X86_PAGE_SIZE);
@@ -4864,5 +4461,4 @@
                 return VERR_NEM_INIT_FAILED;
             }
-#  endif
         }
     }
@@ -4873,22 +4469,4 @@
     if (fPageProt & NEM_PAGE_PROT_WRITE)
     {
-#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-        int rc = nemHCWinHypercallMapPage(pVM, pVCpu, GCPhysSrc, GCPhysDst,
-                                            HV_MAP_GPA_READABLE   | HV_MAP_GPA_WRITABLE
-                                          | HV_MAP_GPA_EXECUTABLE | HV_MAP_GPA_EXECUTABLE_AGAIN);
-        AssertRC(rc);
-        if (RT_SUCCESS(rc))
-        {
-            *pu2State = NEM_WIN_PAGE_STATE_WRITABLE;
-            STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage);
-            uint32_t cMappedPages = ASMAtomicIncU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
-            Log5(("NEM GPA mapped/set: %RGp %s (was %s, cMappedPages=%u)\n",
-                  GCPhysDst, g_apszPageStates[u2NewState], g_apszPageStates[u2OldState], cMappedPages));
-            return VINF_SUCCESS;
-        }
-        STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed);
-        LogRel(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
-        return rc;
-#  else
         void *pvPage;
         int rc = nemR3NativeGCPhys2R3PtrWriteable(pVM, GCPhysSrc, &pvPage);
@@ -4913,26 +4491,8 @@
         LogRel(("nemHCNativeSetPhysPage/writable: GCPhysSrc=%RGp rc=%Rrc\n", GCPhysSrc, rc));
         return rc;
-#  endif
     }
 
     if (fPageProt & NEM_PAGE_PROT_READ)
     {
-#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-        int rc = nemHCWinHypercallMapPage(pVM, pVCpu, GCPhysSrc, GCPhysDst,
-                                          HV_MAP_GPA_READABLE | HV_MAP_GPA_EXECUTABLE | HV_MAP_GPA_EXECUTABLE_AGAIN);
-        AssertRC(rc);
-        if (RT_SUCCESS(rc))
-        {
-            *pu2State = NEM_WIN_PAGE_STATE_READABLE;
-            STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage);
-            uint32_t cMappedPages = ASMAtomicIncU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
-            Log5(("NEM GPA mapped/set: %RGp %s (was %s, cMappedPages=%u)\n",
-                  GCPhysDst, g_apszPageStates[u2NewState], g_apszPageStates[u2OldState], cMappedPages));
-            return VINF_SUCCESS;
-        }
-        STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed);
-        LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
-        return rc;
-#  else
         const void *pvPage;
         int rc = nemR3NativeGCPhys2R3PtrReadOnly(pVM, GCPhysSrc, &pvPage);
@@ -4959,5 +4519,4 @@
         LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysSrc=%RGp rc=%Rrc\n", GCPhysSrc, rc));
         return rc;
-#  endif
     }
 
@@ -4965,7 +4524,6 @@
     *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED;
     return VINF_SUCCESS;
-# endif /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
-}
-#endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) */
+}
+#endif /* IN_RING3 */
 
 
@@ -4979,21 +4537,5 @@
     }
 
-#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES)
-    PVMCPUCC pVCpu = VMMGetCpu(pVM);
-    int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhysDst);
-    AssertRC(rc);
-    if (RT_SUCCESS(rc))
-    {
-        STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
-        uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
-        Log5(("NEM GPA unmapped/just: %RGp (was %s, cMappedPages=%u)\n", GCPhysDst, g_apszPageStates[*pu2State], cMappedPages));
-        *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED;
-        return VINF_SUCCESS;
-    }
-    STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
-    LogRel(("nemHCJustUnmapPageFromHyperV/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
-    return rc;
-
-#elif defined(IN_RING3)
+#if defined(IN_RING3)
     STAM_REL_PROFILE_START(&pVM->nem.s.StatProfUnmapGpaRangePage, a);
     HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhysDst & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK, X86_PAGE_SIZE);
@@ -5027,34 +4569,15 @@
 
     int rc;
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    PVMCPUCC pVCpu = VMMGetCpu(pVM);
-# ifdef NEM_WIN_WITH_A20
+    RT_NOREF_PV(fPageProt);
+#ifdef NEM_WIN_WITH_A20
     if (   pVM->nem.s.fA20Enabled
         || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
-# endif
-        rc = nemHCNativeSetPhysPage(pVM, pVCpu, GCPhys, GCPhys, fPageProt, pu2State, true /*fBackingChanged*/);
-# ifdef NEM_WIN_WITH_A20
-    else
-    {
-        /* To keep effort at a minimum, we unmap the HMA page alias and resync it lazily when needed. */
-        rc = nemHCWinUnmapPageForA20Gate(pVM, pVCpu, GCPhys | RT_BIT_32(20));
-        if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys) && RT_SUCCESS(rc))
-            rc = nemHCNativeSetPhysPage(pVM, pVCpu, GCPhys, GCPhys, fPageProt, pu2State, true /*fBackingChanged*/);
-
-    }
-# endif
-#else
-    RT_NOREF_PV(fPageProt);
-# ifdef NEM_WIN_WITH_A20
-    if (   pVM->nem.s.fA20Enabled
-        || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
-# endif
+#endif
         rc = nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
-# ifdef NEM_WIN_WITH_A20
+#ifdef NEM_WIN_WITH_A20
     else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys))
         rc = nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     else
         rc = VINF_SUCCESS; /* ignore since we've got the alias page at this address. */
-# endif
 #endif
     return rc;
@@ -5070,32 +4593,14 @@
     RT_NOREF(HCPhys, enmType, pvR3);
 
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    PVMCPUCC pVCpu = VMMGetCpu(pVM);
-# ifdef NEM_WIN_WITH_A20
+    RT_NOREF_PV(fPageProt);
+#ifdef NEM_WIN_WITH_A20
     if (   pVM->nem.s.fA20Enabled
         || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
-# endif
-        nemHCNativeSetPhysPage(pVM, pVCpu, GCPhys, GCPhys, fPageProt, pu2State, false /*fBackingChanged*/);
-# ifdef NEM_WIN_WITH_A20
-    else
-    {
-        /* To keep effort at a minimum, we unmap the HMA page alias and resync it lazily when needed. */
-        nemHCWinUnmapPageForA20Gate(pVM, pVCpu, GCPhys | RT_BIT_32(20));
-        if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys))
-            nemHCNativeSetPhysPage(pVM, pVCpu, GCPhys, GCPhys, fPageProt, pu2State, false /*fBackingChanged*/);
-    }
-# endif
-#else
-    RT_NOREF_PV(fPageProt);
-# ifdef NEM_WIN_WITH_A20
-    if (   pVM->nem.s.fA20Enabled
-        || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
-# endif
+#endif
         nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
-# ifdef NEM_WIN_WITH_A20
+#ifdef NEM_WIN_WITH_A20
     else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys))
         nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     /* else: ignore since we've got the alias page at this address. */
-# endif
 #endif
 }
@@ -5110,32 +4615,14 @@
     RT_NOREF(HCPhysPrev, HCPhysNew, pvNewR3, enmType);
 
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    PVMCPUCC pVCpu = VMMGetCpu(pVM);
-# ifdef NEM_WIN_WITH_A20
+    RT_NOREF_PV(fPageProt);
+#ifdef NEM_WIN_WITH_A20
     if (   pVM->nem.s.fA20Enabled
         || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
-# endif
-        nemHCNativeSetPhysPage(pVM, pVCpu, GCPhys, GCPhys, fPageProt, pu2State, true /*fBackingChanged*/);
-# ifdef NEM_WIN_WITH_A20
-    else
-    {
-        /* To keep effort at a minimum, we unmap the HMA page alias and resync it lazily when needed. */
-        nemHCWinUnmapPageForA20Gate(pVM, pVCpu, GCPhys | RT_BIT_32(20));
-        if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys))
-            nemHCNativeSetPhysPage(pVM, pVCpu, GCPhys, GCPhys, fPageProt, pu2State, true /*fBackingChanged*/);
-    }
-# endif
-#else
-    RT_NOREF_PV(fPageProt);
-# ifdef NEM_WIN_WITH_A20
-    if (   pVM->nem.s.fA20Enabled
-        || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
-# endif
+#endif
         nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
-# ifdef NEM_WIN_WITH_A20
+#ifdef NEM_WIN_WITH_A20
     else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys))
         nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     /* else: ignore since we've got the alias page at this address. */
-# endif
 #endif
 }
Index: trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp	(revision 93350)
+++ trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp	(revision 93351)
@@ -66,89 +66,8 @@
 
 
-/*********************************************************************************************************************************
-*   Global Variables                                                                                                             *
-*********************************************************************************************************************************/
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-static uint64_t (*g_pfnHvlInvokeHypercall)(uint64_t uCallInfo, uint64_t HCPhysInput, uint64_t HCPhysOutput);
-
-/**
- * WinHvr.sys!WinHvDepositMemory
- *
- * This API will try allocates cPages on IdealNode and deposit it to the
- * hypervisor for use with the given partition.  The memory will be freed when
- * VID.SYS calls WinHvWithdrawAllMemory when the partition is cleanedup.
- *
- * Apparently node numbers above 64 has a different meaning.
- */
-static NTSTATUS (*g_pfnWinHvDepositMemory)(uintptr_t idPartition, size_t cPages, uintptr_t IdealNode, size_t *pcActuallyAdded);
-#endif
-
-RT_C_DECLS_BEGIN
-/**
- * The WinHvGetPartitionProperty function we intercept in VID.SYS to get the
- * Hyper-V partition ID.
- *
- * This is used from assembly.
- */
-NTSTATUS WinHvGetPartitionProperty(uintptr_t idPartition, HV_PARTITION_PROPERTY_CODE enmProperty, PHV_PARTITION_PROPERTY puValue);
-decltype(WinHvGetPartitionProperty) *g_pfnWinHvGetPartitionProperty;
-RT_C_DECLS_END
-
-/** @name VID.SYS image details.
- * @{ */
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-static uint8_t                                 *g_pbVidSys                            = NULL;
-static uintptr_t                                g_cbVidSys                            = 0;
-static PIMAGE_NT_HEADERS                        g_pVidSysHdrs                         = NULL;
-/** Pointer to the import thunk entry in VID.SYS for WinHvGetPartitionProperty if we found it. */
-static decltype(WinHvGetPartitionProperty)    **g_ppfnVidSysWinHvGetPartitionProperty = NULL;
-
-/** Critical section protecting the WinHvGetPartitionProperty hacking. */
-static RTCRITSECT                               g_VidSysCritSect;
-#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
-RT_C_DECLS_BEGIN
-/** The partition ID passed to WinHvGetPartitionProperty by VID.SYS.   */
-HV_PARTITION_ID                                 g_idVidSysFoundPartition = HV_PARTITION_ID_INVALID;
-/** The thread which is currently looking for a partition ID. */
-RTNATIVETHREAD                                  g_hVidSysMatchThread     = NIL_RTNATIVETHREAD;
-/** The property code we expect in WinHvGetPartitionProperty. */
-VID_PARTITION_PROPERTY_CODE                     g_enmVidSysMatchProperty = INT64_MAX;
-/* NEMR0NativeA-win.asm: */
-extern uint8_t                                  g_abNemR0WinHvrWinHvGetPartitionProperty_OriginalProlog[64];
-RT_C_DECLS_END
-/** @} */
-
-
-
-/*********************************************************************************************************************************
-*   Internal Functions                                                                                                           *
-*********************************************************************************************************************************/
-NEM_TMPL_STATIC int  nemR0WinMapPages(PGVM pGVM, PGVMCPU pGVCpu, RTGCPHYS GCPhysSrc, RTGCPHYS GCPhysDst,
-                                      uint32_t cPages, uint32_t fFlags);
-NEM_TMPL_STATIC int  nemR0WinUnmapPages(PGVM pGVM, PGVMCPU pGVCpu, RTGCPHYS GCPhys, uint32_t cPages);
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
-NEM_TMPL_STATIC int  nemR0WinExportState(PGVM pGVM, PGVMCPU pGVCpu, PCPUMCTX pCtx);
-NEM_TMPL_STATIC int  nemR0WinImportState(PGVM pGVM, PGVMCPU pGVCpu, PCPUMCTX pCtx, uint64_t fWhat, bool fCanUpdateCr3);
-NEM_TMPL_STATIC int  nemR0WinQueryCpuTick(PGVM pGVM, PGVMCPU pGVCpu, uint64_t *pcTicks, uint32_t *pcAux);
-NEM_TMPL_STATIC int  nemR0WinResumeCpuTickOnAll(PGVM pGVM, PGVMCPU pGVCpu, uint64_t uPausedTscValue);
-#endif
-DECLINLINE(NTSTATUS) nemR0NtPerformIoControl(PGVM pGVM, PGVMCPU pGVCpu, uint32_t uFunction, void *pvInput, uint32_t cbInput,
-                                             void *pvOutput, uint32_t cbOutput);
-
-/* NEMR0NativeA-win.asm: */
-DECLASM(NTSTATUS)    nemR0VidSysWinHvGetPartitionProperty(uintptr_t idPartition, HV_PARTITION_PROPERTY_CODE enmProperty,
-                                                          PHV_PARTITION_PROPERTY puValue);
-DECLASM(NTSTATUS)    nemR0WinHvrWinHvGetPartitionProperty(uintptr_t idPartition, HV_PARTITION_PROPERTY_CODE enmProperty,
-                                                          PHV_PARTITION_PROPERTY puValue);
-
-
 /*
  * Instantate the code we share with ring-0.
  */
-#ifdef NEM_WIN_WITH_RING0_RUNLOOP
-# define NEM_WIN_TEMPLATE_MODE_OWN_RUN_API
-#else
-# undef NEM_WIN_TEMPLATE_MODE_OWN_RUN_API
-#endif
+#undef NEM_WIN_TEMPLATE_MODE_OWN_RUN_API
 #include "../VMMAll/NEMAllNativeTemplate-win.cpp.h"
 
@@ -159,9 +78,5 @@
 VMMR0_INT_DECL(int)  NEMR0Init(void)
 {
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    return RTCritSectInit(&g_VidSysCritSect);
-#else
     return VINF_SUCCESS;
-#endif
 }
 
@@ -172,221 +87,5 @@
 VMMR0_INT_DECL(void) NEMR0Term(void)
 {
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    RTCritSectDelete(&g_VidSysCritSect);
-#endif
-}
-
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-
-/**
- * Worker for NEMR0InitVM that allocates a hypercall page.
- *
- * @returns VBox status code.
- * @param   pHypercallData  The hypercall data page to initialize.
- */
-static int nemR0InitHypercallData(PNEMR0HYPERCALLDATA pHypercallData)
-{
-    int rc = RTR0MemObjAllocPage(&pHypercallData->hMemObj, PAGE_SIZE, false /*fExecutable*/);
-    if (RT_SUCCESS(rc))
-    {
-        pHypercallData->HCPhysPage = RTR0MemObjGetPagePhysAddr(pHypercallData->hMemObj, 0 /*iPage*/);
-        AssertStmt(pHypercallData->HCPhysPage != NIL_RTHCPHYS, rc = VERR_INTERNAL_ERROR_3);
-        pHypercallData->pbPage     = (uint8_t *)RTR0MemObjAddress(pHypercallData->hMemObj);
-        AssertStmt(pHypercallData->pbPage, rc = VERR_INTERNAL_ERROR_3);
-        if (RT_SUCCESS(rc))
-            return VINF_SUCCESS;
-
-        /* bail out */
-        RTR0MemObjFree(pHypercallData->hMemObj, true /*fFreeMappings*/);
-    }
-    pHypercallData->hMemObj     = NIL_RTR0MEMOBJ;
-    pHypercallData->HCPhysPage  = NIL_RTHCPHYS;
-    pHypercallData->pbPage      = NULL;
-    return rc;
-}
-
-
-/**
- * Worker for NEMR0CleanupVM and NEMR0InitVM that cleans up a hypercall page.
- *
- * @param   pHypercallData  The hypercall data page to uninitialize.
- */
-static void nemR0DeleteHypercallData(PNEMR0HYPERCALLDATA pHypercallData)
-{
-    /* Check pbPage here since it's NULL, whereas the hMemObj can be either
-       NIL_RTR0MEMOBJ or 0 (they aren't necessarily the same). */
-    if (pHypercallData->pbPage != NULL)
-    {
-        RTR0MemObjFree(pHypercallData->hMemObj, true /*fFreeMappings*/);
-        pHypercallData->pbPage = NULL;
-    }
-    pHypercallData->hMemObj    = NIL_RTR0MEMOBJ;
-    pHypercallData->HCPhysPage = NIL_RTHCPHYS;
-}
-
-
-static int nemR0StrICmp(const char *psz1, const char *psz2)
-{
-    for (;;)
-    {
-        char ch1 = *psz1++;
-        char ch2 = *psz2++;
-        if (   ch1 != ch2
-            && RT_C_TO_LOWER(ch1) != RT_C_TO_LOWER(ch2))
-            return ch1 - ch2;
-        if (!ch1)
-            return 0;
-    }
-}
-
-
-/**
- * Worker for nemR0PrepareForVidSysIntercept().
- */
-static void nemR0PrepareForVidSysInterceptInner(void)
-{
-    uint32_t const             cbImage       = g_cbVidSys;
-    uint8_t * const            pbImage       = g_pbVidSys;
-    PIMAGE_NT_HEADERS const    pNtHdrs       = g_pVidSysHdrs;
-    uintptr_t const            offEndNtHdrs  = (uintptr_t)(pNtHdrs + 1) - (uintptr_t)pbImage;
-
-# define CHECK_LOG_RET(a_Expr, a_LogRel) do { \
-            if (RT_LIKELY(a_Expr)) { /* likely */ } \
-            else \
-            { \
-                LogRel(a_LogRel); \
-                return; \
-            } \
-        } while (0)
-
-    //__try
-    {
-        /*
-         * Get and validate the import directory entry.
-         */
-        CHECK_LOG_RET(   pNtHdrs->OptionalHeader.NumberOfRvaAndSizes >  IMAGE_DIRECTORY_ENTRY_IMPORT
-                      || pNtHdrs->OptionalHeader.NumberOfRvaAndSizes <= IMAGE_NUMBEROF_DIRECTORY_ENTRIES * 4,
-                      ("NEMR0: vid.sys: NumberOfRvaAndSizes is out of range: %#x\n", pNtHdrs->OptionalHeader.NumberOfRvaAndSizes));
-
-        IMAGE_DATA_DIRECTORY const ImportDir = pNtHdrs->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
-        CHECK_LOG_RET(   ImportDir.Size >= sizeof(IMAGE_IMPORT_DESCRIPTOR)
-                      && ImportDir.VirtualAddress >= offEndNtHdrs /* ASSUMES NT headers before imports */
-                      && (uint64_t)ImportDir.VirtualAddress + ImportDir.Size <= cbImage,
-                      ("NEMR0: vid.sys: Bad import directory entry: %#x LB %#x (cbImage=%#x, offEndNtHdrs=%#zx)\n",
-                       ImportDir.VirtualAddress, ImportDir.Size, cbImage, offEndNtHdrs));
-
-        /*
-         * Walk the import descriptor table looking for NTDLL.DLL.
-         */
-        for (PIMAGE_IMPORT_DESCRIPTOR pImps = (PIMAGE_IMPORT_DESCRIPTOR)&pbImage[ImportDir.VirtualAddress];
-             pImps->Name != 0 && pImps->FirstThunk != 0;
-             pImps++)
-        {
-            CHECK_LOG_RET(pImps->Name < cbImage, ("NEMR0: vid.sys: Bad import directory entry name: %#x", pImps->Name));
-            const char *pszModName = (const char *)&pbImage[pImps->Name];
-            if (nemR0StrICmp(pszModName, "winhvr.sys"))
-                continue;
-            CHECK_LOG_RET(pImps->FirstThunk < cbImage && pImps->FirstThunk >= offEndNtHdrs,
-                          ("NEMR0: vid.sys: Bad FirstThunk: %#x", pImps->FirstThunk));
-            CHECK_LOG_RET(   pImps->u.OriginalFirstThunk == 0
-                          || (pImps->u.OriginalFirstThunk >= offEndNtHdrs && pImps->u.OriginalFirstThunk < cbImage),
-                          ("NEMR0: vid.sys: Bad OriginalFirstThunk: %#x", pImps->u.OriginalFirstThunk));
-
-            /*
-             * Walk the thunks table(s) looking for WinHvGetPartitionProperty.
-             */
-            uintptr_t *puFirstThunk = (uintptr_t *)&pbImage[pImps->FirstThunk]; /* update this. */
-            if (   pImps->u.OriginalFirstThunk != 0
-                && pImps->u.OriginalFirstThunk != pImps->FirstThunk)
-            {
-                uintptr_t const *puOrgThunk = (uintptr_t const *)&pbImage[pImps->u.OriginalFirstThunk]; /* read from this. */
-                uintptr_t        cLeft      = (cbImage - (RT_MAX(pImps->FirstThunk, pImps->u.OriginalFirstThunk)))
-                                            / sizeof(*puFirstThunk);
-                while (cLeft-- > 0 && *puOrgThunk != 0)
-                {
-                    if (!(*puOrgThunk & IMAGE_ORDINAL_FLAG64))
-                    {
-                        CHECK_LOG_RET(*puOrgThunk >= offEndNtHdrs && *puOrgThunk < cbImage,
-                                      ("NEMR0: vid.sys: Bad thunk entry: %#x", *puOrgThunk));
-
-                        const char *pszSymbol = (const char *)&pbImage[*puOrgThunk + 2];
-                        if (strcmp(pszSymbol, "WinHvGetPartitionProperty") == 0)
-                            g_ppfnVidSysWinHvGetPartitionProperty = (decltype(WinHvGetPartitionProperty) **)puFirstThunk;
-                    }
-
-                    puOrgThunk++;
-                    puFirstThunk++;
-                }
-            }
-            else
-            {
-                /* No original thunk table, so scan the resolved symbols for a match
-                   with the WinHvGetPartitionProperty address. */
-                uintptr_t const uNeedle = (uintptr_t)g_pfnWinHvGetPartitionProperty;
-                uintptr_t       cLeft   = (cbImage - pImps->FirstThunk) / sizeof(*puFirstThunk);
-                while (cLeft-- > 0 && *puFirstThunk != 0)
-                {
-                    if (*puFirstThunk == uNeedle)
-                        g_ppfnVidSysWinHvGetPartitionProperty = (decltype(WinHvGetPartitionProperty) **)puFirstThunk;
-                    puFirstThunk++;
-                }
-            }
-        }
-
-        /* Report the findings: */
-        if (g_ppfnVidSysWinHvGetPartitionProperty)
-            LogRel(("NEMR0: vid.sys: Found WinHvGetPartitionProperty import thunk at %p (value %p vs %p)\n",
-                    g_ppfnVidSysWinHvGetPartitionProperty,*g_ppfnVidSysWinHvGetPartitionProperty, g_pfnWinHvGetPartitionProperty));
-        else
-            LogRel(("NEMR0: vid.sys: Did not find WinHvGetPartitionProperty!\n"));
-    }
-    //__except(EXCEPTION_EXECUTE_HANDLER)
-    //{
-    //    return;
-    //}
-# undef CHECK_LOG_RET
-}
-
-
-/**
- * Worker for NEMR0InitVM that prepares for intercepting stuff in VID.SYS.
- */
-static void nemR0PrepareForVidSysIntercept(RTDBGKRNLINFO hKrnlInfo)
-{
-    /*
-     * Resolve the symbols we need first.
-     */
-    int rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, "vid.sys", "__ImageBase", (void **)&g_pbVidSys);
-    if (RT_SUCCESS(rc))
-    {
-        rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, "vid.sys", "__ImageSize", (void **)&g_cbVidSys);
-        if (RT_SUCCESS(rc))
-        {
-            rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, "vid.sys", "__ImageNtHdrs", (void **)&g_pVidSysHdrs);
-            if (RT_SUCCESS(rc))
-            {
-                rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, "winhvr.sys", "WinHvGetPartitionProperty",
-                                                (void **)&g_pfnWinHvGetPartitionProperty);
-                if (RT_SUCCESS(rc))
-                {
-                    /*
-                     * Now locate the import thunk entry for WinHvGetPartitionProperty in vid.sys.
-                     */
-                    nemR0PrepareForVidSysInterceptInner();
-                }
-                else
-                    LogRel(("NEMR0: Failed to find winhvr.sys!WinHvGetPartitionProperty (%Rrc)\n", rc));
-            }
-            else
-                LogRel(("NEMR0: Failed to find vid.sys!__ImageNtHdrs (%Rrc)\n", rc));
-        }
-        else
-            LogRel(("NEMR0: Failed to find vid.sys!__ImageSize (%Rrc)\n", rc));
-    }
-    else
-        LogRel(("NEMR0: Failed to find vid.sys!__ImageBase (%Rrc)\n", rc));
-}
-
-#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
+}
 
 
@@ -406,411 +105,7 @@
     AssertRCReturn(rc, rc);
 
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    /*
-     * We want to perform hypercalls here.  The NT kernel started to expose a very low
-     * level interface to do this thru somewhere between build 14271 and 16299.  Since
-     * we need build 17134 to get anywhere at all, the exact build is not relevant here.
-     *
-     * We also need to deposit memory to the hypervisor for use with partition (page
-     * mapping structures, stuff).
-     */
-    RTDBGKRNLINFO hKrnlInfo;
-    rc = RTR0DbgKrnlInfoOpen(&hKrnlInfo, 0);
-    if (RT_SUCCESS(rc))
-    {
-        rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "HvlInvokeHypercall", (void **)&g_pfnHvlInvokeHypercall);
-        if (RT_FAILURE(rc))
-            rc = VERR_NEM_MISSING_KERNEL_API_1;
-        if (RT_SUCCESS(rc))
-        {
-            rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, "winhvr.sys", "WinHvDepositMemory", (void **)&g_pfnWinHvDepositMemory);
-            if (RT_FAILURE(rc))
-                rc = rc == VERR_MODULE_NOT_FOUND ? VERR_NEM_MISSING_KERNEL_API_2 : VERR_NEM_MISSING_KERNEL_API_3;
-        }
-
-        /*
-         * Since late 2021 we may also need to do some nasty trickery with vid.sys to get
-         * the partition ID. So, ge the necessary info while we have a hKrnlInfo instance.
-         */
-        if (RT_SUCCESS(rc))
-            nemR0PrepareForVidSysIntercept(hKrnlInfo);
-
-        RTR0DbgKrnlInfoRelease(hKrnlInfo);
-        if (RT_SUCCESS(rc))
-        {
-            /*
-             * Allocate a page for non-EMT threads to use for hypercalls (update
-             * statistics and such) and a critical section protecting it.
-             */
-            rc = RTCritSectInit(&pGVM->nemr0.s.HypercallDataCritSect);
-            if (RT_SUCCESS(rc))
-            {
-                rc = nemR0InitHypercallData(&pGVM->nemr0.s.HypercallData);
-                if (RT_SUCCESS(rc))
-                {
-                    /*
-                     * Allocate a page for each VCPU to place hypercall data on.
-                     */
-                    for (VMCPUID i = 0; i < pGVM->cCpus; i++)
-                    {
-                        rc = nemR0InitHypercallData(&pGVM->aCpus[i].nemr0.s.HypercallData);
-                        if (RT_FAILURE(rc))
-                        {
-                            while (i-- > 0)
-                                nemR0DeleteHypercallData(&pGVM->aCpus[i].nemr0.s.HypercallData);
-                            break;
-                        }
-                    }
-                    if (RT_SUCCESS(rc))
-                    {
-                        /*
-                         * So far, so good.
-                         */
-                        return rc;
-                    }
-
-                    /*
-                     * Bail out.
-                     */
-                    nemR0DeleteHypercallData(&pGVM->nemr0.s.HypercallData);
-                }
-                RTCritSectDelete(&pGVM->nemr0.s.HypercallDataCritSect);
-            }
-        }
-    }
-#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
-
     return rc;
 }
 
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-
-/**
- * Perform an I/O control operation on the partition handle (VID.SYS).
- *
- * @returns NT status code.
- * @param   pGVM            The ring-0 VM structure.
- * @param   pGVCpu          The global (ring-0) CPU structure of the calling EMT.
- * @param   uFunction       The function to perform.
- * @param   pvInput         The input buffer.  This must point within the VM
- *                          structure so we can easily convert to a ring-3
- *                          pointer if necessary.
- * @param   cbInput         The size of the input.  @a pvInput must be NULL when
- *                          zero.
- * @param   pvOutput        The output buffer.  This must also point within the
- *                          VM structure for ring-3 pointer magic.
- * @param   cbOutput        The size of the output.  @a pvOutput must be NULL
- *                          when zero.
- * @thread  EMT(pGVCpu)
- */
-DECLINLINE(NTSTATUS) nemR0NtPerformIoControl(PGVM pGVM, PGVMCPU pGVCpu, uint32_t uFunction, void *pvInput, uint32_t cbInput,
-                                             void *pvOutput, uint32_t cbOutput)
-{
-# ifdef RT_STRICT
-    /*
-     * Input and output parameters are part of the VM CPU structure.
-     */
-    VMCPU_ASSERT_EMT(pGVCpu);
-    if (pvInput)
-        AssertReturn(((uintptr_t)pvInput + cbInput) - (uintptr_t)pGVCpu <= sizeof(*pGVCpu), VERR_INVALID_PARAMETER);
-    if (pvOutput)
-        AssertReturn(((uintptr_t)pvOutput + cbOutput) - (uintptr_t)pGVCpu <= sizeof(*pGVCpu), VERR_INVALID_PARAMETER);
-# endif
-
-    int32_t rcNt = STATUS_UNSUCCESSFUL;
-    int rc = SUPR0IoCtlPerform(pGVM->nemr0.s.pIoCtlCtx, uFunction,
-                               pvInput,
-                               pvInput  ? (uintptr_t)pvInput  + pGVCpu->nemr0.s.offRing3ConversionDelta : NIL_RTR3PTR,
-                               cbInput,
-                               pvOutput,
-                               pvOutput ? (uintptr_t)pvOutput + pGVCpu->nemr0.s.offRing3ConversionDelta : NIL_RTR3PTR,
-                               cbOutput,
-                               &rcNt);
-    if (RT_SUCCESS(rc) || !NT_SUCCESS((NTSTATUS)rcNt))
-        return (NTSTATUS)rcNt;
-    return STATUS_UNSUCCESSFUL;
-}
-
-
-/**
- * Here is something that we really do not wish to do, but find us force do to
- * right now as we cannot rewrite the memory management of VBox 6.1 in time for
- * windows 11.
- *
- * @returns VBox status code.
- * @param   pGVM        The ring-0 VM structure.
- * @param   pahMemObjs  Array of 6 memory objects that the caller will release.
- *                      ASSUMES that they are initialized to NIL.
- */
-static int nemR0InitVMPart2DontWannaDoTheseUglyPartitionIdFallbacks(PGVM pGVM, PRTR0MEMOBJ pahMemObjs)
-{
-    /*
-     * Check preconditions:
-     */
-    if (   !g_ppfnVidSysWinHvGetPartitionProperty
-        || (uintptr_t)g_ppfnVidSysWinHvGetPartitionProperty & (sizeof(uintptr_t) - 1))
-    {
-        LogRel(("NEMR0: g_ppfnVidSysWinHvGetPartitionProperty is NULL or misaligned (%p), partition ID fallback not possible.\n",
-                g_ppfnVidSysWinHvGetPartitionProperty));
-        return VERR_NEM_INIT_FAILED;
-    }
-    if (!g_pfnWinHvGetPartitionProperty)
-    {
-        LogRel(("NEMR0: g_pfnWinHvGetPartitionProperty is NULL, partition ID fallback not possible.\n"));
-        return VERR_NEM_INIT_FAILED;
-    }
-    if (!pGVM->nem.s.IoCtlGetPartitionProperty.uFunction)
-    {
-        LogRel(("NEMR0: IoCtlGetPartitionProperty.uFunction is 0, partition ID fallback not possible.\n"));
-        return VERR_NEM_INIT_FAILED;
-    }
-
-    /*
-     * Create an alias for the thunk table entry because its very likely to be read-only.
-     */
-    int rc = RTR0MemObjLockKernel(&pahMemObjs[0], g_ppfnVidSysWinHvGetPartitionProperty, sizeof(uintptr_t), RTMEM_PROT_READ);
-    if (RT_FAILURE(rc))
-    {
-        LogRel(("NEMR0: RTR0MemObjLockKernel failed on VID.SYS thunk table entry: %Rrc\n", rc));
-        return rc;
-    }
-
-    rc = RTR0MemObjEnterPhys(&pahMemObjs[1], RTR0MemObjGetPagePhysAddr(pahMemObjs[0], 0), PAGE_SIZE, RTMEM_CACHE_POLICY_DONT_CARE);
-    if (RT_FAILURE(rc))
-    {
-        LogRel(("NEMR0: RTR0MemObjEnterPhys failed on VID.SYS thunk table entry: %Rrc\n", rc));
-        return rc;
-    }
-
-    rc = RTR0MemObjMapKernel(&pahMemObjs[2], pahMemObjs[1], (void *)-1, 0, RTMEM_PROT_READ | RTMEM_PROT_WRITE);
-    if (RT_FAILURE(rc))
-    {
-        LogRel(("NEMR0: RTR0MemObjMapKernel failed on VID.SYS thunk table entry: %Rrc\n", rc));
-        return rc;
-    }
-
-    decltype(WinHvGetPartitionProperty) **ppfnThunkAlias
-        = (decltype(WinHvGetPartitionProperty) **)(  (uintptr_t)RTR0MemObjAddress(pahMemObjs[2])
-                                                   | ((uintptr_t)g_ppfnVidSysWinHvGetPartitionProperty & PAGE_OFFSET_MASK));
-    LogRel(("NEMR0: ppfnThunkAlias=%p *ppfnThunkAlias=%p; original: %p & %p, phys %RHp\n", ppfnThunkAlias, *ppfnThunkAlias,
-            g_ppfnVidSysWinHvGetPartitionProperty, *g_ppfnVidSysWinHvGetPartitionProperty,
-            RTR0MemObjGetPagePhysAddr(pahMemObjs[0], 0) ));
-
-    /*
-     * Create an alias for the target code in WinHvr.sys as there is a very decent
-     * chance we have to patch it.
-     */
-    rc = RTR0MemObjLockKernel(&pahMemObjs[3], g_pfnWinHvGetPartitionProperty, sizeof(uintptr_t), RTMEM_PROT_READ);
-    if (RT_FAILURE(rc))
-    {
-        LogRel(("NEMR0: RTR0MemObjLockKernel failed on WinHvGetPartitionProperty (%p): %Rrc\n", g_pfnWinHvGetPartitionProperty, rc));
-        return rc;
-    }
-
-    rc = RTR0MemObjEnterPhys(&pahMemObjs[4], RTR0MemObjGetPagePhysAddr(pahMemObjs[3], 0), PAGE_SIZE, RTMEM_CACHE_POLICY_DONT_CARE);
-    if (RT_FAILURE(rc))
-    {
-        LogRel(("NEMR0: RTR0MemObjEnterPhys failed on WinHvGetPartitionProperty: %Rrc\n", rc));
-        return rc;
-    }
-
-    rc = RTR0MemObjMapKernel(&pahMemObjs[5], pahMemObjs[4], (void *)-1, 0, RTMEM_PROT_READ | RTMEM_PROT_WRITE);
-    if (RT_FAILURE(rc))
-    {
-        LogRel(("NEMR0: RTR0MemObjMapKernel failed on WinHvGetPartitionProperty: %Rrc\n", rc));
-        return rc;
-    }
-
-    uint8_t *pbTargetAlias = (uint8_t *)(  (uintptr_t)RTR0MemObjAddress(pahMemObjs[5])
-                                         | ((uintptr_t)g_pfnWinHvGetPartitionProperty & PAGE_OFFSET_MASK));
-    LogRel(("NEMR0: pbTargetAlias=%p %.16Rhxs; original: %p %.16Rhxs, phys %RHp\n", pbTargetAlias, pbTargetAlias,
-            g_pfnWinHvGetPartitionProperty, g_pfnWinHvGetPartitionProperty, RTR0MemObjGetPagePhysAddr(pahMemObjs[3], 0) ));
-
-    /*
-     * Analyse the target functions prologue to figure out how much we should copy
-     * when patching it.  We repeat this every time because we don't want to get
-     * tripped up by someone else doing the same stuff as we're doing here.
-     * We need at least 12 bytes for the patch sequence (MOV RAX, QWORD; JMP RAX)
-     */
-    union
-    {
-        uint8_t  ab[48];    /**< Must be equal or smallar than g_abNemR0WinHvrWinHvGetPartitionProperty_OriginalProlog */
-        int64_t  ai64[6];
-    } Org;
-    memcpy(Org.ab, g_pfnWinHvGetPartitionProperty, sizeof(Org)); /** @todo ASSUMES 48 valid bytes start at function... */
-
-    uint32_t       offJmpBack = 0;
-    uint32_t const cbMinJmpPatch = 12;
-    DISSTATE       Dis;
-    while (offJmpBack < cbMinJmpPatch && offJmpBack < sizeof(Org) - 16)
-    {
-        uint32_t cbInstr = 1;
-        rc = DISInstr(&Org.ab[offJmpBack], DISCPUMODE_64BIT, &Dis, &cbInstr);
-        if (RT_FAILURE(rc))
-        {
-            LogRel(("NEMR0: DISInstr failed %#x bytes into WinHvGetPartitionProperty: %Rrc (%.48Rhxs)\n",
-                    offJmpBack, rc, Org.ab));
-            break;
-        }
-        if (Dis.pCurInstr->fOpType & DISOPTYPE_CONTROLFLOW)
-        {
-            LogRel(("NEMR0: Control flow instruction %#x bytes into WinHvGetPartitionProperty prologue: %.48Rhxs\n",
-                    offJmpBack, Org.ab));
-            break;
-        }
-        if (Dis.ModRM.Bits.Mod == 0 && Dis.ModRM.Bits.Rm == 5 /* wrt RIP */)
-        {
-            LogRel(("NEMR0: RIP relative addressing %#x bytes into WinHvGetPartitionProperty prologue: %.48Rhxs\n",
-                    offJmpBack, Org.ab));
-            break;
-        }
-        offJmpBack += cbInstr;
-    }
-
-    uintptr_t const cbLeftInPage = PAGE_SIZE - ((uintptr_t)g_pfnWinHvGetPartitionProperty & PAGE_OFFSET_MASK);
-    if (cbLeftInPage < 16 && offJmpBack >= cbMinJmpPatch)
-    {
-        LogRel(("NEMR0: WinHvGetPartitionProperty patching not possible do the page crossing: %p (%#zx)\n",
-                g_pfnWinHvGetPartitionProperty, cbLeftInPage));
-        offJmpBack = 0;
-    }
-    if (offJmpBack >= cbMinJmpPatch)
-        LogRel(("NEMR0: offJmpBack=%#x for WinHvGetPartitionProperty (%p: %.48Rhxs)\n",
-                offJmpBack, g_pfnWinHvGetPartitionProperty, Org.ab));
-    else
-        offJmpBack = 0;
-    rc = VINF_SUCCESS;
-
-    /*
-     * Now enter serialization lock and get on with it...
-     */
-    PVMCPUCC const pVCpu0 = &pGVM->aCpus[0];
-    NTSTATUS       rcNt;
-    RTCritSectEnter(&g_VidSysCritSect);
-
-    /*
-     * First attempt, patching the import table entry.
-     */
-    g_idVidSysFoundPartition = HV_PARTITION_ID_INVALID;
-    g_hVidSysMatchThread     = RTThreadNativeSelf();
-    g_enmVidSysMatchProperty = pVCpu0->nem.s.uIoCtlBuf.GetProp.enmProperty = HvPartitionPropertyProcessorVendor;
-    pVCpu0->nem.s.uIoCtlBuf.GetProp.uValue = 0;
-
-    void *pvOld = NULL;
-    if (ASMAtomicCmpXchgExPtr(ppfnThunkAlias, (void *)(uintptr_t)nemR0VidSysWinHvGetPartitionProperty,
-                              (void *)(uintptr_t)g_pfnWinHvGetPartitionProperty, &pvOld))
-    {
-        LogRel(("NEMR0: after switch to %p: ppfnThunkAlias=%p *ppfnThunkAlias=%p; original: %p & %p\n",
-                nemR0VidSysWinHvGetPartitionProperty, ppfnThunkAlias, *ppfnThunkAlias,
-                g_ppfnVidSysWinHvGetPartitionProperty, *g_ppfnVidSysWinHvGetPartitionProperty));
-
-        rcNt = nemR0NtPerformIoControl(pGVM, pVCpu0, pGVM->nemr0.s.IoCtlGetPartitionProperty.uFunction,
-                                       &pVCpu0->nem.s.uIoCtlBuf.GetProp.enmProperty,
-                                       sizeof(pVCpu0->nem.s.uIoCtlBuf.GetProp.enmProperty),
-                                       &pVCpu0->nem.s.uIoCtlBuf.GetProp.uValue,
-                                       sizeof(pVCpu0->nem.s.uIoCtlBuf.GetProp.uValue));
-        ASMAtomicWritePtr(ppfnThunkAlias, (void *)(uintptr_t)g_pfnWinHvGetPartitionProperty);
-        HV_PARTITION_ID idHvPartition = g_idVidSysFoundPartition;
-
-        LogRel(("NEMR0: WinHvGetPartitionProperty trick #1 yielded: rcNt=%#x idHvPartition=%#RX64 uValue=%#RX64\n",
-                rcNt, idHvPartition, pVCpu0->nem.s.uIoCtlBuf.GetProp.uValue));
-        pGVM->nemr0.s.idHvPartition = idHvPartition;
-    }
-    else
-    {
-        LogRel(("NEMR0: Unexpected WinHvGetPartitionProperty pointer in VID.SYS: %p, expected %p\n",
-                pvOld, g_pfnWinHvGetPartitionProperty));
-        rc = VERR_NEM_INIT_FAILED;
-    }
-
-    /*
-     * If that didn't succeed, try patching the winhvr.sys code.
-     */
-    if (   pGVM->nemr0.s.idHvPartition == HV_PARTITION_ID_INVALID
-        && offJmpBack >= cbMinJmpPatch)
-    {
-        g_idVidSysFoundPartition = HV_PARTITION_ID_INVALID;
-        g_hVidSysMatchThread     = RTThreadNativeSelf();
-        g_enmVidSysMatchProperty = pVCpu0->nem.s.uIoCtlBuf.GetProp.enmProperty = HvPartitionPropertyProcessorVendor;
-        pVCpu0->nem.s.uIoCtlBuf.GetProp.uValue = 0;
-
-        /*
-         * Prepare the hook area.
-         */
-        uint8_t *pbDst = g_abNemR0WinHvrWinHvGetPartitionProperty_OriginalProlog;
-        memcpy(pbDst, (uint8_t const *)(uintptr_t)g_pfnWinHvGetPartitionProperty, offJmpBack);
-        pbDst += offJmpBack;
-
-        *pbDst++ = 0x48; /* mov rax, imm64 */
-        *pbDst++ = 0xb8;
-        *(uint64_t *)pbDst = (uintptr_t)g_pfnWinHvGetPartitionProperty + offJmpBack;
-        pbDst += sizeof(uint64_t);
-        *pbDst++ = 0xff; /* jmp rax */
-        *pbDst++ = 0xe0;
-        *pbDst++ = 0xcc; /* int3 */
-
-        /*
-         * Patch the original. We use cmpxchg16b here to avoid concurrency problems
-         * (this also makes sure we don't trample over someone else doing similar
-         * patching at the same time).
-         */
-        union
-        {
-            uint8_t  ab[16];
-            uint64_t au64[2];
-        } Patch;
-        memcpy(Patch.ab, Org.ab, sizeof(Patch));
-        pbDst = Patch.ab;
-        *pbDst++ = 0x48; /* mov rax, imm64 */
-        *pbDst++ = 0xb8;
-        *(uint64_t *)pbDst = (uintptr_t)nemR0WinHvrWinHvGetPartitionProperty;
-        pbDst += sizeof(uint64_t);
-        *pbDst++ = 0xff; /* jmp rax */
-        *pbDst++ = 0xe0;
-
-        int64_t ai64CmpCopy[2] = { Org.ai64[0], Org.ai64[1] }; /* paranoia  */
-        if (_InterlockedCompareExchange128((__int64 volatile *)pbTargetAlias, Patch.au64[1], Patch.au64[0], ai64CmpCopy) != 0)
-        {
-            rcNt = nemR0NtPerformIoControl(pGVM, pVCpu0, pGVM->nemr0.s.IoCtlGetPartitionProperty.uFunction,
-                                           &pVCpu0->nem.s.uIoCtlBuf.GetProp.enmProperty,
-                                           sizeof(pVCpu0->nem.s.uIoCtlBuf.GetProp.enmProperty),
-                                           &pVCpu0->nem.s.uIoCtlBuf.GetProp.uValue,
-                                           sizeof(pVCpu0->nem.s.uIoCtlBuf.GetProp.uValue));
-
-            for (uint32_t cFailures = 0; cFailures < 10; cFailures++)
-            {
-                ai64CmpCopy[0] = Patch.au64[0]; /* paranoia */
-                ai64CmpCopy[1] = Patch.au64[1];
-                if (_InterlockedCompareExchange128((__int64 volatile *)pbTargetAlias, Org.ai64[1], Org.ai64[0], ai64CmpCopy) != 0)
-                {
-                    if (cFailures > 0)
-                        LogRel(("NEMR0: Succeeded on try #%u.\n", cFailures));
-                    break;
-                }
-                LogRel(("NEMR0: Patch restore failure #%u: %.16Rhxs, expected %.16Rhxs\n",
-                        cFailures + 1, &ai64CmpCopy[0], &Patch.au64[0]));
-                RTThreadSleep(1000);
-            }
-
-            HV_PARTITION_ID idHvPartition = g_idVidSysFoundPartition;
-            LogRel(("NEMR0: WinHvGetPartitionProperty trick #2 yielded: rcNt=%#x idHvPartition=%#RX64 uValue=%#RX64\n",
-                    rcNt, idHvPartition, pVCpu0->nem.s.uIoCtlBuf.GetProp.uValue));
-            pGVM->nemr0.s.idHvPartition = idHvPartition;
-
-        }
-        else
-        {
-            LogRel(("NEMR0: Failed to install WinHvGetPartitionProperty patch: %.16Rhxs, expected %.16Rhxs\n",
-                    &ai64CmpCopy[0], &Org.ai64[0]));
-            rc = VERR_NEM_INIT_FAILED;
-        }
-    }
-
-    RTCritSectLeave(&g_VidSysCritSect);
-
-    return rc;
-}
-
-#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
 
 /**
@@ -825,112 +120,4 @@
     int rc = GVMMR0ValidateGVMandEMT(pGVM, 0);
     AssertRCReturn(rc, rc);
-    SUPR0Printf("NEMR0InitVMPart2\n"); LogRel(("2: NEMR0InitVMPart2\n"));
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-# ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    Assert(pGVM->nemr0.s.fMayUseRing0Runloop == false);
-# endif
-
-    /*
-     * Copy and validate the I/O control information from ring-3.
-     */
-    NEMWINIOCTL Copy = pGVM->nem.s.IoCtlGetHvPartitionId;
-    AssertLogRelReturn(Copy.uFunction != 0, VERR_NEM_INIT_FAILED);
-    AssertLogRelReturn(Copy.cbInput == 0, VERR_NEM_INIT_FAILED);
-    AssertLogRelReturn(Copy.cbOutput == sizeof(HV_PARTITION_ID), VERR_NEM_INIT_FAILED);
-    pGVM->nemr0.s.IoCtlGetHvPartitionId = Copy;
-
-    Copy = pGVM->nem.s.IoCtlGetPartitionProperty;
-    AssertLogRelReturn(Copy.uFunction != 0, VERR_NEM_INIT_FAILED);
-    AssertLogRelReturn(Copy.cbInput == sizeof(VID_PARTITION_PROPERTY_CODE), VERR_NEM_INIT_FAILED);
-    AssertLogRelReturn(Copy.cbOutput == sizeof(HV_PARTITION_PROPERTY), VERR_NEM_INIT_FAILED);
-    pGVM->nemr0.s.IoCtlGetPartitionProperty = Copy;
-
-# ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    pGVM->nemr0.s.fMayUseRing0Runloop = pGVM->nem.s.fUseRing0Runloop;
-
-    Copy = pGVM->nem.s.IoCtlStartVirtualProcessor;
-    AssertLogRelStmt(Copy.uFunction != 0, rc = VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(Copy.cbInput == sizeof(HV_VP_INDEX), rc = VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(Copy.cbOutput == 0, rc = VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(Copy.uFunction != pGVM->nemr0.s.IoCtlGetHvPartitionId.uFunction, rc = VERR_NEM_INIT_FAILED);
-    if (RT_SUCCESS(rc))
-        pGVM->nemr0.s.IoCtlStartVirtualProcessor = Copy;
-
-    Copy = pGVM->nem.s.IoCtlStopVirtualProcessor;
-    AssertLogRelStmt(Copy.uFunction != 0, rc = VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(Copy.cbInput == sizeof(HV_VP_INDEX), rc = VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(Copy.cbOutput == 0, rc = VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(Copy.uFunction != pGVM->nemr0.s.IoCtlGetHvPartitionId.uFunction, rc = VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(Copy.uFunction != pGVM->nemr0.s.IoCtlStartVirtualProcessor.uFunction, rc = VERR_NEM_INIT_FAILED);
-    if (RT_SUCCESS(rc))
-        pGVM->nemr0.s.IoCtlStopVirtualProcessor = Copy;
-
-    Copy = pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext;
-    AssertLogRelStmt(Copy.uFunction != 0, rc = VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(   Copy.cbInput == sizeof(VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT)
-                     || Copy.cbInput == RT_OFFSETOF(VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT, cMillies),
-                     rc = VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(Copy.cbOutput == 0, VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(Copy.uFunction != pGVM->nemr0.s.IoCtlGetHvPartitionId.uFunction, rc = VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(Copy.uFunction != pGVM->nemr0.s.IoCtlStartVirtualProcessor.uFunction, rc = VERR_NEM_INIT_FAILED);
-    AssertLogRelStmt(Copy.uFunction != pGVM->nemr0.s.IoCtlStopVirtualProcessor.uFunction, rc = VERR_NEM_INIT_FAILED);
-    if (RT_SUCCESS(rc))
-        pGVM->nemr0.s.IoCtlMessageSlotHandleAndGetNext = Copy;
-# endif
-
-    if (   RT_SUCCESS(rc)
-        || !pGVM->nem.s.fUseRing0Runloop)
-    {
-        /*
-         * Setup of an I/O control context for the partition handle for later use.
-         */
-        rc = SUPR0IoCtlSetupForHandle(pGVM->pSession, pGVM->nem.s.hPartitionDevice, 0, &pGVM->nemr0.s.pIoCtlCtx);
-        AssertLogRelRCReturn(rc, rc);
-        for (VMCPUID idCpu = 0; idCpu < pGVM->cCpus; idCpu++)
-        {
-            PGVMCPU pGVCpu = &pGVM->aCpus[idCpu];
-            pGVCpu->nemr0.s.offRing3ConversionDelta = (uintptr_t)pGVM->aCpus[idCpu].pVCpuR3 - (uintptr_t)pGVCpu;
-        }
-
-        /*
-         * Get the partition ID.
-         */
-        PVMCPUCC pVCpu0 = &pGVM->aCpus[0];
-        NTSTATUS rcNt = nemR0NtPerformIoControl(pGVM, pVCpu0, pGVM->nemr0.s.IoCtlGetHvPartitionId.uFunction, NULL, 0,
-                                                &pVCpu0->nem.s.uIoCtlBuf.idPartition, sizeof(pVCpu0->nem.s.uIoCtlBuf.idPartition));
-# if 0
-        AssertLogRelMsgReturn(NT_SUCCESS(rcNt), ("IoCtlGetHvPartitionId failed: %#x\n", rcNt), VERR_NEM_INIT_FAILED);
-        pGVM->nemr0.s.idHvPartition = pVCpu0->nem.s.uIoCtlBuf.idPartition;
-# else
-        /*
-         * Since 2021 (Win11) the above I/O control doesn't work on exo-partitions
-         * so we have to go to extremes to get at it.  Sigh.
-         */
-        if (   !NT_SUCCESS(rcNt)
-            || pVCpu0->nem.s.uIoCtlBuf.idPartition == HV_PARTITION_ID_INVALID)
-        {
-            LogRel(("IoCtlGetHvPartitionId failed: r0=%#RX64, r3=%#RX64, rcNt=%#x\n",
-                    pGVM->nemr0.s.idHvPartition, pGVM->nem.s.idHvPartition, rcNt));
-
-            RTR0MEMOBJ ahMemObjs[6]
-                = { NIL_RTR0MEMOBJ, NIL_RTR0MEMOBJ, NIL_RTR0MEMOBJ, NIL_RTR0MEMOBJ, NIL_RTR0MEMOBJ, NIL_RTR0MEMOBJ };
-            rc = nemR0InitVMPart2DontWannaDoTheseUglyPartitionIdFallbacks(pGVM, ahMemObjs);
-            size_t i = RT_ELEMENTS(ahMemObjs);
-            while (i-- > 0)
-                RTR0MemObjFree(ahMemObjs[i], false /*fFreeMappings*/);
-        }
-        else
-            pGVM->nemr0.s.idHvPartition = pVCpu0->nem.s.uIoCtlBuf.idPartition;
-
-        if (pGVM->nem.s.idHvPartition == HV_PARTITION_ID_INVALID)
-            pGVM->nem.s.idHvPartition = pGVM->nemr0.s.idHvPartition;
-# endif
-        AssertLogRelMsgReturn(pGVM->nemr0.s.idHvPartition == pGVM->nem.s.idHvPartition,
-                              ("idHvPartition mismatch: r0=%#RX64, r3=%#RX64\n", pGVM->nemr0.s.idHvPartition, pGVM->nem.s.idHvPartition),
-                              VERR_NEM_INIT_FAILED);
-        if (RT_SUCCESS(rc) && pGVM->nemr0.s.idHvPartition == HV_PARTITION_ID_INVALID)
-            rc = VERR_NEM_INIT_FAILED;
-    }
-#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
 
     return rc;
@@ -948,127 +135,6 @@
 VMMR0_INT_DECL(void) NEMR0CleanupVM(PGVM pGVM)
 {
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    pGVM->nemr0.s.idHvPartition = HV_PARTITION_ID_INVALID;
-
-    /* Clean up I/O control context. */
-    if (pGVM->nemr0.s.pIoCtlCtx)
-    {
-        int rc = SUPR0IoCtlCleanup(pGVM->nemr0.s.pIoCtlCtx);
-        AssertRC(rc);
-        pGVM->nemr0.s.pIoCtlCtx = NULL;
-    }
-
-    /* Free the hypercall pages. */
-    VMCPUID i = pGVM->cCpus;
-    while (i-- > 0)
-        nemR0DeleteHypercallData(&pGVM->aCpus[i].nemr0.s.HypercallData);
-
-    /* The non-EMT one too. */
-    if (RTCritSectIsInitialized(&pGVM->nemr0.s.HypercallDataCritSect))
-        RTCritSectDelete(&pGVM->nemr0.s.HypercallDataCritSect);
-    nemR0DeleteHypercallData(&pGVM->nemr0.s.HypercallData);
-#else
     RT_NOREF(pGVM);
-#endif
-}
-
-
-#if 0 /* for debugging GPA unmapping.  */
-static int nemR3WinDummyReadGpa(PGVM pGVM, PGVMCPU pGVCpu, RTGCPHYS GCPhys)
-{
-    PHV_INPUT_READ_GPA  pIn  = (PHV_INPUT_READ_GPA)pGVCpu->nemr0.s.pbHypercallData;
-    PHV_OUTPUT_READ_GPA pOut = (PHV_OUTPUT_READ_GPA)(pIn + 1);
-    pIn->PartitionId            = pGVM->nemr0.s.idHvPartition;
-    pIn->VpIndex                = pGVCpu->idCpu;
-    pIn->ByteCount              = 0x10;
-    pIn->BaseGpa                = GCPhys;
-    pIn->ControlFlags.AsUINT64  = 0;
-    pIn->ControlFlags.CacheType = HvCacheTypeX64WriteCombining;
-    memset(pOut, 0xfe, sizeof(*pOut));
-    uint64_t volatile uResult = g_pfnHvlInvokeHypercall(HvCallReadGpa, pGVCpu->nemr0.s.HCPhysHypercallData,
-                                                        pGVCpu->nemr0.s.HCPhysHypercallData + sizeof(*pIn));
-    LogRel(("nemR3WinDummyReadGpa: %RGp -> %#RX64; code=%u rsvd=%u abData=%.16Rhxs\n",
-            GCPhys, uResult, pOut->AccessResult.ResultCode, pOut->AccessResult.Reserved, pOut->Data));
-    __debugbreak();
-
-    return uResult != 0 ? VERR_READ_ERROR : VINF_SUCCESS;
-}
-#endif
-
-
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-/**
- * Worker for NEMR0MapPages and others.
- */
-NEM_TMPL_STATIC int nemR0WinMapPages(PGVM pGVM, PGVMCPU pGVCpu, RTGCPHYS GCPhysSrc, RTGCPHYS GCPhysDst,
-                                     uint32_t cPages, uint32_t fFlags)
-{
-    /*
-     * Validate.
-     */
-    AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-
-    AssertReturn(cPages > 0, VERR_OUT_OF_RANGE);
-    AssertReturn(cPages <= NEM_MAX_MAP_PAGES, VERR_OUT_OF_RANGE);
-    AssertReturn(!(fFlags & ~(HV_MAP_GPA_MAYBE_ACCESS_MASK & ~HV_MAP_GPA_DUNNO_ACCESS)), VERR_INVALID_FLAGS);
-    AssertMsgReturn(!(GCPhysDst & X86_PAGE_OFFSET_MASK), ("GCPhysDst=%RGp\n", GCPhysDst), VERR_OUT_OF_RANGE);
-    AssertReturn(GCPhysDst < _1E, VERR_OUT_OF_RANGE);
-    if (GCPhysSrc != GCPhysDst)
-    {
-        AssertMsgReturn(!(GCPhysSrc & X86_PAGE_OFFSET_MASK), ("GCPhysSrc=%RGp\n", GCPhysSrc), VERR_OUT_OF_RANGE);
-        AssertReturn(GCPhysSrc < _1E, VERR_OUT_OF_RANGE);
-    }
-
-    /*
-     * Compose and make the hypercall.
-     * Ring-3 is not allowed to fill in the host physical addresses of the call.
-     */
-    for (uint32_t iTries = 0;; iTries++)
-    {
-        RTGCPHYS GCPhysSrcTmp = GCPhysSrc;
-        HV_INPUT_MAP_GPA_PAGES *pMapPages = (HV_INPUT_MAP_GPA_PAGES *)pGVCpu->nemr0.s.HypercallData.pbPage;
-        AssertPtrReturn(pMapPages, VERR_INTERNAL_ERROR_3);
-        pMapPages->TargetPartitionId    = pGVM->nemr0.s.idHvPartition;
-        pMapPages->TargetGpaBase        = GCPhysDst >> X86_PAGE_SHIFT;
-        pMapPages->MapFlags             = fFlags;
-        pMapPages->u32ExplicitPadding   = 0;
-
-        for (uint32_t iPage = 0; iPage < cPages; iPage++, GCPhysSrcTmp += X86_PAGE_SIZE)
-        {
-            RTHCPHYS HCPhys = NIL_RTGCPHYS;
-            int rc = PGMPhysGCPhys2HCPhys(pGVM, GCPhysSrcTmp, &HCPhys);
-            AssertRCReturn(rc, rc);
-            pMapPages->PageList[iPage] = HCPhys >> X86_PAGE_SHIFT;
-        }
-
-        uint64_t uResult = g_pfnHvlInvokeHypercall(HvCallMapGpaPages | ((uint64_t)cPages << 32),
-                                                   pGVCpu->nemr0.s.HypercallData.HCPhysPage, 0);
-        Log6(("NEMR0MapPages: %RGp/%RGp L %u prot %#x -> %#RX64\n",
-              GCPhysDst, GCPhysSrcTmp - cPages * X86_PAGE_SIZE, cPages, fFlags, uResult));
-        if (uResult == ((uint64_t)cPages << 32))
-            return VINF_SUCCESS;
-
-        /*
-         * If the partition is out of memory, try donate another 512 pages to
-         * it (2MB).  VID.SYS does multiples of 512 pages, nothing smaller.
-         */
-        if (   uResult != HV_STATUS_INSUFFICIENT_MEMORY
-            || iTries > 16
-            || g_pfnWinHvDepositMemory == NULL)
-        {
-            LogRel(("g_pfnHvlInvokeHypercall/MapGpaPages -> %#RX64\n", uResult));
-            return VERR_NEM_MAP_PAGES_FAILED;
-        }
-
-        size_t cPagesAdded = 0;
-        NTSTATUS rcNt = g_pfnWinHvDepositMemory(pGVM->nemr0.s.idHvPartition, 512, 0, &cPagesAdded);
-        if (!cPagesAdded)
-        {
-            LogRel(("g_pfnWinHvDepositMemory -> %#x / %#RX64\n", rcNt, uResult));
-            return VERR_NEM_MAP_PAGES_FAILED;
-        }
-    }
-}
-#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
+}
 
 
@@ -1087,73 +153,7 @@
 VMMR0_INT_DECL(int) NEMR0MapPages(PGVM pGVM, VMCPUID idCpu)
 {
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    /*
-     * Unpack the call.
-     */
-    int rc = GVMMR0ValidateGVMandEMT(pGVM, idCpu);
-    if (RT_SUCCESS(rc))
-    {
-        PGVMCPU pGVCpu = &pGVM->aCpus[idCpu];
-
-        RTGCPHYS const          GCPhysSrc = pGVCpu->nem.s.Hypercall.MapPages.GCPhysSrc;
-        RTGCPHYS const          GCPhysDst = pGVCpu->nem.s.Hypercall.MapPages.GCPhysDst;
-        uint32_t const          cPages    = pGVCpu->nem.s.Hypercall.MapPages.cPages;
-        HV_MAP_GPA_FLAGS const  fFlags    = pGVCpu->nem.s.Hypercall.MapPages.fFlags;
-
-        /*
-         * Do the work.
-         */
-        rc = nemR0WinMapPages(pGVM, pGVCpu, GCPhysSrc, GCPhysDst, cPages, fFlags);
-    }
-    return rc;
-#else
     RT_NOREF(pGVM, idCpu);
     return  VERR_NOT_IMPLEMENTED;
-#endif
-}
-
-
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-/**
- * Worker for NEMR0UnmapPages and others.
- */
-NEM_TMPL_STATIC int nemR0WinUnmapPages(PGVM pGVM, PGVMCPU pGVCpu, RTGCPHYS GCPhys, uint32_t cPages)
-{
-    /*
-     * Validate input.
-     */
-    AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-
-    AssertReturn(cPages > 0, VERR_OUT_OF_RANGE);
-    AssertReturn(cPages <= NEM_MAX_UNMAP_PAGES, VERR_OUT_OF_RANGE);
-    AssertMsgReturn(!(GCPhys & X86_PAGE_OFFSET_MASK), ("%RGp\n", GCPhys), VERR_OUT_OF_RANGE);
-    AssertReturn(GCPhys < _1E, VERR_OUT_OF_RANGE);
-
-    /*
-     * Compose and make the hypercall.
-     */
-    HV_INPUT_UNMAP_GPA_PAGES *pUnmapPages = (HV_INPUT_UNMAP_GPA_PAGES *)pGVCpu->nemr0.s.HypercallData.pbPage;
-    AssertPtrReturn(pUnmapPages, VERR_INTERNAL_ERROR_3);
-    pUnmapPages->TargetPartitionId    = pGVM->nemr0.s.idHvPartition;
-    pUnmapPages->TargetGpaBase        = GCPhys >> X86_PAGE_SHIFT;
-    pUnmapPages->fFlags               = 0;
-
-    uint64_t uResult = g_pfnHvlInvokeHypercall(HvCallUnmapGpaPages | ((uint64_t)cPages << 32),
-                                               pGVCpu->nemr0.s.HypercallData.HCPhysPage, 0);
-    Log6(("NEMR0UnmapPages: %RGp L %u -> %#RX64\n", GCPhys, cPages, uResult));
-    if (uResult == ((uint64_t)cPages << 32))
-    {
-# if 1       /* Do we need to do this? Hopefully not... */
-        uint64_t volatile uR = g_pfnHvlInvokeHypercall(HvCallUncommitGpaPages | ((uint64_t)cPages << 32),
-                                                       pGVCpu->nemr0.s.HypercallData.HCPhysPage, 0);
-        AssertMsg(uR == ((uint64_t)cPages << 32), ("uR=%#RX64\n", uR)); NOREF(uR);
-# endif
-        return VINF_SUCCESS;
-    }
-
-    LogRel(("g_pfnHvlInvokeHypercall/UnmapGpaPages -> %#RX64\n", uResult));
-    return VERR_NEM_UNMAP_PAGES_FAILED;
-}
-#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
+}
 
 
@@ -1172,711 +172,7 @@
 VMMR0_INT_DECL(int) NEMR0UnmapPages(PGVM pGVM, VMCPUID idCpu)
 {
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    /*
-     * Unpack the call.
-     */
-    int rc = GVMMR0ValidateGVMandEMT(pGVM, idCpu);
-    if (RT_SUCCESS(rc))
-    {
-        PGVMCPU pGVCpu = &pGVM->aCpus[idCpu];
-
-        RTGCPHYS const GCPhys = pGVCpu->nem.s.Hypercall.UnmapPages.GCPhys;
-        uint32_t const cPages = pGVCpu->nem.s.Hypercall.UnmapPages.cPages;
-
-        /*
-         * Do the work.
-         */
-        rc = nemR0WinUnmapPages(pGVM, pGVCpu, GCPhys, cPages);
-    }
-    return rc;
-#else
     RT_NOREF(pGVM, idCpu);
     return  VERR_NOT_IMPLEMENTED;
-#endif
-}
-
-
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
-/**
- * Worker for NEMR0ExportState.
- *
- * Intention is to use it internally later.
- *
- * @returns VBox status code.
- * @param   pGVM        The ring-0 VM handle.
- * @param   pGVCpu      The ring-0 VCPU handle.
- * @param   pCtx        The CPU context structure to import into.
- */
-NEM_TMPL_STATIC int nemR0WinExportState(PGVM pGVM, PGVMCPU pGVCpu, PCPUMCTX pCtx)
-{
-    HV_INPUT_SET_VP_REGISTERS *pInput = (HV_INPUT_SET_VP_REGISTERS *)pGVCpu->nemr0.s.HypercallData.pbPage;
-    AssertPtrReturn(pInput, VERR_INTERNAL_ERROR_3);
-    AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-
-    pInput->PartitionId = pGVM->nemr0.s.idHvPartition;
-    pInput->VpIndex     = pGVCpu->idCpu;
-    pInput->RsvdZ       = 0;
-
-    uint64_t const fWhat = ~pCtx->fExtrn & (CPUMCTX_EXTRN_ALL | CPUMCTX_EXTRN_NEM_WIN_MASK);
-    if (   !fWhat
-        && pGVCpu->nem.s.fCurrentInterruptWindows == pGVCpu->nem.s.fDesiredInterruptWindows)
-        return VINF_SUCCESS;
-    uintptr_t iReg = 0;
-
-    /* GPRs */
-    if (fWhat & CPUMCTX_EXTRN_GPRS_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_RAX)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterRax;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->rax;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RCX)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterRcx;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->rcx;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RDX)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterRdx;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->rdx;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RBX)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterRbx;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->rbx;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RSP)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterRsp;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->rsp;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RBP)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterRbp;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->rbp;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RSI)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterRsi;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->rsi;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RDI)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterRdi;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->rdi;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_R8_R15)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterR8;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->r8;
-            iReg++;
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterR9;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->r9;
-            iReg++;
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterR10;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->r10;
-            iReg++;
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterR11;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->r11;
-            iReg++;
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterR12;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->r12;
-            iReg++;
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterR13;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->r13;
-            iReg++;
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterR14;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->r14;
-            iReg++;
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                = HvX64RegisterR15;
-            pInput->Elements[iReg].Value.Reg64         = pCtx->r15;
-            iReg++;
-        }
-    }
-
-    /* RIP & Flags */
-    if (fWhat & CPUMCTX_EXTRN_RIP)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                = HvX64RegisterRip;
-        pInput->Elements[iReg].Value.Reg64         = pCtx->rip;
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_RFLAGS)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                = HvX64RegisterRflags;
-        pInput->Elements[iReg].Value.Reg64         = pCtx->rflags.u;
-        iReg++;
-    }
-
-    /* Segments */
-# define COPY_OUT_SEG(a_idx, a_enmName, a_SReg) \
-        do { \
-            HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[a_idx]); \
-            pInput->Elements[a_idx].Name                     = a_enmName; \
-            pInput->Elements[a_idx].Value.Segment.Base       = (a_SReg).u64Base; \
-            pInput->Elements[a_idx].Value.Segment.Limit      = (a_SReg).u32Limit; \
-            pInput->Elements[a_idx].Value.Segment.Selector   = (a_SReg).Sel; \
-            pInput->Elements[a_idx].Value.Segment.Attributes = (a_SReg).Attr.u; \
-        } while (0)
-    if (fWhat & CPUMCTX_EXTRN_SREG_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_CS)
-        {
-            COPY_OUT_SEG(iReg, HvX64RegisterCs,   pCtx->cs);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_ES)
-        {
-            COPY_OUT_SEG(iReg, HvX64RegisterEs,   pCtx->es);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_SS)
-        {
-            COPY_OUT_SEG(iReg, HvX64RegisterSs,   pCtx->ss);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_DS)
-        {
-            COPY_OUT_SEG(iReg, HvX64RegisterDs,   pCtx->ds);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_FS)
-        {
-            COPY_OUT_SEG(iReg, HvX64RegisterFs,   pCtx->fs);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_GS)
-        {
-            COPY_OUT_SEG(iReg, HvX64RegisterGs,   pCtx->gs);
-            iReg++;
-        }
-    }
-
-    /* Descriptor tables & task segment. */
-    if (fWhat & CPUMCTX_EXTRN_TABLE_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_LDTR)
-        {
-            COPY_OUT_SEG(iReg, HvX64RegisterLdtr, pCtx->ldtr);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_TR)
-        {
-            COPY_OUT_SEG(iReg, HvX64RegisterTr,   pCtx->tr);
-            iReg++;
-        }
-
-        if (fWhat & CPUMCTX_EXTRN_IDTR)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Value.Table.Pad[0]   = 0;
-            pInput->Elements[iReg].Value.Table.Pad[1]   = 0;
-            pInput->Elements[iReg].Value.Table.Pad[2]   = 0;
-            pInput->Elements[iReg].Name                 = HvX64RegisterIdtr;
-            pInput->Elements[iReg].Value.Table.Limit    = pCtx->idtr.cbIdt;
-            pInput->Elements[iReg].Value.Table.Base     = pCtx->idtr.pIdt;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_GDTR)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Value.Table.Pad[0]   = 0;
-            pInput->Elements[iReg].Value.Table.Pad[1]   = 0;
-            pInput->Elements[iReg].Value.Table.Pad[2]   = 0;
-            pInput->Elements[iReg].Name                 = HvX64RegisterGdtr;
-            pInput->Elements[iReg].Value.Table.Limit    = pCtx->gdtr.cbGdt;
-            pInput->Elements[iReg].Value.Table.Base     = pCtx->gdtr.pGdt;
-            iReg++;
-        }
-    }
-
-    /* Control registers. */
-    if (fWhat & CPUMCTX_EXTRN_CR_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_CR0)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                 = HvX64RegisterCr0;
-            pInput->Elements[iReg].Value.Reg64          = pCtx->cr0;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_CR2)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                 = HvX64RegisterCr2;
-            pInput->Elements[iReg].Value.Reg64          = pCtx->cr2;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_CR3)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                 = HvX64RegisterCr3;
-            pInput->Elements[iReg].Value.Reg64          = pCtx->cr3;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_CR4)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                 = HvX64RegisterCr4;
-            pInput->Elements[iReg].Value.Reg64          = pCtx->cr4;
-            iReg++;
-        }
-    }
-    if (fWhat & CPUMCTX_EXTRN_APIC_TPR)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterCr8;
-        pInput->Elements[iReg].Value.Reg64          = CPUMGetGuestCR8(pGVCpu);
-        iReg++;
-    }
-
-    /** @todo does HvX64RegisterXfem mean XCR0? What about the related MSR. */
-
-    /* Debug registers. */
-/** @todo fixme. Figure out what the hyper-v version of KVM_SET_GUEST_DEBUG would be. */
-    if (fWhat & CPUMCTX_EXTRN_DR0_DR3)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterDr0;
-        //pInput->Elements[iReg].Value.Reg64        = CPUMGetHyperDR0(pGVCpu);
-        pInput->Elements[iReg].Value.Reg64          = pCtx->dr[0];
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterDr1;
-        //pInput->Elements[iReg].Value.Reg64        = CPUMGetHyperDR1(pGVCpu);
-        pInput->Elements[iReg].Value.Reg64          = pCtx->dr[1];
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterDr2;
-        //pInput->Elements[iReg].Value.Reg64        = CPUMGetHyperDR2(pGVCpu);
-        pInput->Elements[iReg].Value.Reg64          = pCtx->dr[2];
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterDr3;
-        //pInput->Elements[iReg].Value.Reg64        = CPUMGetHyperDR3(pGVCpu);
-        pInput->Elements[iReg].Value.Reg64          = pCtx->dr[3];
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_DR6)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterDr6;
-        //pInput->Elements[iReg].Value.Reg64        = CPUMGetHyperDR6(pGVCpu);
-        pInput->Elements[iReg].Value.Reg64          = pCtx->dr[6];
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_DR7)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterDr7;
-        //pInput->Elements[iReg].Value.Reg64        = CPUMGetHyperDR7(pGVCpu);
-        pInput->Elements[iReg].Value.Reg64          = pCtx->dr[7];
-        iReg++;
-    }
-
-    /* Floating point state. */
-    if (fWhat & CPUMCTX_EXTRN_X87)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                      = HvX64RegisterFpMmx0;
-        pInput->Elements[iReg].Value.Fp.AsUINT128.Low64  = pCtx->XState.x87.aRegs[0].au64[0];
-        pInput->Elements[iReg].Value.Fp.AsUINT128.High64 = pCtx->XState.x87.aRegs[0].au64[1];
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                      = HvX64RegisterFpMmx1;
-        pInput->Elements[iReg].Value.Fp.AsUINT128.Low64  = pCtx->XState.x87.aRegs[1].au64[0];
-        pInput->Elements[iReg].Value.Fp.AsUINT128.High64 = pCtx->XState.x87.aRegs[1].au64[1];
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                      = HvX64RegisterFpMmx2;
-        pInput->Elements[iReg].Value.Fp.AsUINT128.Low64  = pCtx->XState.x87.aRegs[2].au64[0];
-        pInput->Elements[iReg].Value.Fp.AsUINT128.High64 = pCtx->XState.x87.aRegs[2].au64[1];
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                      = HvX64RegisterFpMmx3;
-        pInput->Elements[iReg].Value.Fp.AsUINT128.Low64  = pCtx->XState.x87.aRegs[3].au64[0];
-        pInput->Elements[iReg].Value.Fp.AsUINT128.High64 = pCtx->XState.x87.aRegs[3].au64[1];
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                      = HvX64RegisterFpMmx4;
-        pInput->Elements[iReg].Value.Fp.AsUINT128.Low64  = pCtx->XState.x87.aRegs[4].au64[0];
-        pInput->Elements[iReg].Value.Fp.AsUINT128.High64 = pCtx->XState.x87.aRegs[4].au64[1];
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                      = HvX64RegisterFpMmx5;
-        pInput->Elements[iReg].Value.Fp.AsUINT128.Low64  = pCtx->XState.x87.aRegs[5].au64[0];
-        pInput->Elements[iReg].Value.Fp.AsUINT128.High64 = pCtx->XState.x87.aRegs[5].au64[1];
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                      = HvX64RegisterFpMmx6;
-        pInput->Elements[iReg].Value.Fp.AsUINT128.Low64  = pCtx->XState.x87.aRegs[6].au64[0];
-        pInput->Elements[iReg].Value.Fp.AsUINT128.High64 = pCtx->XState.x87.aRegs[6].au64[1];
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                      = HvX64RegisterFpMmx7;
-        pInput->Elements[iReg].Value.Fp.AsUINT128.Low64  = pCtx->XState.x87.aRegs[7].au64[0];
-        pInput->Elements[iReg].Value.Fp.AsUINT128.High64 = pCtx->XState.x87.aRegs[7].au64[1];
-        iReg++;
-
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                            = HvX64RegisterFpControlStatus;
-        pInput->Elements[iReg].Value.FpControlStatus.FpControl = pCtx->XState.x87.FCW;
-        pInput->Elements[iReg].Value.FpControlStatus.FpStatus  = pCtx->XState.x87.FSW;
-        pInput->Elements[iReg].Value.FpControlStatus.FpTag     = pCtx->XState.x87.FTW;
-        pInput->Elements[iReg].Value.FpControlStatus.Reserved  = pCtx->XState.x87.FTW >> 8;
-        pInput->Elements[iReg].Value.FpControlStatus.LastFpOp  = pCtx->XState.x87.FOP;
-        pInput->Elements[iReg].Value.FpControlStatus.LastFpRip = (pCtx->XState.x87.FPUIP)
-                                                               | ((uint64_t)pCtx->XState.x87.CS << 32)
-                                                               | ((uint64_t)pCtx->XState.x87.Rsrvd1 << 48);
-        iReg++;
-/** @todo we've got trouble if if we try write just SSE w/o X87.  */
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                                        = HvX64RegisterXmmControlStatus;
-        pInput->Elements[iReg].Value.XmmControlStatus.LastFpRdp            = (pCtx->XState.x87.FPUDP)
-                                                                           | ((uint64_t)pCtx->XState.x87.DS << 32)
-                                                                           | ((uint64_t)pCtx->XState.x87.Rsrvd2 << 48);
-        pInput->Elements[iReg].Value.XmmControlStatus.XmmStatusControl     = pCtx->XState.x87.MXCSR;
-        pInput->Elements[iReg].Value.XmmControlStatus.XmmStatusControlMask = pCtx->XState.x87.MXCSR_MASK; /** @todo ??? (Isn't this an output field?) */
-        iReg++;
-    }
-
-    /* Vector state. */
-    if (fWhat & CPUMCTX_EXTRN_SSE_AVX)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm0;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[0].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[0].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm1;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[1].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[1].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm2;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[2].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[2].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm3;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[3].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[3].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm4;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[4].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[4].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm5;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[5].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[5].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm6;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[6].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[6].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm7;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[7].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[7].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm8;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[8].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[8].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm9;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[9].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[9].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm10;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[10].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[10].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm11;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[11].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[11].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm12;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[12].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[12].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm13;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[13].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[13].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm14;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[14].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[14].uXmm.s.Hi;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterXmm15;
-        pInput->Elements[iReg].Value.Reg128.Low64   = pCtx->XState.x87.aXMM[15].uXmm.s.Lo;
-        pInput->Elements[iReg].Value.Reg128.High64  = pCtx->XState.x87.aXMM[15].uXmm.s.Hi;
-        iReg++;
-    }
-
-    /* MSRs */
-    // HvX64RegisterTsc - don't touch
-    if (fWhat & CPUMCTX_EXTRN_EFER)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterEfer;
-        pInput->Elements[iReg].Value.Reg64          = pCtx->msrEFER;
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_KERNEL_GS_BASE)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterKernelGsBase;
-        pInput->Elements[iReg].Value.Reg64          = pCtx->msrKERNELGSBASE;
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_SYSENTER_MSRS)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterSysenterCs;
-        pInput->Elements[iReg].Value.Reg64          = pCtx->SysEnter.cs;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterSysenterEip;
-        pInput->Elements[iReg].Value.Reg64          = pCtx->SysEnter.eip;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterSysenterEsp;
-        pInput->Elements[iReg].Value.Reg64          = pCtx->SysEnter.esp;
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_SYSCALL_MSRS)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterStar;
-        pInput->Elements[iReg].Value.Reg64          = pCtx->msrSTAR;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterLstar;
-        pInput->Elements[iReg].Value.Reg64          = pCtx->msrLSTAR;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterCstar;
-        pInput->Elements[iReg].Value.Reg64          = pCtx->msrCSTAR;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterSfmask;
-        pInput->Elements[iReg].Value.Reg64          = pCtx->msrSFMASK;
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_TSC_AUX)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterTscAux;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.TscAux;
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_OTHER_MSRS)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterApicBase;
-        pInput->Elements[iReg].Value.Reg64          = APICGetBaseMsrNoCheck(pGVCpu);
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterPat;
-        pInput->Elements[iReg].Value.Reg64          = pCtx->msrPAT;
-        iReg++;
-# if 0 /** @todo HvX64RegisterMtrrCap is read only?  Seems it's not even readable. */
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrCap;
-        pInput->Elements[iReg].Value.Reg64          = CPUMGetGuestIa32MtrrCap(pGVCpu);
-        iReg++;
-# endif
-
-        PCPUMCTXMSRS pCtxMsrs = CPUMQueryGuestCtxMsrsPtr(pGVCpu);
-
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrDefType;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrDefType;
-        iReg++;
-
-        /** @todo we dont keep state for HvX64RegisterMtrrPhysBaseX and HvX64RegisterMtrrPhysMaskX */
-
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrFix64k00000;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix64K_00000;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrFix16k80000;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix16K_80000;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrFix16kA0000;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix16K_A0000;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrFix4kC0000;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix4K_C0000;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrFix4kC8000;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix4K_C8000;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrFix4kD0000;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix4K_D0000;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrFix4kD8000;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix4K_D8000;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrFix4kE0000;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix4K_E0000;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrFix4kE8000;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix4K_E8000;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrFix4kF0000;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix4K_F0000;
-        iReg++;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvX64RegisterMtrrFix4kF8000;
-        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix4K_F8000;
-        iReg++;
-
-# if 0 /** @todo Why can't we write these on Intel systems? Not that we really care... */
-        const CPUMCPUVENDOR enmCpuVendor = CPUMGetHostCpuVendor(pGVM);
-        if (enmCpuVendor != CPUMCPUVENDOR_AMD)
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                 = HvX64RegisterIa32MiscEnable;
-            pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MiscEnable;
-            iReg++;
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                 = HvX64RegisterIa32FeatureControl;
-            pInput->Elements[iReg].Value.Reg64          = CPUMGetGuestIa32FeatureControl(pGVCpu);
-            iReg++;
-        }
-# endif
-    }
-
-    /* event injection (clear it). */
-    if (fWhat & CPUMCTX_EXTRN_NEM_WIN_EVENT_INJECT)
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvRegisterPendingInterruption;
-        pInput->Elements[iReg].Value.Reg64          = 0;
-        iReg++;
-    }
-
-    /* Interruptibility state.  This can get a little complicated since we get
-       half of the state via HV_X64_VP_EXECUTION_STATE. */
-    if (   (fWhat & (CPUMCTX_EXTRN_INHIBIT_INT | CPUMCTX_EXTRN_INHIBIT_NMI))
-        ==          (CPUMCTX_EXTRN_INHIBIT_INT | CPUMCTX_EXTRN_INHIBIT_NMI) )
-    {
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                 = HvRegisterInterruptState;
-        pInput->Elements[iReg].Value.Reg64          = 0;
-        if (   VMCPU_FF_IS_SET(pGVCpu, VMCPU_FF_INHIBIT_INTERRUPTS)
-            && EMGetInhibitInterruptsPC(pGVCpu) == pCtx->rip)
-            pInput->Elements[iReg].Value.InterruptState.InterruptShadow = 1;
-        if (VMCPU_FF_IS_SET(pGVCpu, VMCPU_FF_BLOCK_NMIS))
-            pInput->Elements[iReg].Value.InterruptState.NmiMasked = 1;
-        iReg++;
-    }
-    else if (fWhat & CPUMCTX_EXTRN_INHIBIT_INT)
-    {
-        if (   pGVCpu->nem.s.fLastInterruptShadow
-            || (   VMCPU_FF_IS_SET(pGVCpu, VMCPU_FF_INHIBIT_INTERRUPTS)
-                && EMGetInhibitInterruptsPC(pGVCpu) == pCtx->rip))
-        {
-            HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-            pInput->Elements[iReg].Name                 = HvRegisterInterruptState;
-            pInput->Elements[iReg].Value.Reg64          = 0;
-            if (   VMCPU_FF_IS_SET(pGVCpu, VMCPU_FF_INHIBIT_INTERRUPTS)
-                && EMGetInhibitInterruptsPC(pGVCpu) == pCtx->rip)
-                pInput->Elements[iReg].Value.InterruptState.InterruptShadow = 1;
-            /** @todo Retrieve NMI state, currently assuming it's zero. (yes this may happen on I/O) */
-            //if (VMCPU_FF_IS_ANY_SET(pGVCpu, VMCPU_FF_BLOCK_NMIS))
-            //    pInput->Elements[iReg].Value.InterruptState.NmiMasked = 1;
-            iReg++;
-        }
-    }
-    else
-        Assert(!(fWhat & CPUMCTX_EXTRN_INHIBIT_NMI));
-
-    /* Interrupt windows. Always set if active as Hyper-V seems to be forgetful. */
-    uint8_t const fDesiredIntWin = pGVCpu->nem.s.fDesiredInterruptWindows;
-    if (   fDesiredIntWin
-        || pGVCpu->nem.s.fCurrentInterruptWindows != fDesiredIntWin)
-    {
-        pGVCpu->nem.s.fCurrentInterruptWindows = pGVCpu->nem.s.fDesiredInterruptWindows;
-        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
-        pInput->Elements[iReg].Name                                         = HvX64RegisterDeliverabilityNotifications;
-        pInput->Elements[iReg].Value.DeliverabilityNotifications.AsUINT64   = fDesiredIntWin;
-        Assert(pInput->Elements[iReg].Value.DeliverabilityNotifications.NmiNotification == RT_BOOL(fDesiredIntWin & NEM_WIN_INTW_F_NMI));
-        Assert(pInput->Elements[iReg].Value.DeliverabilityNotifications.InterruptNotification == RT_BOOL(fDesiredIntWin & NEM_WIN_INTW_F_REGULAR));
-        Assert(pInput->Elements[iReg].Value.DeliverabilityNotifications.InterruptPriority == (fDesiredIntWin & NEM_WIN_INTW_F_PRIO_MASK) >> NEM_WIN_INTW_F_PRIO_SHIFT);
-        iReg++;
-    }
-
-    /// @todo HvRegisterPendingEvent0
-    /// @todo HvRegisterPendingEvent1
-
-    /*
-     * Set the registers.
-     */
-    Assert((uintptr_t)&pInput->Elements[iReg] - (uintptr_t)pGVCpu->nemr0.s.HypercallData.pbPage < PAGE_SIZE); /* max is 127 */
-
-    /*
-     * Make the hypercall.
-     */
-    uint64_t uResult = g_pfnHvlInvokeHypercall(HV_MAKE_CALL_INFO(HvCallSetVpRegisters, iReg),
-                                               pGVCpu->nemr0.s.HypercallData.HCPhysPage, 0 /*GCPhysOutput*/);
-    AssertLogRelMsgReturn(uResult == HV_MAKE_CALL_REP_RET(iReg),
-                          ("uResult=%RX64 iRegs=%#x\n", uResult, iReg),
-                          VERR_NEM_SET_REGISTERS_FAILED);
-    //LogFlow(("nemR0WinExportState: uResult=%#RX64 iReg=%zu fWhat=%#018RX64 fExtrn=%#018RX64 -> %#018RX64\n", uResult, iReg, fWhat, pCtx->fExtrn,
-    //         pCtx->fExtrn | CPUMCTX_EXTRN_ALL | CPUMCTX_EXTRN_NEM_WIN_MASK | CPUMCTX_EXTRN_KEEPER_NEM ));
-    pCtx->fExtrn |= CPUMCTX_EXTRN_ALL | CPUMCTX_EXTRN_NEM_WIN_MASK | CPUMCTX_EXTRN_KEEPER_NEM;
-    return VINF_SUCCESS;
-}
-#endif /* NEM_WIN_WITH_RING0_RUNLOOP || NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS */
+}
 
 
@@ -1891,911 +187,7 @@
 VMMR0_INT_DECL(int)  NEMR0ExportState(PGVM pGVM, VMCPUID idCpu)
 {
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
-    /*
-     * Validate the call.
-     */
-    int rc = GVMMR0ValidateGVMandEMT(pGVM, idCpu);
-    if (RT_SUCCESS(rc))
-    {
-        PGVMCPU pGVCpu = &pGVM->aCpus[idCpu];
-        AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-
-        /*
-         * Call worker.
-         */
-        rc = nemR0WinExportState(pGVM, pGVCpu, &pGVCpu->cpum.GstCtx);
-    }
-    return rc;
-#else
-    RT_NOREF(pGVM, idCpu);
-    return VERR_NOT_IMPLEMENTED;
-#endif
-}
-
-
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
-/**
- * Worker for NEMR0ImportState.
- *
- * Intention is to use it internally later.
- *
- * @returns VBox status code.
- * @param   pGVM            The ring-0 VM handle.
- * @param   pGVCpu          The ring-0 VCPU handle.
- * @param   pCtx            The CPU context structure to import into.
- * @param   fWhat           What to import, CPUMCTX_EXTRN_XXX.
- * @param   fCanUpdateCr3   Whether it's safe to update CR3 or not.
- */
-NEM_TMPL_STATIC int nemR0WinImportState(PGVM pGVM, PGVMCPU pGVCpu, PCPUMCTX pCtx, uint64_t fWhat, bool fCanUpdateCr3)
-{
-    HV_INPUT_GET_VP_REGISTERS *pInput = (HV_INPUT_GET_VP_REGISTERS *)pGVCpu->nemr0.s.HypercallData.pbPage;
-    AssertPtrReturn(pInput, VERR_INTERNAL_ERROR_3);
-    AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-    Assert(pCtx == &pGVCpu->cpum.GstCtx);
-
-    fWhat &= pCtx->fExtrn;
-
-    pInput->PartitionId = pGVM->nemr0.s.idHvPartition;
-    pInput->VpIndex     = pGVCpu->idCpu;
-    pInput->fFlags      = 0;
-
-    /* GPRs */
-    uintptr_t iReg = 0;
-    if (fWhat & CPUMCTX_EXTRN_GPRS_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_RAX)
-            pInput->Names[iReg++] = HvX64RegisterRax;
-        if (fWhat & CPUMCTX_EXTRN_RCX)
-            pInput->Names[iReg++] = HvX64RegisterRcx;
-        if (fWhat & CPUMCTX_EXTRN_RDX)
-            pInput->Names[iReg++] = HvX64RegisterRdx;
-        if (fWhat & CPUMCTX_EXTRN_RBX)
-            pInput->Names[iReg++] = HvX64RegisterRbx;
-        if (fWhat & CPUMCTX_EXTRN_RSP)
-            pInput->Names[iReg++] = HvX64RegisterRsp;
-        if (fWhat & CPUMCTX_EXTRN_RBP)
-            pInput->Names[iReg++] = HvX64RegisterRbp;
-        if (fWhat & CPUMCTX_EXTRN_RSI)
-            pInput->Names[iReg++] = HvX64RegisterRsi;
-        if (fWhat & CPUMCTX_EXTRN_RDI)
-            pInput->Names[iReg++] = HvX64RegisterRdi;
-        if (fWhat & CPUMCTX_EXTRN_R8_R15)
-        {
-            pInput->Names[iReg++] = HvX64RegisterR8;
-            pInput->Names[iReg++] = HvX64RegisterR9;
-            pInput->Names[iReg++] = HvX64RegisterR10;
-            pInput->Names[iReg++] = HvX64RegisterR11;
-            pInput->Names[iReg++] = HvX64RegisterR12;
-            pInput->Names[iReg++] = HvX64RegisterR13;
-            pInput->Names[iReg++] = HvX64RegisterR14;
-            pInput->Names[iReg++] = HvX64RegisterR15;
-        }
-    }
-
-    /* RIP & Flags */
-    if (fWhat & CPUMCTX_EXTRN_RIP)
-        pInput->Names[iReg++]  = HvX64RegisterRip;
-    if (fWhat & CPUMCTX_EXTRN_RFLAGS)
-        pInput->Names[iReg++] = HvX64RegisterRflags;
-
-    /* Segments */
-    if (fWhat & CPUMCTX_EXTRN_SREG_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_CS)
-            pInput->Names[iReg++] = HvX64RegisterCs;
-        if (fWhat & CPUMCTX_EXTRN_ES)
-            pInput->Names[iReg++] = HvX64RegisterEs;
-        if (fWhat & CPUMCTX_EXTRN_SS)
-            pInput->Names[iReg++] = HvX64RegisterSs;
-        if (fWhat & CPUMCTX_EXTRN_DS)
-            pInput->Names[iReg++] = HvX64RegisterDs;
-        if (fWhat & CPUMCTX_EXTRN_FS)
-            pInput->Names[iReg++] = HvX64RegisterFs;
-        if (fWhat & CPUMCTX_EXTRN_GS)
-            pInput->Names[iReg++] = HvX64RegisterGs;
-    }
-
-    /* Descriptor tables and the task segment. */
-    if (fWhat & CPUMCTX_EXTRN_TABLE_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_LDTR)
-            pInput->Names[iReg++] = HvX64RegisterLdtr;
-        if (fWhat & CPUMCTX_EXTRN_TR)
-            pInput->Names[iReg++] = HvX64RegisterTr;
-        if (fWhat & CPUMCTX_EXTRN_IDTR)
-            pInput->Names[iReg++] = HvX64RegisterIdtr;
-        if (fWhat & CPUMCTX_EXTRN_GDTR)
-            pInput->Names[iReg++] = HvX64RegisterGdtr;
-    }
-
-    /* Control registers. */
-    if (fWhat & CPUMCTX_EXTRN_CR_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_CR0)
-            pInput->Names[iReg++] = HvX64RegisterCr0;
-        if (fWhat & CPUMCTX_EXTRN_CR2)
-            pInput->Names[iReg++] = HvX64RegisterCr2;
-        if (fWhat & CPUMCTX_EXTRN_CR3)
-            pInput->Names[iReg++] = HvX64RegisterCr3;
-        if (fWhat & CPUMCTX_EXTRN_CR4)
-            pInput->Names[iReg++] = HvX64RegisterCr4;
-    }
-    if (fWhat & CPUMCTX_EXTRN_APIC_TPR)
-        pInput->Names[iReg++] = HvX64RegisterCr8;
-
-    /* Debug registers. */
-    if (fWhat & CPUMCTX_EXTRN_DR7)
-        pInput->Names[iReg++] = HvX64RegisterDr7;
-    if (fWhat & CPUMCTX_EXTRN_DR0_DR3)
-    {
-        if (!(fWhat & CPUMCTX_EXTRN_DR7) && (pCtx->fExtrn & CPUMCTX_EXTRN_DR7))
-        {
-            fWhat |= CPUMCTX_EXTRN_DR7;
-            pInput->Names[iReg++] = HvX64RegisterDr7;
-        }
-        pInput->Names[iReg++] = HvX64RegisterDr0;
-        pInput->Names[iReg++] = HvX64RegisterDr1;
-        pInput->Names[iReg++] = HvX64RegisterDr2;
-        pInput->Names[iReg++] = HvX64RegisterDr3;
-    }
-    if (fWhat & CPUMCTX_EXTRN_DR6)
-        pInput->Names[iReg++] = HvX64RegisterDr6;
-
-    /* Floating point state. */
-    if (fWhat & CPUMCTX_EXTRN_X87)
-    {
-        pInput->Names[iReg++] = HvX64RegisterFpMmx0;
-        pInput->Names[iReg++] = HvX64RegisterFpMmx1;
-        pInput->Names[iReg++] = HvX64RegisterFpMmx2;
-        pInput->Names[iReg++] = HvX64RegisterFpMmx3;
-        pInput->Names[iReg++] = HvX64RegisterFpMmx4;
-        pInput->Names[iReg++] = HvX64RegisterFpMmx5;
-        pInput->Names[iReg++] = HvX64RegisterFpMmx6;
-        pInput->Names[iReg++] = HvX64RegisterFpMmx7;
-        pInput->Names[iReg++] = HvX64RegisterFpControlStatus;
-    }
-    if (fWhat & (CPUMCTX_EXTRN_X87 | CPUMCTX_EXTRN_SSE_AVX))
-        pInput->Names[iReg++] = HvX64RegisterXmmControlStatus;
-
-    /* Vector state. */
-    if (fWhat & CPUMCTX_EXTRN_SSE_AVX)
-    {
-        pInput->Names[iReg++] = HvX64RegisterXmm0;
-        pInput->Names[iReg++] = HvX64RegisterXmm1;
-        pInput->Names[iReg++] = HvX64RegisterXmm2;
-        pInput->Names[iReg++] = HvX64RegisterXmm3;
-        pInput->Names[iReg++] = HvX64RegisterXmm4;
-        pInput->Names[iReg++] = HvX64RegisterXmm5;
-        pInput->Names[iReg++] = HvX64RegisterXmm6;
-        pInput->Names[iReg++] = HvX64RegisterXmm7;
-        pInput->Names[iReg++] = HvX64RegisterXmm8;
-        pInput->Names[iReg++] = HvX64RegisterXmm9;
-        pInput->Names[iReg++] = HvX64RegisterXmm10;
-        pInput->Names[iReg++] = HvX64RegisterXmm11;
-        pInput->Names[iReg++] = HvX64RegisterXmm12;
-        pInput->Names[iReg++] = HvX64RegisterXmm13;
-        pInput->Names[iReg++] = HvX64RegisterXmm14;
-        pInput->Names[iReg++] = HvX64RegisterXmm15;
-    }
-
-    /* MSRs */
-    // HvX64RegisterTsc - don't touch
-    if (fWhat & CPUMCTX_EXTRN_EFER)
-        pInput->Names[iReg++] = HvX64RegisterEfer;
-    if (fWhat & CPUMCTX_EXTRN_KERNEL_GS_BASE)
-        pInput->Names[iReg++] = HvX64RegisterKernelGsBase;
-    if (fWhat & CPUMCTX_EXTRN_SYSENTER_MSRS)
-    {
-        pInput->Names[iReg++] = HvX64RegisterSysenterCs;
-        pInput->Names[iReg++] = HvX64RegisterSysenterEip;
-        pInput->Names[iReg++] = HvX64RegisterSysenterEsp;
-    }
-    if (fWhat & CPUMCTX_EXTRN_SYSCALL_MSRS)
-    {
-        pInput->Names[iReg++] = HvX64RegisterStar;
-        pInput->Names[iReg++] = HvX64RegisterLstar;
-        pInput->Names[iReg++] = HvX64RegisterCstar;
-        pInput->Names[iReg++] = HvX64RegisterSfmask;
-    }
-
-# ifdef LOG_ENABLED
-    const CPUMCPUVENDOR enmCpuVendor = CPUMGetHostCpuVendor(pGVM);
-# endif
-    if (fWhat & CPUMCTX_EXTRN_OTHER_MSRS)
-    {
-        pInput->Names[iReg++] = HvX64RegisterApicBase; /// @todo APIC BASE
-        pInput->Names[iReg++] = HvX64RegisterPat;
-# if 0 /*def LOG_ENABLED*/ /** @todo something's wrong with HvX64RegisterMtrrCap? (AMD) */
-        pInput->Names[iReg++] = HvX64RegisterMtrrCap;
-# endif
-        pInput->Names[iReg++] = HvX64RegisterMtrrDefType;
-        pInput->Names[iReg++] = HvX64RegisterMtrrFix64k00000;
-        pInput->Names[iReg++] = HvX64RegisterMtrrFix16k80000;
-        pInput->Names[iReg++] = HvX64RegisterMtrrFix16kA0000;
-        pInput->Names[iReg++] = HvX64RegisterMtrrFix4kC0000;
-        pInput->Names[iReg++] = HvX64RegisterMtrrFix4kC8000;
-        pInput->Names[iReg++] = HvX64RegisterMtrrFix4kD0000;
-        pInput->Names[iReg++] = HvX64RegisterMtrrFix4kD8000;
-        pInput->Names[iReg++] = HvX64RegisterMtrrFix4kE0000;
-        pInput->Names[iReg++] = HvX64RegisterMtrrFix4kE8000;
-        pInput->Names[iReg++] = HvX64RegisterMtrrFix4kF0000;
-        pInput->Names[iReg++] = HvX64RegisterMtrrFix4kF8000;
-        pInput->Names[iReg++] = HvX64RegisterTscAux;
-# if 0 /** @todo why can't we read HvX64RegisterIa32MiscEnable? */
-        if (enmCpuVendor != CPUMCPUVENDOR_AMD)
-            pInput->Names[iReg++] = HvX64RegisterIa32MiscEnable;
-# endif
-# ifdef LOG_ENABLED
-        if (enmCpuVendor != CPUMCPUVENDOR_AMD && enmCpuVendor != CPUMCPUVENDOR_HYGON)
-            pInput->Names[iReg++] = HvX64RegisterIa32FeatureControl;
-# endif
-    }
-
-    /* Interruptibility. */
-    if (fWhat & (CPUMCTX_EXTRN_INHIBIT_INT | CPUMCTX_EXTRN_INHIBIT_NMI))
-    {
-        pInput->Names[iReg++] = HvRegisterInterruptState;
-        pInput->Names[iReg++] = HvX64RegisterRip;
-    }
-
-    /* event injection */
-    pInput->Names[iReg++] = HvRegisterPendingInterruption;
-    pInput->Names[iReg++] = HvRegisterPendingEvent0;
-    pInput->Names[iReg++] = HvRegisterPendingEvent1;
-    size_t const cRegs   = iReg;
-    size_t const cbInput = RT_ALIGN_Z(RT_UOFFSETOF_DYN(HV_INPUT_GET_VP_REGISTERS, Names[cRegs]), 32);
-
-    HV_REGISTER_VALUE *paValues = (HV_REGISTER_VALUE *)((uint8_t *)pInput + cbInput);
-    Assert((uintptr_t)&paValues[cRegs] - (uintptr_t)pGVCpu->nemr0.s.HypercallData.pbPage < PAGE_SIZE); /* (max is around 168 registers) */
-    RT_BZERO(paValues, cRegs * sizeof(paValues[0]));
-
-    /*
-     * Make the hypercall.
-     */
-    uint64_t uResult = g_pfnHvlInvokeHypercall(HV_MAKE_CALL_INFO(HvCallGetVpRegisters, cRegs),
-                                               pGVCpu->nemr0.s.HypercallData.HCPhysPage,
-                                               pGVCpu->nemr0.s.HypercallData.HCPhysPage + cbInput);
-    AssertLogRelMsgReturn(uResult == HV_MAKE_CALL_REP_RET(cRegs),
-                          ("uResult=%RX64 cRegs=%#x\n", uResult, cRegs),
-                          VERR_NEM_GET_REGISTERS_FAILED);
-    //LogFlow(("nemR0WinImportState: uResult=%#RX64 iReg=%zu fWhat=%#018RX64 fExtr=%#018RX64\n", uResult, cRegs, fWhat, pCtx->fExtrn));
-
-    /*
-     * Copy information to the CPUM context.
-     */
-    iReg = 0;
-
-    /* GPRs */
-    if (fWhat & CPUMCTX_EXTRN_GPRS_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_RAX)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterRax);
-            pCtx->rax = paValues[iReg++].Reg64;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RCX)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterRcx);
-            pCtx->rcx = paValues[iReg++].Reg64;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RDX)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterRdx);
-            pCtx->rdx = paValues[iReg++].Reg64;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RBX)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterRbx);
-            pCtx->rbx = paValues[iReg++].Reg64;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RSP)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterRsp);
-            pCtx->rsp = paValues[iReg++].Reg64;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RBP)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterRbp);
-            pCtx->rbp = paValues[iReg++].Reg64;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RSI)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterRsi);
-            pCtx->rsi = paValues[iReg++].Reg64;
-        }
-        if (fWhat & CPUMCTX_EXTRN_RDI)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterRdi);
-            pCtx->rdi = paValues[iReg++].Reg64;
-        }
-        if (fWhat & CPUMCTX_EXTRN_R8_R15)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterR8);
-            Assert(pInput->Names[iReg + 7] == HvX64RegisterR15);
-            pCtx->r8  = paValues[iReg++].Reg64;
-            pCtx->r9  = paValues[iReg++].Reg64;
-            pCtx->r10 = paValues[iReg++].Reg64;
-            pCtx->r11 = paValues[iReg++].Reg64;
-            pCtx->r12 = paValues[iReg++].Reg64;
-            pCtx->r13 = paValues[iReg++].Reg64;
-            pCtx->r14 = paValues[iReg++].Reg64;
-            pCtx->r15 = paValues[iReg++].Reg64;
-        }
-    }
-
-    /* RIP & Flags */
-    if (fWhat & CPUMCTX_EXTRN_RIP)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterRip);
-        pCtx->rip      = paValues[iReg++].Reg64;
-    }
-    if (fWhat & CPUMCTX_EXTRN_RFLAGS)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterRflags);
-        pCtx->rflags.u = paValues[iReg++].Reg64;
-    }
-
-    /* Segments */
-# define COPY_BACK_SEG(a_idx, a_enmName, a_SReg) \
-        do { \
-            Assert(pInput->Names[a_idx] == a_enmName); \
-            (a_SReg).u64Base  = paValues[a_idx].Segment.Base; \
-            (a_SReg).u32Limit = paValues[a_idx].Segment.Limit; \
-            (a_SReg).ValidSel = (a_SReg).Sel = paValues[a_idx].Segment.Selector; \
-            (a_SReg).Attr.u   = paValues[a_idx].Segment.Attributes; \
-            (a_SReg).fFlags   = CPUMSELREG_FLAGS_VALID; \
-        } while (0)
-    if (fWhat & CPUMCTX_EXTRN_SREG_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_CS)
-        {
-            COPY_BACK_SEG(iReg, HvX64RegisterCs,   pCtx->cs);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_ES)
-        {
-            COPY_BACK_SEG(iReg, HvX64RegisterEs,   pCtx->es);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_SS)
-        {
-            COPY_BACK_SEG(iReg, HvX64RegisterSs,   pCtx->ss);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_DS)
-        {
-            COPY_BACK_SEG(iReg, HvX64RegisterDs,   pCtx->ds);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_FS)
-        {
-            COPY_BACK_SEG(iReg, HvX64RegisterFs,   pCtx->fs);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_GS)
-        {
-            COPY_BACK_SEG(iReg, HvX64RegisterGs,   pCtx->gs);
-            iReg++;
-        }
-    }
-    /* Descriptor tables and the task segment. */
-    if (fWhat & CPUMCTX_EXTRN_TABLE_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_LDTR)
-        {
-            COPY_BACK_SEG(iReg, HvX64RegisterLdtr, pCtx->ldtr);
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_TR)
-        {
-            /* AMD-V likes loading TR with in AVAIL state, whereas intel insists on BUSY.  So,
-               avoid to trigger sanity assertions around the code, always fix this. */
-            COPY_BACK_SEG(iReg, HvX64RegisterTr,   pCtx->tr);
-            switch (pCtx->tr.Attr.n.u4Type)
-            {
-                case X86_SEL_TYPE_SYS_386_TSS_BUSY:
-                case X86_SEL_TYPE_SYS_286_TSS_BUSY:
-                    break;
-                case X86_SEL_TYPE_SYS_386_TSS_AVAIL:
-                    pCtx->tr.Attr.n.u4Type = X86_SEL_TYPE_SYS_386_TSS_BUSY;
-                    break;
-                case X86_SEL_TYPE_SYS_286_TSS_AVAIL:
-                    pCtx->tr.Attr.n.u4Type = X86_SEL_TYPE_SYS_286_TSS_BUSY;
-                    break;
-            }
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_IDTR)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterIdtr);
-            pCtx->idtr.cbIdt = paValues[iReg].Table.Limit;
-            pCtx->idtr.pIdt  = paValues[iReg].Table.Base;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_GDTR)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterGdtr);
-            pCtx->gdtr.cbGdt = paValues[iReg].Table.Limit;
-            pCtx->gdtr.pGdt  = paValues[iReg].Table.Base;
-            iReg++;
-        }
-    }
-
-    /* Control registers. */
-    bool fMaybeChangedMode = false;
-    bool fUpdateCr3        = false;
-    if (fWhat & CPUMCTX_EXTRN_CR_MASK)
-    {
-        if (fWhat & CPUMCTX_EXTRN_CR0)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterCr0);
-            if (pCtx->cr0 != paValues[iReg].Reg64)
-            {
-                CPUMSetGuestCR0(pGVCpu, paValues[iReg].Reg64);
-                fMaybeChangedMode = true;
-            }
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_CR2)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterCr2);
-            pCtx->cr2 = paValues[iReg].Reg64;
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_CR3)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterCr3);
-            if (pCtx->cr3 != paValues[iReg].Reg64)
-            {
-                CPUMSetGuestCR3(pGVCpu, paValues[iReg].Reg64);
-                fUpdateCr3 = true;
-            }
-            iReg++;
-        }
-        if (fWhat & CPUMCTX_EXTRN_CR4)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterCr4);
-            if (pCtx->cr4 != paValues[iReg].Reg64)
-            {
-                CPUMSetGuestCR4(pGVCpu, paValues[iReg].Reg64);
-                fMaybeChangedMode = true;
-            }
-            iReg++;
-        }
-    }
-    if (fWhat & CPUMCTX_EXTRN_APIC_TPR)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterCr8);
-        APICSetTpr(pGVCpu, (uint8_t)paValues[iReg].Reg64 << 4);
-        iReg++;
-    }
-
-    /* Debug registers. */
-    if (fWhat & CPUMCTX_EXTRN_DR7)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterDr7);
-        if (pCtx->dr[7] != paValues[iReg].Reg64)
-            CPUMSetGuestDR7(pGVCpu, paValues[iReg].Reg64);
-        pCtx->fExtrn &= ~CPUMCTX_EXTRN_DR7; /* Hack alert! Avoids asserting when processing CPUMCTX_EXTRN_DR0_DR3. */
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_DR0_DR3)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterDr0);
-        Assert(pInput->Names[iReg+3] == HvX64RegisterDr3);
-        if (pCtx->dr[0] != paValues[iReg].Reg64)
-            CPUMSetGuestDR0(pGVCpu, paValues[iReg].Reg64);
-        iReg++;
-        if (pCtx->dr[1] != paValues[iReg].Reg64)
-            CPUMSetGuestDR1(pGVCpu, paValues[iReg].Reg64);
-        iReg++;
-        if (pCtx->dr[2] != paValues[iReg].Reg64)
-            CPUMSetGuestDR2(pGVCpu, paValues[iReg].Reg64);
-        iReg++;
-        if (pCtx->dr[3] != paValues[iReg].Reg64)
-            CPUMSetGuestDR3(pGVCpu, paValues[iReg].Reg64);
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_DR6)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterDr6);
-        if (pCtx->dr[6] != paValues[iReg].Reg64)
-            CPUMSetGuestDR6(pGVCpu, paValues[iReg].Reg64);
-        iReg++;
-    }
-
-    /* Floating point state. */
-    if (fWhat & CPUMCTX_EXTRN_X87)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterFpMmx0);
-        Assert(pInput->Names[iReg + 7] == HvX64RegisterFpMmx7);
-        pCtx->XState.x87.aRegs[0].au64[0] = paValues[iReg].Fp.AsUINT128.Low64;
-        pCtx->XState.x87.aRegs[0].au64[1] = paValues[iReg].Fp.AsUINT128.High64;
-        iReg++;
-        pCtx->XState.x87.aRegs[1].au64[0] = paValues[iReg].Fp.AsUINT128.Low64;
-        pCtx->XState.x87.aRegs[1].au64[1] = paValues[iReg].Fp.AsUINT128.High64;
-        iReg++;
-        pCtx->XState.x87.aRegs[2].au64[0] = paValues[iReg].Fp.AsUINT128.Low64;
-        pCtx->XState.x87.aRegs[2].au64[1] = paValues[iReg].Fp.AsUINT128.High64;
-        iReg++;
-        pCtx->XState.x87.aRegs[3].au64[0] = paValues[iReg].Fp.AsUINT128.Low64;
-        pCtx->XState.x87.aRegs[3].au64[1] = paValues[iReg].Fp.AsUINT128.High64;
-        iReg++;
-        pCtx->XState.x87.aRegs[4].au64[0] = paValues[iReg].Fp.AsUINT128.Low64;
-        pCtx->XState.x87.aRegs[4].au64[1] = paValues[iReg].Fp.AsUINT128.High64;
-        iReg++;
-        pCtx->XState.x87.aRegs[5].au64[0] = paValues[iReg].Fp.AsUINT128.Low64;
-        pCtx->XState.x87.aRegs[5].au64[1] = paValues[iReg].Fp.AsUINT128.High64;
-        iReg++;
-        pCtx->XState.x87.aRegs[6].au64[0] = paValues[iReg].Fp.AsUINT128.Low64;
-        pCtx->XState.x87.aRegs[6].au64[1] = paValues[iReg].Fp.AsUINT128.High64;
-        iReg++;
-        pCtx->XState.x87.aRegs[7].au64[0] = paValues[iReg].Fp.AsUINT128.Low64;
-        pCtx->XState.x87.aRegs[7].au64[1] = paValues[iReg].Fp.AsUINT128.High64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterFpControlStatus);
-        pCtx->XState.x87.FCW        = paValues[iReg].FpControlStatus.FpControl;
-        pCtx->XState.x87.FSW        = paValues[iReg].FpControlStatus.FpStatus;
-        pCtx->XState.x87.FTW        = paValues[iReg].FpControlStatus.FpTag
-                                        /*| (paValues[iReg].FpControlStatus.Reserved << 8)*/;
-        pCtx->XState.x87.FOP        = paValues[iReg].FpControlStatus.LastFpOp;
-        pCtx->XState.x87.FPUIP      = (uint32_t)paValues[iReg].FpControlStatus.LastFpRip;
-        pCtx->XState.x87.CS         = (uint16_t)(paValues[iReg].FpControlStatus.LastFpRip >> 32);
-        pCtx->XState.x87.Rsrvd1     = (uint16_t)(paValues[iReg].FpControlStatus.LastFpRip >> 48);
-        iReg++;
-    }
-
-    if (fWhat & (CPUMCTX_EXTRN_X87 | CPUMCTX_EXTRN_SSE_AVX))
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterXmmControlStatus);
-        if (fWhat & CPUMCTX_EXTRN_X87)
-        {
-            pCtx->XState.x87.FPUDP  = (uint32_t)paValues[iReg].XmmControlStatus.LastFpRdp;
-            pCtx->XState.x87.DS     = (uint16_t)(paValues[iReg].XmmControlStatus.LastFpRdp >> 32);
-            pCtx->XState.x87.Rsrvd2 = (uint16_t)(paValues[iReg].XmmControlStatus.LastFpRdp >> 48);
-        }
-        pCtx->XState.x87.MXCSR      = paValues[iReg].XmmControlStatus.XmmStatusControl;
-        pCtx->XState.x87.MXCSR_MASK = paValues[iReg].XmmControlStatus.XmmStatusControlMask; /** @todo ??? (Isn't this an output field?) */
-        iReg++;
-    }
-
-    /* Vector state. */
-    if (fWhat & CPUMCTX_EXTRN_SSE_AVX)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterXmm0);
-        Assert(pInput->Names[iReg+15] == HvX64RegisterXmm15);
-        pCtx->XState.x87.aXMM[0].uXmm.s.Lo  = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[0].uXmm.s.Hi  = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[1].uXmm.s.Lo  = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[1].uXmm.s.Hi  = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[2].uXmm.s.Lo  = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[2].uXmm.s.Hi  = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[3].uXmm.s.Lo  = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[3].uXmm.s.Hi  = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[4].uXmm.s.Lo  = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[4].uXmm.s.Hi  = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[5].uXmm.s.Lo  = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[5].uXmm.s.Hi  = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[6].uXmm.s.Lo  = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[6].uXmm.s.Hi  = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[7].uXmm.s.Lo  = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[7].uXmm.s.Hi  = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[8].uXmm.s.Lo  = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[8].uXmm.s.Hi  = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[9].uXmm.s.Lo  = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[9].uXmm.s.Hi  = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[10].uXmm.s.Lo = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[10].uXmm.s.Hi = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[11].uXmm.s.Lo = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[11].uXmm.s.Hi = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[12].uXmm.s.Lo = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[12].uXmm.s.Hi = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[13].uXmm.s.Lo = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[13].uXmm.s.Hi = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[14].uXmm.s.Lo = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[14].uXmm.s.Hi = paValues[iReg].Reg128.High64;
-        iReg++;
-        pCtx->XState.x87.aXMM[15].uXmm.s.Lo = paValues[iReg].Reg128.Low64;
-        pCtx->XState.x87.aXMM[15].uXmm.s.Hi = paValues[iReg].Reg128.High64;
-        iReg++;
-    }
-
-
-    /* MSRs */
-    // HvX64RegisterTsc - don't touch
-    if (fWhat & CPUMCTX_EXTRN_EFER)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterEfer);
-        if (paValues[iReg].Reg64 != pCtx->msrEFER)
-        {
-            Log7(("NEM/%u: MSR EFER changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtx->msrEFER, paValues[iReg].Reg64));
-            if ((paValues[iReg].Reg64 ^ pCtx->msrEFER) & MSR_K6_EFER_NXE)
-                PGMNotifyNxeChanged(pGVCpu, RT_BOOL(paValues[iReg].Reg64 & MSR_K6_EFER_NXE));
-            pCtx->msrEFER = paValues[iReg].Reg64;
-            fMaybeChangedMode = true;
-        }
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_KERNEL_GS_BASE)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterKernelGsBase);
-        if (pCtx->msrKERNELGSBASE != paValues[iReg].Reg64)
-            Log7(("NEM/%u: MSR KERNELGSBASE changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtx->msrKERNELGSBASE, paValues[iReg].Reg64));
-        pCtx->msrKERNELGSBASE = paValues[iReg].Reg64;
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_SYSENTER_MSRS)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterSysenterCs);
-        if (pCtx->SysEnter.cs != paValues[iReg].Reg64)
-            Log7(("NEM/%u: MSR SYSENTER.CS changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtx->SysEnter.cs, paValues[iReg].Reg64));
-        pCtx->SysEnter.cs = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterSysenterEip);
-        if (pCtx->SysEnter.eip != paValues[iReg].Reg64)
-            Log7(("NEM/%u: MSR SYSENTER.EIP changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtx->SysEnter.eip, paValues[iReg].Reg64));
-        pCtx->SysEnter.eip = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterSysenterEsp);
-        if (pCtx->SysEnter.esp != paValues[iReg].Reg64)
-            Log7(("NEM/%u: MSR SYSENTER.ESP changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtx->SysEnter.esp, paValues[iReg].Reg64));
-        pCtx->SysEnter.esp = paValues[iReg].Reg64;
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_SYSCALL_MSRS)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterStar);
-        if (pCtx->msrSTAR != paValues[iReg].Reg64)
-            Log7(("NEM/%u: MSR STAR changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtx->msrSTAR, paValues[iReg].Reg64));
-        pCtx->msrSTAR   = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterLstar);
-        if (pCtx->msrLSTAR != paValues[iReg].Reg64)
-            Log7(("NEM/%u: MSR LSTAR changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtx->msrLSTAR, paValues[iReg].Reg64));
-        pCtx->msrLSTAR  = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterCstar);
-        if (pCtx->msrCSTAR != paValues[iReg].Reg64)
-            Log7(("NEM/%u: MSR CSTAR changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtx->msrCSTAR, paValues[iReg].Reg64));
-        pCtx->msrCSTAR  = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterSfmask);
-        if (pCtx->msrSFMASK != paValues[iReg].Reg64)
-            Log7(("NEM/%u: MSR SFMASK changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtx->msrSFMASK, paValues[iReg].Reg64));
-        pCtx->msrSFMASK = paValues[iReg].Reg64;
-        iReg++;
-    }
-    if (fWhat & CPUMCTX_EXTRN_OTHER_MSRS)
-    {
-        Assert(pInput->Names[iReg] == HvX64RegisterApicBase);
-        const uint64_t uOldBase = APICGetBaseMsrNoCheck(pGVCpu);
-        if (paValues[iReg].Reg64 != uOldBase)
-        {
-            Log7(("NEM/%u: MSR APICBase changed %RX64 -> %RX64 (%RX64)\n",
-                  pGVCpu->idCpu, uOldBase, paValues[iReg].Reg64, paValues[iReg].Reg64 ^ uOldBase));
-            int rc2 = APICSetBaseMsr(pGVCpu, paValues[iReg].Reg64);
-            AssertLogRelMsg(rc2 == VINF_SUCCESS, ("rc2=%Rrc [%#RX64]\n", rc2, paValues[iReg].Reg64));
-        }
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterPat);
-        if (pCtx->msrPAT != paValues[iReg].Reg64)
-            Log7(("NEM/%u: MSR PAT changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtx->msrPAT, paValues[iReg].Reg64));
-        pCtx->msrPAT    = paValues[iReg].Reg64;
-        iReg++;
-
-# if 0 /*def LOG_ENABLED*/ /** @todo something's wrong with HvX64RegisterMtrrCap? (AMD) */
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrCap);
-        if (paValues[iReg].Reg64 != CPUMGetGuestIa32MtrrCap(pGVCpu))
-            Log7(("NEM/%u: MSR MTRR_CAP changed %RX64 -> %RX64 (!!)\n", pGVCpu->idCpu, CPUMGetGuestIa32MtrrCap(pGVCpu), paValues[iReg].Reg64));
-        iReg++;
-# endif
-
-        PCPUMCTXMSRS pCtxMsrs = CPUMQueryGuestCtxMsrsPtr(pGVCpu);
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrDefType);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrDefType )
-            Log7(("NEM/%u: MSR MTRR_DEF_TYPE changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrDefType, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrDefType = paValues[iReg].Reg64;
-        iReg++;
-
-        /** @todo we dont keep state for HvX64RegisterMtrrPhysBaseX and HvX64RegisterMtrrPhysMaskX */
-
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrFix64k00000);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrFix64K_00000 )
-            Log7(("NEM/%u: MSR MTRR_FIX16K_00000 changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrFix64K_00000, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrFix64K_00000 = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrFix16k80000);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrFix16K_80000 )
-            Log7(("NEM/%u: MSR MTRR_FIX16K_80000 changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrFix16K_80000, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrFix16K_80000 = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrFix16kA0000);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrFix16K_A0000 )
-            Log7(("NEM/%u: MSR MTRR_FIX16K_A0000 changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrFix16K_A0000, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrFix16K_A0000 = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrFix4kC0000);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrFix4K_C0000 )
-            Log7(("NEM/%u: MSR MTRR_FIX16K_C0000 changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrFix4K_C0000, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrFix4K_C0000 = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrFix4kC8000);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrFix4K_C8000 )
-            Log7(("NEM/%u: MSR MTRR_FIX16K_C8000 changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrFix4K_C8000, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrFix4K_C8000 = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrFix4kD0000);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrFix4K_D0000 )
-            Log7(("NEM/%u: MSR MTRR_FIX16K_D0000 changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrFix4K_D0000, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrFix4K_D0000 = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrFix4kD8000);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrFix4K_D8000 )
-            Log7(("NEM/%u: MSR MTRR_FIX16K_D8000 changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrFix4K_D8000, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrFix4K_D8000 = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrFix4kE0000);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrFix4K_E0000 )
-            Log7(("NEM/%u: MSR MTRR_FIX16K_E0000 changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrFix4K_E0000, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrFix4K_E0000 = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrFix4kE8000);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrFix4K_E8000 )
-            Log7(("NEM/%u: MSR MTRR_FIX16K_E8000 changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrFix4K_E8000, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrFix4K_E8000 = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrFix4kF0000);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrFix4K_F0000 )
-            Log7(("NEM/%u: MSR MTRR_FIX16K_F0000 changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrFix4K_F0000, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrFix4K_F0000 = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterMtrrFix4kF8000);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.MtrrFix4K_F8000 )
-            Log7(("NEM/%u: MSR MTRR_FIX16K_F8000 changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MtrrFix4K_F8000, paValues[iReg].Reg64));
-        pCtxMsrs->msr.MtrrFix4K_F8000 = paValues[iReg].Reg64;
-        iReg++;
-
-        Assert(pInput->Names[iReg] == HvX64RegisterTscAux);
-        if (paValues[iReg].Reg64 != pCtxMsrs->msr.TscAux )
-            Log7(("NEM/%u: MSR TSC_AUX changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.TscAux, paValues[iReg].Reg64));
-        pCtxMsrs->msr.TscAux = paValues[iReg].Reg64;
-        iReg++;
-
-# if 0 /** @todo why can't we even read HvX64RegisterIa32MiscEnable? */
-        if (enmCpuVendor != CPUMCPUVENDOR_AMD)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterIa32MiscEnable);
-            if (paValues[iReg].Reg64 != pCtxMsrs->msr.MiscEnable)
-                Log7(("NEM/%u: MSR MISC_ENABLE changed %RX64 -> %RX64\n", pGVCpu->idCpu, pCtxMsrs->msr.MiscEnable, paValues[iReg].Reg64));
-            pCtxMsrs->msr.MiscEnable = paValues[iReg].Reg64;
-            iReg++;
-        }
-# endif
-# ifdef LOG_ENABLED
-        if (enmCpuVendor != CPUMCPUVENDOR_AMD && enmCpuVendor != CPUMCPUVENDOR_HYGON)
-        {
-            Assert(pInput->Names[iReg] == HvX64RegisterIa32FeatureControl);
-            uint64_t const uFeatCtrl = CPUMGetGuestIa32FeatCtrl(pVCpu);
-            if (paValues[iReg].Reg64 != uFeatCtrl)
-                Log7(("NEM/%u: MSR FEATURE_CONTROL changed %RX64 -> %RX64 (!!)\n", pGVCpu->idCpu, uFeatCtrl, paValues[iReg].Reg64));
-            iReg++;
-        }
-# endif
-    }
-
-    /* Interruptibility. */
-    if (fWhat & (CPUMCTX_EXTRN_INHIBIT_INT | CPUMCTX_EXTRN_INHIBIT_NMI))
-    {
-        Assert(pInput->Names[iReg] == HvRegisterInterruptState);
-        Assert(pInput->Names[iReg + 1] == HvX64RegisterRip);
-
-        if (!(pCtx->fExtrn & CPUMCTX_EXTRN_INHIBIT_INT))
-        {
-            pGVCpu->nem.s.fLastInterruptShadow = paValues[iReg].InterruptState.InterruptShadow;
-            if (paValues[iReg].InterruptState.InterruptShadow)
-                EMSetInhibitInterruptsPC(pGVCpu, paValues[iReg + 1].Reg64);
-            else
-                VMCPU_FF_CLEAR(pGVCpu, VMCPU_FF_INHIBIT_INTERRUPTS);
-        }
-
-        if (!(pCtx->fExtrn & CPUMCTX_EXTRN_INHIBIT_NMI))
-        {
-            if (paValues[iReg].InterruptState.NmiMasked)
-                VMCPU_FF_SET(pGVCpu, VMCPU_FF_BLOCK_NMIS);
-            else
-                VMCPU_FF_CLEAR(pGVCpu, VMCPU_FF_BLOCK_NMIS);
-        }
-
-        fWhat |= CPUMCTX_EXTRN_INHIBIT_INT | CPUMCTX_EXTRN_INHIBIT_NMI;
-        iReg += 2;
-    }
-
-    /* Event injection. */
-    /// @todo HvRegisterPendingInterruption
-    Assert(pInput->Names[iReg] == HvRegisterPendingInterruption);
-    if (paValues[iReg].PendingInterruption.InterruptionPending)
-    {
-        Log7(("PendingInterruption: type=%u vector=%#x errcd=%RTbool/%#x instr-len=%u nested=%u\n",
-              paValues[iReg].PendingInterruption.InterruptionType, paValues[iReg].PendingInterruption.InterruptionVector,
-              paValues[iReg].PendingInterruption.DeliverErrorCode, paValues[iReg].PendingInterruption.ErrorCode,
-              paValues[iReg].PendingInterruption.InstructionLength, paValues[iReg].PendingInterruption.NestedEvent));
-        AssertMsg((paValues[iReg].PendingInterruption.AsUINT64 & UINT64_C(0xfc00)) == 0,
-                  ("%#RX64\n", paValues[iReg].PendingInterruption.AsUINT64));
-    }
-
-    /// @todo HvRegisterPendingEvent0
-    /// @todo HvRegisterPendingEvent1
-
-    /* Almost done, just update extrn flags and maybe change PGM mode. */
-    pCtx->fExtrn &= ~fWhat;
-    if (!(pCtx->fExtrn & (CPUMCTX_EXTRN_ALL | (CPUMCTX_EXTRN_NEM_WIN_MASK & ~CPUMCTX_EXTRN_NEM_WIN_EVENT_INJECT))))
-        pCtx->fExtrn = 0;
-
-    /* Typical. */
-    if (!fMaybeChangedMode && !fUpdateCr3)
-        return VINF_SUCCESS;
-
-    /*
-     * Slow.
-     */
-    int rc = VINF_SUCCESS;
-    if (fMaybeChangedMode)
-    {
-        rc = PGMChangeMode(pGVCpu, pCtx->cr0, pCtx->cr4, pCtx->msrEFER, false /* fForce */);
-        AssertMsgReturn(rc == VINF_SUCCESS, ("rc=%Rrc\n", rc), RT_FAILURE_NP(rc) ? rc : VERR_NEM_IPE_1);
-    }
-
-    if (fUpdateCr3)
-    {
-        if (fCanUpdateCr3)
-        {
-            LogFlow(("nemR0WinImportState: -> PGMUpdateCR3!\n"));
-            rc = PGMUpdateCR3(pGVCpu, pCtx->cr3);
-            if (rc == VINF_SUCCESS)
-            { /* likely */ }
-            else
-                AssertMsgFailedReturn(("rc=%Rrc\n", rc), RT_FAILURE_NP(rc) ? rc : VERR_NEM_IPE_2);
-        }
-        else
-        {
-            LogFlow(("nemR0WinImportState: -> VERR_NEM_FLUSH_TLB!\n"));
-            rc = VERR_NEM_FLUSH_TLB; /* Calling PGMFlushTLB w/o long jump setup doesn't work, ring-3 does it. */
-        }
-    }
-
-    return rc;
-}
-#endif /* NEM_WIN_WITH_RING0_RUNLOOP || NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS */
+    RT_NOREF(pGVM, idCpu);
+    return VERR_NOT_IMPLEMENTED;
+}
 
 
@@ -2812,74 +204,7 @@
 VMMR0_INT_DECL(int) NEMR0ImportState(PGVM pGVM, VMCPUID idCpu, uint64_t fWhat)
 {
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
-    /*
-     * Validate the call.
-     */
-    int rc = GVMMR0ValidateGVMandEMT(pGVM, idCpu);
-    if (RT_SUCCESS(rc))
-    {
-        PGVMCPU pGVCpu = &pGVM->aCpus[idCpu];
-        AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-
-        /*
-         * Call worker.
-         */
-        rc = nemR0WinImportState(pGVM, pGVCpu, &pGVCpu->cpum.GstCtx, fWhat, false /*fCanUpdateCr3*/);
-    }
-    return rc;
-#else
     RT_NOREF(pGVM, idCpu, fWhat);
     return VERR_NOT_IMPLEMENTED;
-#endif
-}
-
-
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
-/**
- * Worker for NEMR0QueryCpuTick and the ring-0 NEMHCQueryCpuTick.
- *
- * @returns VBox status code.
- * @param   pGVM        The ring-0 VM handle.
- * @param   pGVCpu      The ring-0 VCPU handle.
- * @param   pcTicks     Where to return the current CPU tick count.
- * @param   pcAux       Where to return the hyper-V TSC_AUX value.  Optional.
- */
-NEM_TMPL_STATIC int nemR0WinQueryCpuTick(PGVM pGVM, PGVMCPU pGVCpu, uint64_t *pcTicks, uint32_t *pcAux)
-{
-    /*
-     * Hypercall parameters.
-     */
-    HV_INPUT_GET_VP_REGISTERS *pInput = (HV_INPUT_GET_VP_REGISTERS *)pGVCpu->nemr0.s.HypercallData.pbPage;
-    AssertPtrReturn(pInput, VERR_INTERNAL_ERROR_3);
-    AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-
-    pInput->PartitionId = pGVM->nemr0.s.idHvPartition;
-    pInput->VpIndex     = pGVCpu->idCpu;
-    pInput->fFlags      = 0;
-    pInput->Names[0]    = HvX64RegisterTsc;
-    pInput->Names[1]    = HvX64RegisterTscAux;
-
-    size_t const cbInput = RT_ALIGN_Z(RT_UOFFSETOF(HV_INPUT_GET_VP_REGISTERS, Names[2]), 32);
-    HV_REGISTER_VALUE *paValues = (HV_REGISTER_VALUE *)((uint8_t *)pInput + cbInput);
-    RT_BZERO(paValues, sizeof(paValues[0]) * 2);
-
-    /*
-     * Make the hypercall.
-     */
-    uint64_t uResult = g_pfnHvlInvokeHypercall(HV_MAKE_CALL_INFO(HvCallGetVpRegisters, 2),
-                                               pGVCpu->nemr0.s.HypercallData.HCPhysPage,
-                                               pGVCpu->nemr0.s.HypercallData.HCPhysPage + cbInput);
-    AssertLogRelMsgReturn(uResult == HV_MAKE_CALL_REP_RET(2), ("uResult=%RX64 cRegs=%#x\n", uResult, 2),
-                          VERR_NEM_GET_REGISTERS_FAILED);
-
-    /*
-     * Get results.
-     */
-    *pcTicks = paValues[0].Reg64;
-    if (pcAux)
-        *pcAux = paValues[0].Reg32;
-    return VINF_SUCCESS;
-}
-#endif /* NEM_WIN_WITH_RING0_RUNLOOP || NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS */
+}
 
 
@@ -2894,99 +219,7 @@
 VMMR0_INT_DECL(int) NEMR0QueryCpuTick(PGVM pGVM, VMCPUID idCpu)
 {
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
-    /*
-     * Validate the call.
-     */
-    int rc = GVMMR0ValidateGVMandEMT(pGVM, idCpu);
-    if (RT_SUCCESS(rc))
-    {
-        PGVMCPU pGVCpu = &pGVM->aCpus[idCpu];
-        AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-
-        /*
-         * Call worker.
-         */
-        pGVCpu->nem.s.Hypercall.QueryCpuTick.cTicks = 0;
-        pGVCpu->nem.s.Hypercall.QueryCpuTick.uAux   = 0;
-        rc = nemR0WinQueryCpuTick(pGVM, pGVCpu, &pGVCpu->nem.s.Hypercall.QueryCpuTick.cTicks,
-                                  &pGVCpu->nem.s.Hypercall.QueryCpuTick.uAux);
-    }
-    return rc;
-#else
-    RT_NOREF(pGVM, idCpu);
-    return VERR_NOT_IMPLEMENTED;
-#endif
-}
-
-
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
-/**
- * Worker for NEMR0ResumeCpuTickOnAll and the ring-0 NEMHCResumeCpuTickOnAll.
- *
- * @returns VBox status code.
- * @param   pGVM            The ring-0 VM handle.
- * @param   pGVCpu          The ring-0 VCPU handle.
- * @param   uPausedTscValue The TSC value at the time of pausing.
- */
-NEM_TMPL_STATIC int nemR0WinResumeCpuTickOnAll(PGVM pGVM, PGVMCPU pGVCpu, uint64_t uPausedTscValue)
-{
-    AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-
-    /*
-     * Set up the hypercall parameters.
-     */
-    HV_INPUT_SET_VP_REGISTERS *pInput = (HV_INPUT_SET_VP_REGISTERS *)pGVCpu->nemr0.s.HypercallData.pbPage;
-    AssertPtrReturn(pInput, VERR_INTERNAL_ERROR_3);
-
-    pInput->PartitionId = pGVM->nemr0.s.idHvPartition;
-    pInput->VpIndex     = 0;
-    pInput->RsvdZ       = 0;
-    pInput->Elements[0].Name  = HvX64RegisterTsc;
-    pInput->Elements[0].Pad0  = 0;
-    pInput->Elements[0].Pad1  = 0;
-    pInput->Elements[0].Value.Reg128.High64 = 0;
-    pInput->Elements[0].Value.Reg64 = uPausedTscValue;
-
-    /*
-     * Disable interrupts and do the first virtual CPU.
-     */
-    RTCCINTREG const fSavedFlags = ASMIntDisableFlags();
-    uint64_t const   uFirstTsc   = ASMReadTSC();
-    uint64_t uResult = g_pfnHvlInvokeHypercall(HV_MAKE_CALL_INFO(HvCallSetVpRegisters, 1),
-                                               pGVCpu->nemr0.s.HypercallData.HCPhysPage, 0 /* no output */);
-    AssertLogRelMsgReturnStmt(uResult == HV_MAKE_CALL_REP_RET(1), ("uResult=%RX64 uTsc=%#RX64\n", uResult, uPausedTscValue),
-                              ASMSetFlags(fSavedFlags), VERR_NEM_SET_TSC);
-
-    /*
-     * Do secondary processors, adjusting for elapsed TSC and keeping finger crossed
-     * that we don't introduce too much drift here.
-     */
-    for (VMCPUID iCpu = 1; iCpu < pGVM->cCpus; iCpu++)
-    {
-        Assert(pInput->PartitionId == pGVM->nemr0.s.idHvPartition);
-        Assert(pInput->RsvdZ       == 0);
-        Assert(pInput->Elements[0].Name == HvX64RegisterTsc);
-        Assert(pInput->Elements[0].Pad0 == 0);
-        Assert(pInput->Elements[0].Pad1 == 0);
-        Assert(pInput->Elements[0].Value.Reg128.High64 == 0);
-
-        pInput->VpIndex = iCpu;
-        const uint64_t offDelta = (ASMReadTSC() - uFirstTsc);
-        pInput->Elements[0].Value.Reg64 = uPausedTscValue + offDelta;
-
-        uResult = g_pfnHvlInvokeHypercall(HV_MAKE_CALL_INFO(HvCallSetVpRegisters, 1),
-                                          pGVCpu->nemr0.s.HypercallData.HCPhysPage, 0 /* no output */);
-        AssertLogRelMsgReturnStmt(uResult == HV_MAKE_CALL_REP_RET(1),
-                                  ("uResult=%RX64 uTsc=%#RX64 + %#RX64\n", uResult, uPausedTscValue, offDelta),
-                                  ASMSetFlags(fSavedFlags), VERR_NEM_SET_TSC);
-    }
-
-    /*
-     * Done.
-     */
-    ASMSetFlags(fSavedFlags);
-    return VINF_SUCCESS;
-}
-#endif /* NEM_WIN_WITH_RING0_RUNLOOP || NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS */
+    RT_NOREF(pGVM, idCpu);
+    return VERR_NOT_IMPLEMENTED;
+}
 
 
@@ -3002,26 +235,6 @@
 VMMR0_INT_DECL(int) NEMR0ResumeCpuTickOnAll(PGVM pGVM, VMCPUID idCpu, uint64_t uPausedTscValue)
 {
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
-    /*
-     * Validate the call.
-     */
-    int rc = GVMMR0ValidateGVMandEMT(pGVM, idCpu);
-    if (RT_SUCCESS(rc))
-    {
-        PGVMCPU pGVCpu = &pGVM->aCpus[idCpu];
-        AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-
-        /*
-         * Call worker.
-         */
-        pGVCpu->nem.s.Hypercall.QueryCpuTick.cTicks = 0;
-        pGVCpu->nem.s.Hypercall.QueryCpuTick.uAux   = 0;
-        rc = nemR0WinResumeCpuTickOnAll(pGVM, pGVCpu, uPausedTscValue);
-    }
-    return rc;
-#else
     RT_NOREF(pGVM, idCpu, uPausedTscValue);
     return VERR_NOT_IMPLEMENTED;
-#endif
 }
 
@@ -3029,12 +242,6 @@
 VMMR0_INT_DECL(VBOXSTRICTRC) NEMR0RunGuestCode(PGVM pGVM, VMCPUID idCpu)
 {
-#ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    if (pGVM->nemr0.s.fMayUseRing0Runloop)
-        return nemHCWinRunGC(pGVM, &pGVM->aCpus[idCpu]);
-    return VERR_NEM_RING3_ONLY;
-#else
-    RT_NOREF(pGVM, idCpu);
-    return VERR_NOT_IMPLEMENTED;
-#endif
+    RT_NOREF(pGVM, idCpu);
+    return VERR_NOT_IMPLEMENTED;
 }
 
@@ -3050,68 +257,6 @@
 VMMR0_INT_DECL(int)  NEMR0UpdateStatistics(PGVM pGVM, VMCPUID idCpu)
 {
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    /*
-     * Validate the call.
-     */
-    int rc;
-    if (idCpu == NIL_VMCPUID)
-        rc = GVMMR0ValidateGVM(pGVM);
-    else
-        rc = GVMMR0ValidateGVMandEMT(pGVM, idCpu);
-    if (RT_SUCCESS(rc))
-    {
-        AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-
-        PNEMR0HYPERCALLDATA pHypercallData = idCpu != NIL_VMCPUID
-                                           ? &pGVM->aCpus[idCpu].nemr0.s.HypercallData
-                                           : &pGVM->nemr0.s.HypercallData;
-        if (   RT_VALID_PTR(pHypercallData->pbPage)
-            && pHypercallData->HCPhysPage != NIL_RTHCPHYS)
-        {
-            if (idCpu == NIL_VMCPUID)
-                rc = RTCritSectEnter(&pGVM->nemr0.s.HypercallDataCritSect);
-            if (RT_SUCCESS(rc))
-            {
-                /*
-                 * Query the memory statistics for the partition.
-                 */
-                HV_INPUT_GET_MEMORY_BALANCE  *pInput = (HV_INPUT_GET_MEMORY_BALANCE *)pHypercallData->pbPage;
-                pInput->TargetPartitionId                               = pGVM->nemr0.s.idHvPartition;
-                pInput->ProximityDomainInfo.Flags.ProximityPreferred    = 0;
-                pInput->ProximityDomainInfo.Flags.ProxyimityInfoValid   = 0;
-                pInput->ProximityDomainInfo.Flags.Reserved              = 0;
-                pInput->ProximityDomainInfo.Id                          = 0;
-
-                HV_OUTPUT_GET_MEMORY_BALANCE *pOutput = (HV_OUTPUT_GET_MEMORY_BALANCE *)(pInput + 1);
-                RT_ZERO(*pOutput);
-
-                uint64_t uResult = g_pfnHvlInvokeHypercall(HvCallGetMemoryBalance,
-                                                           pHypercallData->HCPhysPage,
-                                                           pHypercallData->HCPhysPage + sizeof(*pInput));
-                if (uResult == HV_STATUS_SUCCESS)
-                {
-                    pGVM->nem.s.R0Stats.cPagesAvailable = pOutput->PagesAvailable;
-                    pGVM->nem.s.R0Stats.cPagesInUse     = pOutput->PagesInUse;
-                    rc = VINF_SUCCESS;
-                }
-                else
-                {
-                    LogRel(("HvCallGetMemoryBalance -> %#RX64 (%#RX64 %#RX64)!!\n",
-                            uResult, pOutput->PagesAvailable, pOutput->PagesInUse));
-                    rc = VERR_NEM_IPE_0;
-                }
-
-                if (idCpu == NIL_VMCPUID)
-                    RTCritSectLeave(&pGVM->nemr0.s.HypercallDataCritSect);
-            }
-        }
-        else
-            rc = VERR_WRONG_ORDER;
-    }
-    return rc;
-#else
     RT_NOREF(pGVM, idCpu);
     return VINF_SUCCESS;
-#endif
 }
 
@@ -3126,95 +271,6 @@
 VMMR0_INT_DECL(int) NEMR0DoExperiment(PGVM pGVM, VMCPUID idCpu, uint64_t u64Arg)
 {
-#if defined(DEBUG_bird) && defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES)
-    /*
-     * Resolve CPU structures.
-     */
-    int rc = GVMMR0ValidateGVMandEMT(pGVM, idCpu);
-    if (RT_SUCCESS(rc))
-    {
-        AssertReturn(g_pfnHvlInvokeHypercall, VERR_NEM_MISSING_KERNEL_API_1);
-
-        PGVMCPU pGVCpu = &pGVM->aCpus[idCpu];
-        if (u64Arg == 0)
-        {
-            /*
-             * Query register.
-             */
-            HV_INPUT_GET_VP_REGISTERS *pInput = (HV_INPUT_GET_VP_REGISTERS *)pGVCpu->nemr0.s.HypercallData.pbPage;
-            AssertPtrReturn(pInput, VERR_INTERNAL_ERROR_3);
-
-            size_t const cbInput = RT_ALIGN_Z(RT_UOFFSETOF(HV_INPUT_GET_VP_REGISTERS, Names[1]), 32);
-            HV_REGISTER_VALUE *paValues = (HV_REGISTER_VALUE *)((uint8_t *)pInput + cbInput);
-            RT_BZERO(paValues, sizeof(paValues[0]) * 1);
-
-            pInput->PartitionId = pGVM->nemr0.s.idHvPartition;
-            pInput->VpIndex     = pGVCpu->idCpu;
-            pInput->fFlags      = 0;
-            pInput->Names[0]    = (HV_REGISTER_NAME)pGVCpu->nem.s.Hypercall.Experiment.uItem;
-
-            uint64_t uResult = g_pfnHvlInvokeHypercall(HV_MAKE_CALL_INFO(HvCallGetVpRegisters, 1),
-                                                       pGVCpu->nemr0.s.HypercallData.HCPhysPage,
-                                                       pGVCpu->nemr0.s.HypercallData.HCPhysPage + cbInput);
-            pGVCpu->nem.s.Hypercall.Experiment.fSuccess = uResult == HV_MAKE_CALL_REP_RET(1);
-            pGVCpu->nem.s.Hypercall.Experiment.uStatus  = uResult;
-            pGVCpu->nem.s.Hypercall.Experiment.uLoValue = paValues[0].Reg128.Low64;
-            pGVCpu->nem.s.Hypercall.Experiment.uHiValue = paValues[0].Reg128.High64;
-            rc = VINF_SUCCESS;
-        }
-        else if (u64Arg == 1)
-        {
-            /*
-             * Query partition property.
-             */
-            HV_INPUT_GET_PARTITION_PROPERTY *pInput = (HV_INPUT_GET_PARTITION_PROPERTY *)pGVCpu->nemr0.s.HypercallData.pbPage;
-            AssertPtrReturn(pInput, VERR_INTERNAL_ERROR_3);
-
-            size_t const cbInput = RT_ALIGN_Z(sizeof(*pInput), 32);
-            HV_OUTPUT_GET_PARTITION_PROPERTY *pOutput = (HV_OUTPUT_GET_PARTITION_PROPERTY *)((uint8_t *)pInput + cbInput);
-            pOutput->PropertyValue = 0;
-
-            pInput->PartitionId  = pGVM->nemr0.s.idHvPartition;
-            pInput->PropertyCode = (HV_PARTITION_PROPERTY_CODE)pGVCpu->nem.s.Hypercall.Experiment.uItem;
-            pInput->uPadding     = 0;
-
-            uint64_t uResult = g_pfnHvlInvokeHypercall(HvCallGetPartitionProperty,
-                                                       pGVCpu->nemr0.s.HypercallData.HCPhysPage,
-                                                       pGVCpu->nemr0.s.HypercallData.HCPhysPage + cbInput);
-            pGVCpu->nem.s.Hypercall.Experiment.fSuccess = uResult == HV_STATUS_SUCCESS;
-            pGVCpu->nem.s.Hypercall.Experiment.uStatus  = uResult;
-            pGVCpu->nem.s.Hypercall.Experiment.uLoValue = pOutput->PropertyValue;
-            pGVCpu->nem.s.Hypercall.Experiment.uHiValue = 0;
-            rc = VINF_SUCCESS;
-        }
-        else if (u64Arg == 2)
-        {
-            /*
-             * Set register.
-             */
-            HV_INPUT_SET_VP_REGISTERS *pInput = (HV_INPUT_SET_VP_REGISTERS *)pGVCpu->nemr0.s.HypercallData.pbPage;
-            AssertPtrReturn(pInput, VERR_INTERNAL_ERROR_3);
-            RT_BZERO(pInput, RT_UOFFSETOF(HV_INPUT_SET_VP_REGISTERS, Elements[1]));
-
-            pInput->PartitionId = pGVM->nemr0.s.idHvPartition;
-            pInput->VpIndex     = pGVCpu->idCpu;
-            pInput->RsvdZ      = 0;
-            pInput->Elements[0].Name = (HV_REGISTER_NAME)pGVCpu->nem.s.Hypercall.Experiment.uItem;
-            pInput->Elements[0].Value.Reg128.High64 = pGVCpu->nem.s.Hypercall.Experiment.uHiValue;
-            pInput->Elements[0].Value.Reg128.Low64  = pGVCpu->nem.s.Hypercall.Experiment.uLoValue;
-
-            uint64_t uResult = g_pfnHvlInvokeHypercall(HV_MAKE_CALL_INFO(HvCallSetVpRegisters, 1),
-                                                       pGVCpu->nemr0.s.HypercallData.HCPhysPage, 0);
-            pGVCpu->nem.s.Hypercall.Experiment.fSuccess = uResult == HV_MAKE_CALL_REP_RET(1);
-            pGVCpu->nem.s.Hypercall.Experiment.uStatus  = uResult;
-            rc = VINF_SUCCESS;
-        }
-        else
-            rc = VERR_INVALID_FUNCTION;
-    }
-    return rc;
-#else   /* !DEBUG_bird */
     RT_NOREF(pGVM, idCpu, u64Arg);
     return VERR_NOT_SUPPORTED;
-#endif /* !DEBUG_bird */
-}
-
+}
+
Index: trunk/src/VBox/VMM/VMMR3/NEMR3.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/NEMR3.cpp	(revision 93350)
+++ trunk/src/VBox/VMM/VMMR3/NEMR3.cpp	(revision 93351)
@@ -120,22 +120,4 @@
         pVCpu->nem.s.fTrapXcptGpForLovelyMesaDrv = f;
     }
-
-#ifdef RT_OS_WINDOWS
-# ifndef VBOX_WITH_PGM_NEM_MODE
-
-    /** @cfgm{/NEM/UseRing0Runloop, bool, true}
-     * Whether to use the ring-0 runloop (if enabled in the build) or the ring-3 one.
-     * The latter is generally slower.  This option serves as a way out in case
-     * something breaks in the ring-0 loop. */
-#  ifdef NEM_WIN_USE_RING0_RUNLOOP_BY_DEFAULT
-    bool fUseRing0Runloop = true;
-#  else
-    bool fUseRing0Runloop = false;
-#  endif
-    rc = CFGMR3QueryBoolDef(pCfgNem, "UseRing0Runloop", &fUseRing0Runloop, fUseRing0Runloop);
-    AssertLogRelRCReturn(rc, rc);
-    pVM->nem.s.fUseRing0Runloop = fUseRing0Runloop;
-# endif
-#endif
 
     return VINF_SUCCESS;
Index: trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp	(revision 93350)
+++ trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp	(revision 93351)
@@ -181,11 +181,9 @@
 /** Pointer to the NtDeviceIoControlFile import table entry. */
 static decltype(NtDeviceIoControlFile) **g_ppfnVidNtDeviceIoControlFile;
-#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED)
+#ifdef LOG_ENABLED
 /** Info about the VidGetHvPartitionId I/O control interface. */
 static NEMWINIOCTL g_IoCtlGetHvPartitionId;
 /** Info about the VidGetPartitionProperty I/O control interface. */
 static NEMWINIOCTL g_IoCtlGetPartitionProperty;
-#endif
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED)
 /** Info about the VidStartVirtualProcessor I/O control interface. */
 static NEMWINIOCTL g_IoCtlStartVirtualProcessor;
@@ -194,6 +192,4 @@
 /** Info about the VidMessageSlotHandleAndGetNext I/O control interface. */
 static NEMWINIOCTL g_IoCtlMessageSlotHandleAndGetNext;
-#endif
-#ifdef LOG_ENABLED
 /** Info about the VidMessageSlotMap I/O control interface - for logging. */
 static NEMWINIOCTL g_IoCtlMessageSlotMap;
@@ -809,5 +805,5 @@
 }
 
-#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED)
+#ifdef LOG_ENABLED
 
 /**
@@ -864,6 +860,4 @@
 }
 
-#endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED) */
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED)
 
 /**
@@ -967,5 +961,5 @@
 }
 
-#endif /* defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED) */
+#endif /* LOG_ENABLED */
 
 #ifdef LOG_ENABLED
@@ -1012,5 +1006,5 @@
      *
      */
-#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED)
+#ifdef LOG_ENABLED
     decltype(NtDeviceIoControlFile) * const pfnOrg = *g_ppfnVidNtDeviceIoControlFile;
 
@@ -1042,8 +1036,4 @@
             g_IoCtlGetPartitionProperty.uFunction, g_IoCtlGetPartitionProperty.cbInput, g_IoCtlGetPartitionProperty.cbOutput));
 
-#endif
-    int rcRet = VINF_SUCCESS;
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED)
-
     /* VidStartVirtualProcessor */
     *g_ppfnVidNtDeviceIoControlFile = nemR3WinIoctlDetector_StartVirtualProcessor;
@@ -1051,7 +1041,6 @@
     *g_ppfnVidNtDeviceIoControlFile = pfnOrg;
     AssertStmt(fRet && g_IoCtlStartVirtualProcessor.uFunction != 0,
-               rcRet = RTERRINFO_LOG_REL_SET_F(pErrInfo, VERR_NEM_RING3_ONLY,
-                                               "Problem figuring out VidStartVirtualProcessor: fRet=%u dwErr=%u",
-                                               fRet, GetLastError()) );
+               RTERRINFO_LOG_REL_SET_F(pErrInfo, VERR_NEM_RING3_ONLY,
+                                       "Problem figuring out VidStartVirtualProcessor: fRet=%u dwErr=%u", fRet, GetLastError()) );
     LogRel(("NEM: VidStartVirtualProcessor       -> fun:%#x in:%#x out:%#x\n", g_IoCtlStartVirtualProcessor.uFunction,
             g_IoCtlStartVirtualProcessor.cbInput, g_IoCtlStartVirtualProcessor.cbOutput));
@@ -1062,7 +1051,6 @@
     *g_ppfnVidNtDeviceIoControlFile = pfnOrg;
     AssertStmt(fRet && g_IoCtlStopVirtualProcessor.uFunction != 0,
-               rcRet = RTERRINFO_LOG_REL_SET_F(pErrInfo, VERR_NEM_RING3_ONLY,
-                                               "Problem figuring out VidStopVirtualProcessor: fRet=%u dwErr=%u",
-                                               fRet, GetLastError()) );
+               RTERRINFO_LOG_REL_SET_F(pErrInfo, VERR_NEM_RING3_ONLY,
+                                       "Problem figuring out VidStopVirtualProcessor: fRet=%u dwErr=%u", fRet, GetLastError()) );
     LogRel(("NEM: VidStopVirtualProcessor        -> fun:%#x in:%#x out:%#x\n", g_IoCtlStopVirtualProcessor.uFunction,
             g_IoCtlStopVirtualProcessor.cbInput, g_IoCtlStopVirtualProcessor.cbOutput));
@@ -1075,13 +1063,11 @@
     *g_ppfnVidNtDeviceIoControlFile = pfnOrg;
     AssertStmt(fRet && g_IoCtlMessageSlotHandleAndGetNext.uFunction != 0,
-               rcRet = RTERRINFO_LOG_REL_SET_F(pErrInfo, VERR_NEM_RING3_ONLY,
-                                               "Problem figuring out VidMessageSlotHandleAndGetNext: fRet=%u dwErr=%u",
-                                               fRet, GetLastError()) );
+               RTERRINFO_LOG_REL_SET_F(pErrInfo, VERR_NEM_RING3_ONLY,
+                                       "Problem figuring out VidMessageSlotHandleAndGetNext: fRet=%u dwErr=%u",
+                                       fRet, GetLastError()) );
     LogRel(("NEM: VidMessageSlotHandleAndGetNext -> fun:%#x in:%#x out:%#x\n",
             g_IoCtlMessageSlotHandleAndGetNext.uFunction, g_IoCtlMessageSlotHandleAndGetNext.cbInput,
             g_IoCtlMessageSlotHandleAndGetNext.cbOutput));
 
-#endif /* defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED) */
-#ifdef LOG_ENABLED
     /* The following are only for logging: */
     union
@@ -1124,17 +1110,7 @@
 
     g_pIoCtlDetectForLogging = NULL;
-#endif
-
-    /* Done. */
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    pVM->nem.s.IoCtlGetHvPartitionId            = g_IoCtlGetHvPartitionId;
-    pVM->nem.s.IoCtlGetPartitionProperty        = g_IoCtlGetPartitionProperty;
-#endif
-#ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    pVM->nem.s.IoCtlStartVirtualProcessor       = g_IoCtlStartVirtualProcessor;
-    pVM->nem.s.IoCtlStopVirtualProcessor        = g_IoCtlStopVirtualProcessor;
-    pVM->nem.s.IoCtlMessageSlotHandleAndGetNext = g_IoCtlMessageSlotHandleAndGetNext;
-#endif
-    return rcRet;
+#endif /* LOG_ENABLED */
+
+    return VINF_SUCCESS;
 }
 
@@ -1303,10 +1279,9 @@
 #endif
 
-#ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    /** Some guess working here. */
+    /** @todo Ditch for VBOX_WITH_PGM_NEM_MODE   */
+    /* Some guess working here. */
     pVM->nem.s.cMaxMappedPages = 4000;
     if (g_uBuildNo >= 22000)
         pVM->nem.s.cMaxMappedPages = _64K; /* seems it can do lots more even */
-#endif
 
     /*
@@ -1362,5 +1337,5 @@
                         Log(("NEM: Marked active!\n"));
                         nemR3WinDisableX2Apic(pVM);
-#if !defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) && defined(VBOX_WITH_PGM_NEM_MODE)
+#ifdef VBOX_WITH_PGM_NEM_MODE
                         PGMR3EnableNemMode(pVM);
 #endif
@@ -1379,10 +1354,5 @@
                         STAMR3Register(pVM, (void *)&pVM->nem.s.StatUnmapPageFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
                                        "/NEM/PagesUnmapFails", STAMUNIT_PAGES, "Calls to WHvUnmapGpaRange/HvCallUnmapGpaPages that failed");
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-                        STAMR3Register(pVM, (void *)&pVM->nem.s.StatRemapPage, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
-                                       "/NEM/PagesRemapCalls", STAMUNIT_PAGES, "Calls to HvCallMapGpaPages for changing page protection");
-                        STAMR3Register(pVM, (void *)&pVM->nem.s.StatRemapPage, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
-                                       "/NEM/PagesRemapFails", STAMUNIT_PAGES, "Calls to HvCallMapGpaPages for changing page protection failed");
-#elif !defined(VBOX_WITH_PGM_NEM_MODE)
+#ifndef VBOX_WITH_PGM_NEM_MODE
                         STAMR3Register(pVM, (void *)&pVM->nem.s.StatUnmapAllPages, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
                                        "/NEM/PagesUnmapAll", STAMUNIT_PAGES, "Times we had to unmap all the pages");
@@ -1393,11 +1363,9 @@
                         STAMR3Register(pVM, &pVM->nem.s.StatProfUnmapGpaRange, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS,
                                        "/NEM/PagesUnmapGpaRange", STAMUNIT_TICKS_PER_CALL, "Profiling calls to WHvUnmapGpaRange for bigger stuff");
-#  endif
-#  ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+#endif
                         STAMR3Register(pVM, &pVM->nem.s.StatProfMapGpaRangePage, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS,
                                        "/NEM/PagesMapGpaRangePage", STAMUNIT_TICKS_PER_CALL, "Profiling calls to WHvMapGpaRange for single pages");
                         STAMR3Register(pVM, &pVM->nem.s.StatProfUnmapGpaRangePage, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS,
                                        "/NEM/PagesUnmapGpaRangePage", STAMUNIT_TICKS_PER_CALL, "Profiling calls to WHvUnmapGpaRange for single pages");
-#  endif
 
                         for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
@@ -1623,46 +1591,35 @@
 
 #ifndef NEM_WIN_USE_OUR_OWN_RUN_API
-# ifdef NEM_WIN_WITH_RING0_RUNLOOP
-        if (!pVM->nem.s.fUseRing0Runloop)
-# endif
+        hrc = WHvCreateVirtualProcessor(hPartition, idCpu, 0 /*fFlags*/);
+        if (FAILED(hrc))
         {
-            hrc = WHvCreateVirtualProcessor(hPartition, idCpu, 0 /*fFlags*/);
-            if (FAILED(hrc))
+            NTSTATUS const rcNtLast  = RTNtLastStatusValue();
+            DWORD const    dwErrLast = RTNtLastErrorValue();
+            while (idCpu-- > 0)
             {
-                NTSTATUS const rcNtLast  = RTNtLastStatusValue();
-                DWORD const    dwErrLast = RTNtLastErrorValue();
-                while (idCpu-- > 0)
-                {
-                    HRESULT hrc2 = WHvDeleteVirtualProcessor(hPartition, idCpu);
-                    AssertLogRelMsg(SUCCEEDED(hrc2), ("WHvDeleteVirtualProcessor(%p, %u) -> %Rhrc (Last=%#x/%u)\n",
-                                                      hPartition, idCpu, hrc2, RTNtLastStatusValue(),
-                                                      RTNtLastErrorValue()));
-                }
-                return VMSetError(pVM, VERR_NEM_VM_CREATE_FAILED, RT_SRC_POS,
-                                  "Call to WHvCreateVirtualProcessor failed: %Rhrc (Last=%#x/%u)", hrc, rcNtLast, dwErrLast);
+                HRESULT hrc2 = WHvDeleteVirtualProcessor(hPartition, idCpu);
+                AssertLogRelMsg(SUCCEEDED(hrc2), ("WHvDeleteVirtualProcessor(%p, %u) -> %Rhrc (Last=%#x/%u)\n",
+                                                  hPartition, idCpu, hrc2, RTNtLastStatusValue(),
+                                                  RTNtLastErrorValue()));
             }
+            return VMSetError(pVM, VERR_NEM_VM_CREATE_FAILED, RT_SRC_POS,
+                              "Call to WHvCreateVirtualProcessor failed: %Rhrc (Last=%#x/%u)", hrc, rcNtLast, dwErrLast);
         }
-# ifdef NEM_WIN_WITH_RING0_RUNLOOP
+#else  /* NEM_WIN_USE_OUR_OWN_RUN_API */
+        VID_MAPPED_MESSAGE_SLOT MappedMsgSlot = { NULL, UINT32_MAX, UINT32_MAX };
+        if (g_pfnVidMessageSlotMap(hPartitionDevice, &MappedMsgSlot, idCpu))
+        {
+            AssertLogRelMsg(MappedMsgSlot.iCpu == idCpu && MappedMsgSlot.uParentAdvisory == UINT32_MAX,
+                            ("%#x %#x (iCpu=%#x)\n", MappedMsgSlot.iCpu, MappedMsgSlot.uParentAdvisory, idCpu));
+            pVCpu->nem.s.pvMsgSlotMapping = MappedMsgSlot.pMsgBlock;
+        }
         else
-# endif
-#endif /* !NEM_WIN_USE_OUR_OWN_RUN_API */
-#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(NEM_WIN_USE_OUR_OWN_RUN_API)
         {
-            VID_MAPPED_MESSAGE_SLOT MappedMsgSlot = { NULL, UINT32_MAX, UINT32_MAX };
-            if (g_pfnVidMessageSlotMap(hPartitionDevice, &MappedMsgSlot, idCpu))
-            {
-                AssertLogRelMsg(MappedMsgSlot.iCpu == idCpu && MappedMsgSlot.uParentAdvisory == UINT32_MAX,
-                                ("%#x %#x (iCpu=%#x)\n", MappedMsgSlot.iCpu, MappedMsgSlot.uParentAdvisory, idCpu));
-                pVCpu->nem.s.pvMsgSlotMapping = MappedMsgSlot.pMsgBlock;
-            }
-            else
-            {
-                NTSTATUS const rcNtLast  = RTNtLastStatusValue();
-                DWORD const    dwErrLast = RTNtLastErrorValue();
-                return VMSetError(pVM, VERR_NEM_VM_CREATE_FAILED, RT_SRC_POS,
-                                  "Call to VidMessageSlotMap failed: Last=%#x/%u", rcNtLast, dwErrLast);
-            }
+            NTSTATUS const rcNtLast  = RTNtLastStatusValue();
+            DWORD const    dwErrLast = RTNtLastErrorValue();
+            return VMSetError(pVM, VERR_NEM_VM_CREATE_FAILED, RT_SRC_POS,
+                              "Call to VidMessageSlotMap failed: Last=%#x/%u", rcNtLast, dwErrLast);
         }
-#endif
+#endif /* NEM_WIN_USE_OUR_OWN_RUN_API */
     }
     pVM->nem.s.fCreatedEmts = true;
@@ -1836,13 +1793,8 @@
             pVCpu->nem.s.pvMsgSlotMapping = NULL;
 #ifndef NEM_WIN_USE_OUR_OWN_RUN_API
-# ifdef NEM_WIN_WITH_RING0_RUNLOOP
-            if (!pVM->nem.s.fUseRing0Runloop)
-# endif
-            {
-                HRESULT hrc = WHvDeleteVirtualProcessor(hPartition, idCpu);
-                AssertLogRelMsg(SUCCEEDED(hrc), ("WHvDeleteVirtualProcessor(%p, %u) -> %Rhrc (Last=%#x/%u)\n",
-                                                 hPartition, idCpu, hrc, RTNtLastStatusValue(),
-                                                 RTNtLastErrorValue()));
-            }
+            HRESULT hrc = WHvDeleteVirtualProcessor(hPartition, idCpu);
+            AssertLogRelMsg(SUCCEEDED(hrc), ("WHvDeleteVirtualProcessor(%p, %u) -> %Rhrc (Last=%#x/%u)\n",
+                                             hPartition, idCpu, hrc, RTNtLastStatusValue(),
+                                             RTNtLastErrorValue()));
 #endif
         }
@@ -1897,44 +1849,4 @@
 VBOXSTRICTRC nemR3NativeRunGC(PVM pVM, PVMCPU pVCpu)
 {
-#ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    if (pVM->nem.s.fUseRing0Runloop)
-    {
-        for (;;)
-        {
-            VBOXSTRICTRC rcStrict = VMMR3CallR0EmtFast(pVM, pVCpu, VMMR0_DO_NEM_RUN);
-            if (RT_SUCCESS(rcStrict))
-            {
-                /*
-                 * We deal with VINF_NEM_FLUSH_TLB here, since we're running the risk of
-                 * getting these while we already got another RC (I/O ports).
-                 */
-                /* Status codes: */
-                VBOXSTRICTRC rcPending = pVCpu->nem.s.rcPending;
-                pVCpu->nem.s.rcPending = VINF_SUCCESS;
-                if (rcStrict == VINF_NEM_FLUSH_TLB || rcPending == VINF_NEM_FLUSH_TLB)
-                {
-                    LogFlow(("nemR3NativeRunGC: calling PGMFlushTLB...\n"));
-                    int rc = PGMFlushTLB(pVCpu, CPUMGetGuestCR3(pVCpu), true /*fGlobal*/);
-                    AssertRCReturn(rc, rc);
-                    if (rcStrict == VINF_NEM_FLUSH_TLB)
-                    {
-                        if (   !VM_FF_IS_ANY_SET(pVM, VM_FF_HIGH_PRIORITY_POST_MASK | VM_FF_HP_R0_PRE_HM_MASK)
-                            && !VMCPU_FF_IS_ANY_SET(pVCpu,   (VMCPU_FF_HIGH_PRIORITY_POST_MASK | VMCPU_FF_HP_R0_PRE_HM_MASK)
-                                                           & ~VMCPU_FF_RESUME_GUEST_MASK))
-                        {
-                            VMCPU_FF_CLEAR_MASK(pVCpu, VMCPU_FF_RESUME_GUEST_MASK);
-                            continue;
-                        }
-                        rcStrict = VINF_SUCCESS;
-                    }
-                }
-                else
-                    AssertMsg(rcPending == VINF_SUCCESS, ("rcPending=%Rrc\n", VBOXSTRICTRC_VAL(rcPending) ));
-            }
-            LogFlow(("nemR3NativeRunGC: returns %Rrc\n", VBOXSTRICTRC_VAL(rcStrict) ));
-            return rcStrict;
-        }
-    }
-#endif
     return nemHCWinRunGC(pVM, pVCpu);
 }
@@ -1981,15 +1893,8 @@
     nemHCWinCancelRunVirtualProcessor(pVM, pVCpu);
 #else
-# ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    if (pVM->nem.s.fUseRing0Runloop)
-        nemHCWinCancelRunVirtualProcessor(pVM, pVCpu);
-    else
-# endif
-    {
-        Log8(("nemR3NativeNotifyFF: canceling %u\n", pVCpu->idCpu));
-        HRESULT hrc = WHvCancelRunVirtualProcessor(pVM->nem.s.hPartition, pVCpu->idCpu, 0);
-        AssertMsg(SUCCEEDED(hrc), ("WHvCancelRunVirtualProcessor -> hrc=%Rhrc\n", hrc));
-        RT_NOREF_PV(hrc);
-    }
+    Log8(("nemR3NativeNotifyFF: canceling %u\n", pVCpu->idCpu));
+    HRESULT hrc = WHvCancelRunVirtualProcessor(pVM->nem.s.hPartition, pVCpu->idCpu, 0);
+    AssertMsg(SUCCEEDED(hrc), ("WHvCancelRunVirtualProcessor -> hrc=%Rhrc\n", hrc));
+    RT_NOREF_PV(hrc);
 #endif
     RT_NOREF_PV(fFlags);
@@ -2026,5 +1931,5 @@
     RT_NOREF(puNemRange);
 
-#if !defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) && defined(VBOX_WITH_PGM_NEM_MODE)
+#ifdef VBOX_WITH_PGM_NEM_MODE
     if (pvR3)
     {
@@ -2064,5 +1969,5 @@
     RT_NOREF(puNemRange);
 
-#if !defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) && defined(VBOX_WITH_PGM_NEM_MODE)
+#ifdef VBOX_WITH_PGM_NEM_MODE
     /*
      * Unmap the RAM we're replacing.
@@ -2139,5 +2044,5 @@
 
     int rc = VINF_SUCCESS;
-#if !defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) && defined(VBOX_WITH_PGM_NEM_MODE)
+#ifdef VBOX_WITH_PGM_NEM_MODE
     /*
      * Unmap the MMIO2 pages.
@@ -2198,5 +2103,5 @@
                                                            void *pvBitmap, size_t cbBitmap)
 {
-#if !defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) && defined(VBOX_WITH_PGM_NEM_MODE)
+#ifdef VBOX_WITH_PGM_NEM_MODE
     Assert(VM_IS_NEM_ENABLED(pVM));
     AssertReturn(g_pfnWHvQueryGpaRangeDirtyBitmap, VERR_INTERNAL_ERROR_2);
@@ -2268,5 +2173,5 @@
     *pu2State = UINT8_MAX;
 
-#if !defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) && defined(VBOX_WITH_PGM_NEM_MODE)
+#ifdef VBOX_WITH_PGM_NEM_MODE
     /*
      * (Re-)map readonly.
@@ -2303,12 +2208,6 @@
     if (pInfo->u2NemState > NEM_WIN_PAGE_STATE_UNMAPPED)
     {
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-        int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys);
-        AssertRC(rc);
-        if (RT_SUCCESS(rc))
-#else
         HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE);
         if (SUCCEEDED(hrc))
-#endif
         {
             STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage);
@@ -2320,12 +2219,7 @@
         {
             STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed);
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-            LogRel(("nemR3WinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc));
-            return rc;
-#else
             LogRel(("nemR3WinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp hrc=%Rhrc (%#x) Last=%#x/%u\n",
                     GCPhys, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue()));
             return VERR_INTERNAL_ERROR_2;
-#endif
         }
     }
Index: trunk/src/VBox/VMM/include/NEMInternal.h
===================================================================
--- trunk/src/VBox/VMM/include/NEMInternal.h	(revision 93350)
+++ trunk/src/VBox/VMM/include/NEMInternal.h	(revision 93351)
@@ -53,22 +53,8 @@
  * Windows: Code configuration.
  */
-# ifndef VBOX_WITH_PGM_NEM_MODE
-#  define NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-#endif
 //# define NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS   /**< Applies to ring-3 code only. Useful for testing VID API. */
 //# define NEM_WIN_USE_OUR_OWN_RUN_API            /**< Applies to ring-3 code only. Useful for testing VID API. */
-//# define NEM_WIN_WITH_RING0_RUNLOOP             /**< Enables the ring-0 runloop. */
-//# define NEM_WIN_USE_RING0_RUNLOOP_BY_DEFAULT   /**< For quickly testing ring-3 API without messing with CFGM. */
 # if defined(NEM_WIN_USE_OUR_OWN_RUN_API) && !defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
 #  error "NEM_WIN_USE_OUR_OWN_RUN_API requires NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS"
-# endif
-# if defined(NEM_WIN_USE_OUR_OWN_RUN_API) && !defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES)
-#  error "NEM_WIN_USE_OUR_OWN_RUN_API requires NEM_WIN_USE_HYPERCALLS_FOR_PAGES"
-# endif
-# if defined(NEM_WIN_WITH_RING0_RUNLOOP) && !defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES)
-#  error "NEM_WIN_WITH_RING0_RUNLOOP requires NEM_WIN_USE_HYPERCALLS_FOR_PAGES"
-# endif
-# if defined(VBOX_WITH_PGM_NEM_MODE) && defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES)
-#  error "VBOX_WITH_PGM_NEM_MODE cannot be used together with NEM_WIN_USE_HYPERCALLS_FOR_PAGES"
 # endif
 
@@ -263,14 +249,12 @@
     /** Number of currently mapped pages. */
     uint32_t volatile           cMappedPages;
-#  ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     /** Max number of pages we dare map at once. */
+#ifdef VBOX_WITH_PGM_NEM_MODE
+    /** @todo consider removing this.   */
+#endif
     uint32_t                    cMaxMappedPages;
-#  endif
     STAMCOUNTER                 StatMapPage;
     STAMCOUNTER                 StatUnmapPage;
-#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    STAMCOUNTER                 StatRemapPage;
-    STAMCOUNTER                 StatRemapPageFailed;
-#  elif !defined(VBOX_WITH_PGM_NEM_MODE)
+#  if !defined(VBOX_WITH_PGM_NEM_MODE)
     STAMCOUNTER                 StatUnmapAllPages;
 #  endif
@@ -281,23 +265,6 @@
     STAMPROFILE                 StatProfUnmapGpaRange;
 #  endif
-#  ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     STAMPROFILE                 StatProfMapGpaRangePage;
     STAMPROFILE                 StatProfUnmapGpaRangePage;
-#  endif
-
-#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    /** Info about the VidGetHvPartitionId I/O control interface. */
-    NEMWINIOCTL                 IoCtlGetHvPartitionId;
-    /** Info about the VidGetPartitionProperty I/O control interface. */
-    NEMWINIOCTL                 IoCtlGetPartitionProperty;
-#  endif
-#  ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    /** Info about the VidStartVirtualProcessor I/O control interface. */
-    NEMWINIOCTL                 IoCtlStartVirtualProcessor;
-    /** Info about the VidStopVirtualProcessor I/O control interface. */
-    NEMWINIOCTL                 IoCtlStopVirtualProcessor;
-    /** Info about the VidStopVirtualProcessor I/O control interface. */
-    NEMWINIOCTL                 IoCtlMessageSlotHandleAndGetNext;
-#  endif
 
     /** Statistics updated by NEMR0UpdateStatistics. */
@@ -406,10 +373,5 @@
     /** Last copy of HV_X64_VP_EXECUTION_STATE::InterruptShadow. */
     bool                        fLastInterruptShadow : 1;
-# ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    /** Pending VINF_NEM_FLUSH_TLB. */
-    int32_t                     rcPending;
-# else
     uint32_t                    uPadding;
-# endif
     /** The VID_MSHAGN_F_XXX flags.
      * Either VID_MSHAGN_F_HANDLE_MESSAGE | VID_MSHAGN_F_GET_NEXT_MESSAGE or zero. */
@@ -635,12 +597,5 @@
 typedef struct NEMR0PERVCPU
 {
-# if defined(RT_OS_WINDOWS) && defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES)
-    /** Hypercall input/ouput page. */
-    NEMR0HYPERCALLDATA          HypercallData;
-    /** Delta to add to convert a ring-0 pointer to a ring-3 one.   */
-    uintptr_t                   offRing3ConversionDelta;
-# else
     uint32_t                    uDummy;
-# endif
 } NEMR0PERVCPU;
 
@@ -650,36 +605,5 @@
 typedef struct NEMR0PERVM
 {
-# ifdef RT_OS_WINDOWS
-#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    /** The partition ID. */
-    uint64_t                    idHvPartition;
-    /** I/O control context. */
-    PSUPR0IOCTLCTX              pIoCtlCtx;
-    /** Info about the VidGetHvPartitionId I/O control interface. */
-    NEMWINIOCTL                 IoCtlGetHvPartitionId;
-    /** Info about the VidGetPartitionProperty I/O control interface. */
-    NEMWINIOCTL                 IoCtlGetPartitionProperty;
-#  endif
-#  ifdef NEM_WIN_WITH_RING0_RUNLOOP
-    /** Info about the VidStartVirtualProcessor I/O control interface. */
-    NEMWINIOCTL                 IoCtlStartVirtualProcessor;
-    /** Info about the VidStopVirtualProcessor I/O control interface. */
-    NEMWINIOCTL                 IoCtlStopVirtualProcessor;
-    /** Info about the VidStopVirtualProcessor I/O control interface. */
-    NEMWINIOCTL                 IoCtlMessageSlotHandleAndGetNext;
-    /** Whether we may use the ring-0 runloop or not. */
-    bool                        fMayUseRing0Runloop;
-#  endif
-
-#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-    /** Hypercall input/ouput page for non-EMT. */
-    NEMR0HYPERCALLDATA          HypercallData;
-    /** Critical section protecting use of HypercallData. */
-    RTCRITSECT                  HypercallDataCritSect;
-#  endif
-
-# else
     uint32_t                    uDummy;
-# endif
 } NEMR0PERVM;
 
