Index: /trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h	(revision 91691)
+++ /trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h	(revision 91692)
@@ -1589,5 +1589,5 @@
 #endif /* IN_RING3 && !NEM_WIN_TEMPLATE_MODE_OWN_RUN_API */
 
-
+#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3)
 
 NEM_TMPL_STATIC DECLCALLBACK(int)
@@ -1595,13 +1595,13 @@
 {
     RT_NOREF_PV(pvUser);
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys);
     AssertRC(rc);
     if (RT_SUCCESS(rc))
-#else
+# else
     RT_NOREF_PV(pVCpu);
     HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE);
     if (SUCCEEDED(hrc))
-#endif
+# endif
     {
         Log5(("NEM GPA unmap all: %RGp (cMappedPages=%u)\n", GCPhys, pVM->nem.s.cMappedPages - 1));
@@ -1610,11 +1610,11 @@
     else
     {
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-        LogRel(("nemR3WinUnmapOnePageCallback: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc));
-#else
-        LogRel(("nemR3WinUnmapOnePageCallback: GCPhys=%RGp %s hrc=%Rhrc (%#x) Last=%#x/%u (cMappedPages=%u)\n",
+# 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
+# endif
         *pu2NemState = NEM_WIN_PAGE_STATE_NOT_SET;
     }
@@ -1673,5 +1673,5 @@
      * We don't really consider downgrades here, as they shouldn't happen.
      */
-#ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# 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
@@ -1682,5 +1682,5 @@
      * with new protection or backing.
      */
-#endif
+# endif
     int rc;
     switch (u2State)
@@ -1725,5 +1725,5 @@
             }
 
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
             /* Upgrade page to writable. */
 /** @todo test this*/
@@ -1751,7 +1751,7 @@
             }
             return rc;
-#else
+# else
             break;
-#endif
+# endif
 
         case NEM_WIN_PAGE_STATE_WRITABLE:
@@ -1768,7 +1768,7 @@
                 return VINF_SUCCESS;
             }
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
             AssertFailed(); /* There should be no downgrades. */
-#endif
+# endif
             break;
 
@@ -1781,13 +1781,13 @@
      * If this fails, which it does every so often, just unmap everything for now.
      */
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys);
     AssertRC(rc);
     if (RT_SUCCESS(rc))
-#else
+# else
     /** @todo figure out whether we mess up the state or if it's WHv.   */
     HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE);
     if (SUCCEEDED(hrc))
-#endif
+# endif
     {
         pState->fDidSomething = true;
@@ -1798,13 +1798,13 @@
         return VINF_SUCCESS;
     }
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     LogRel(("nemHCWinHandleMemoryAccessPageCheckerCallback/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhys, rc));
     return rc;
-#else
+# else
     LogRel(("nemHCWinHandleMemoryAccessPageCheckerCallback/unmap: GCPhysDst=%RGp %s hrc=%Rhrc (%#x) Last=%#x/%u (cMappedPages=%u)\n",
             GCPhys, g_apszPageStates[u2State], hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue(),
             pVM->nem.s.cMappedPages));
 
-    PGMPhysNemEnumPagesByState(pVM, pVCpu, NEM_WIN_PAGE_STATE_READABLE, nemR3WinUnmapOnePageCallback, NULL);
+    PGMPhysNemEnumPagesByState(pVM, pVCpu, NEM_WIN_PAGE_STATE_READABLE, nemHCWinUnmapOnePageCallback, NULL);
     Log(("nemHCWinHandleMemoryAccessPageCheckerCallback: Unmapped all (cMappedPages=%u)\n", pVM->nem.s.cMappedPages));
 
@@ -1813,7 +1813,8 @@
     pInfo->u2NemState = NEM_WIN_PAGE_STATE_UNMAPPED;
     return VINF_SUCCESS;
-#endif
-}
-
+# endif
+}
+
+#endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) */
 
 
@@ -4513,4 +4514,5 @@
 
 #endif /* defined(NEM_WIN_TEMPLATE_MODE_OWN_RUN_API) || defined(IN_RING3) */
+#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3)
 
 /**
@@ -4523,12 +4525,12 @@
     if (pInfo->u2NemState > NEM_WIN_PAGE_STATE_UNMAPPED)
     {
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
         int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys);
         AssertRC(rc);
         if (RT_SUCCESS(rc))
-#else
+# else
         HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE);
         if (SUCCEEDED(hrc))
-#endif
+# endif
         {
             uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
@@ -4538,12 +4540,12 @@
         else
         {
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
             LogRel(("nemHCWinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc));
             return rc;
-#else
+# else
             LogRel(("nemHCWinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp hrc=%Rhrc (%#x) Last=%#x/%u\n",
                     GCPhys, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue()));
             return VERR_NEM_IPE_2;
-#endif
+# endif
         }
     }
@@ -4568,4 +4570,5 @@
 }
 
+#endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) */
 
 void nemHCNativeNotifyHandlerPhysicalRegister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb)
@@ -4594,4 +4597,5 @@
 
 
+#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3)
 /**
  * Worker that maps pages into Hyper-V.
@@ -4615,5 +4619,5 @@
                                            uint32_t fPageProt, uint8_t *pu2State, bool fBackingChanged)
 {
-#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     /*
      * When using the hypercalls instead of the ring-3 APIs, we don't need to
@@ -4685,5 +4689,5 @@
     return VINF_SUCCESS;
 
-#else
+# else /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
     /*
      * Looks like we need to unmap a page before we can change the backing
@@ -4691,4 +4695,5 @@
      * PGM lends us two bits to keep track of the state here.
      */
+    RT_NOREF(pVCpu);
     uint8_t const u2OldState = *pu2State;
     uint8_t const u2NewState = fPageProt & NEM_PAGE_PROT_WRITE ? NEM_WIN_PAGE_STATE_WRITABLE
@@ -4699,5 +4704,5 @@
         if (u2OldState > NEM_WIN_PAGE_STATE_UNMAPPED)
         {
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
             int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhysDst);
             AssertRC(rc);
@@ -4718,5 +4723,5 @@
                 return rc;
             }
-# else
+#  else
             HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhysDst, X86_PAGE_SIZE);
             if (SUCCEEDED(hrc))
@@ -4737,5 +4742,5 @@
                 return VERR_NEM_INIT_FAILED;
             }
-# endif
+#  endif
         }
     }
@@ -4746,5 +4751,5 @@
     if (fPageProt & NEM_PAGE_PROT_WRITE)
     {
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
         int rc = nemHCWinHypercallMapPage(pVM, pVCpu, GCPhysSrc, GCPhysDst,
                                             HV_MAP_GPA_READABLE   | HV_MAP_GPA_WRITABLE
@@ -4761,5 +4766,5 @@
         LogRel(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
         return rc;
-# else
+#  else
         void *pvPage;
         int rc = nemR3NativeGCPhys2R3PtrWriteable(pVM, GCPhysSrc, &pvPage);
@@ -4782,10 +4787,10 @@
         LogRel(("nemHCNativeSetPhysPage/writable: GCPhysSrc=%RGp rc=%Rrc\n", GCPhysSrc, rc));
         return rc;
-# endif
+#  endif
     }
 
     if (fPageProt & NEM_PAGE_PROT_READ)
     {
-# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+#  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);
@@ -4801,5 +4806,5 @@
         LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
         return rc;
-# else
+#  else
         const void *pvPage;
         int rc = nemR3NativeGCPhys2R3PtrReadOnly(pVM, GCPhysSrc, &pvPage);
@@ -4822,5 +4827,5 @@
         LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysSrc=%RGp rc=%Rrc\n", GCPhysSrc, rc));
         return rc;
-# endif
+#  endif
     }
 
@@ -4828,6 +4833,7 @@
     *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED;
     return VINF_SUCCESS;
-#endif /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
-}
+# endif /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
+}
+#endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) */
 
 
@@ -4841,5 +4847,5 @@
     }
 
-#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)
+#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES)
     PVMCPUCC pVCpu = VMMGetCpu(pVM);
     int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhysDst);
@@ -4854,5 +4860,5 @@
     LogRel(("nemHCJustUnmapPageFromHyperV/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
     return rc;
-#else
+#elif defined(IN_RING3)
     HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhysDst & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK, X86_PAGE_SIZE);
     if (SUCCEEDED(hrc))
@@ -4866,4 +4872,8 @@
             GCPhysDst, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue()));
     return VERR_NEM_IPE_6;
+#else
+    RT_NOREF(pVM, GCPhysDst, pu2State);
+    LogRel(("nemHCJustUnmapPageFromHyperV(%RGp): Why are we here?!?\n", GCPhysDst));
+    return VERR_NEM_IPE_6;
 #endif
 }
@@ -4878,5 +4888,5 @@
 
     int rc;
-#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     PVMCPUCC pVCpu = VMMGetCpu(pVM);
     if (   pVM->nem.s.fA20Enabled
@@ -4895,7 +4905,7 @@
     if (   pVM->nem.s.fA20Enabled
         || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
-        rc = nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
+        rc = nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys))
-        rc = nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
+        rc = nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     else
         rc = VINF_SUCCESS; /* ignore since we've got the alias page at this address. */
@@ -4912,5 +4922,5 @@
     RT_NOREF_PV(HCPhys); RT_NOREF_PV(enmType);
 
-#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     PVMCPUCC pVCpu = VMMGetCpu(pVM);
     if (   pVM->nem.s.fA20Enabled
@@ -4928,7 +4938,7 @@
     if (   pVM->nem.s.fA20Enabled
         || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
-        nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
+        nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys))
-        nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
+        nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     /* else: ignore since we've got the alias page at this address. */
 #endif
@@ -4943,5 +4953,5 @@
     RT_NOREF_PV(HCPhysPrev); RT_NOREF_PV(HCPhysNew); RT_NOREF_PV(enmType);
 
-#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     PVMCPUCC pVCpu = VMMGetCpu(pVM);
     if (   pVM->nem.s.fA20Enabled
@@ -4959,7 +4969,7 @@
     if (   pVM->nem.s.fA20Enabled
         || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
-        nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
+        nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys))
-        nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
+        nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     /* else: ignore since we've got the alias page at this address. */
 #endif
Index: /trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp	(revision 91691)
+++ /trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp	(revision 91692)
@@ -68,4 +68,5 @@
 *   Global Variables                                                                                                             *
 *********************************************************************************************************************************/
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
 static uint64_t (*g_pfnHvlInvokeHypercall)(uint64_t uCallInfo, uint64_t HCPhysInput, uint64_t HCPhysOutput);
 
@@ -91,7 +92,9 @@
 decltype(WinHvGetPartitionProperty) *g_pfnWinHvGetPartitionProperty;
 RT_C_DECLS_END
+#endif
 
 /** @name VID.SYS image details.
  * @{ */
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
 static uint8_t                                 *g_pbVidSys                            = NULL;
 static uintptr_t                                g_cbVidSys                            = 0;
@@ -102,4 +105,5 @@
 /** 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.   */
@@ -392,4 +396,5 @@
     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
@@ -464,8 +469,10 @@
         }
     }
+#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
 
     return rc;
 }
 
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
 
 /**
@@ -490,5 +497,5 @@
                                              void *pvOutput, uint32_t cbOutput)
 {
-#ifdef RT_STRICT
+# ifdef RT_STRICT
     /*
      * Input and output parameters are part of the VM CPU structure.
@@ -499,5 +506,5 @@
     if (pvOutput)
         AssertReturn(((uintptr_t)pvOutput + cbOutput) - (uintptr_t)pGVCpu <= sizeof(*pGVCpu), VERR_INVALID_PARAMETER);
-#endif
+# endif
 
     int32_t rcNt = STATUS_UNSUCCESSFUL;
@@ -795,4 +802,5 @@
 }
 
+#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
 
 /**
@@ -808,7 +816,8 @@
     AssertRCReturn(rc, rc);
     SUPR0Printf("NEMR0InitVMPart2\n"); LogRel(("2: NEMR0InitVMPart2\n"));
-#ifdef NEM_WIN_WITH_RING0_RUNLOOP
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
+# ifdef NEM_WIN_WITH_RING0_RUNLOOP
     Assert(pGVM->nemr0.s.fMayUseRing0Runloop == false);
-#endif
+# endif
 
     /*
@@ -827,5 +836,5 @@
     pGVM->nemr0.s.IoCtlGetPartitionProperty = Copy;
 
-#ifdef NEM_WIN_WITH_RING0_RUNLOOP
+# ifdef NEM_WIN_WITH_RING0_RUNLOOP
     pGVM->nemr0.s.fMayUseRing0Runloop = pGVM->nem.s.fUseRing0Runloop;
 
@@ -858,5 +867,5 @@
     if (RT_SUCCESS(rc))
         pGVM->nemr0.s.IoCtlMessageSlotHandleAndGetNext = Copy;
-#endif
+# endif
 
     if (   RT_SUCCESS(rc)
@@ -880,8 +889,8 @@
         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
+# 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
+# else
         /*
          * Since 2021 (Win11) the above I/O control doesn't work on exo-partitions
@@ -903,5 +912,5 @@
         if (pGVM->nem.s.idHvPartition == HV_PARTITION_ID_INVALID)
             pGVM->nem.s.idHvPartition = pGVM->nemr0.s.idHvPartition;
-#endif
+# 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),
@@ -910,4 +919,5 @@
             rc = VERR_NEM_INIT_FAILED;
     }
+#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
 
     return rc;
@@ -925,4 +935,5 @@
 VMMR0_INT_DECL(void) NEMR0CleanupVM(PGVM pGVM)
 {
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     pGVM->nemr0.s.idHvPartition = HV_PARTITION_ID_INVALID;
 
@@ -944,4 +955,7 @@
         RTCritSectDelete(&pGVM->nemr0.s.HypercallDataCritSect);
     nemR0DeleteHypercallData(&pGVM->nemr0.s.HypercallData);
+#else
+    RT_NOREF(pGVM);
+#endif
 }
 
@@ -970,4 +984,5 @@
 
 
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
 /**
  * Worker for NEMR0MapPages and others.
@@ -1042,4 +1057,5 @@
     }
 }
+#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
 
 
@@ -1058,4 +1074,5 @@
 VMMR0_INT_DECL(int) NEMR0MapPages(PGVM pGVM, VMCPUID idCpu)
 {
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     /*
      * Unpack the call.
@@ -1077,7 +1094,12 @@
     }
     return rc;
+#else
+    RT_NOREF(pGVM, idCpu);
+    return  VERR_NOT_IMPLEMENTED;
+#endif
 }
 
 
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
 /**
  * Worker for NEMR0UnmapPages and others.
@@ -1109,9 +1131,9 @@
     if (uResult == ((uint64_t)cPages << 32))
     {
-#if 1       /* Do we need to do this? Hopefully not... */
+# 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
+# endif
         return VINF_SUCCESS;
     }
@@ -1120,4 +1142,5 @@
     return VERR_NEM_UNMAP_PAGES_FAILED;
 }
+#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
 
 
@@ -1136,4 +1159,5 @@
 VMMR0_INT_DECL(int) NEMR0UnmapPages(PGVM pGVM, VMCPUID idCpu)
 {
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     /*
      * Unpack the call.
@@ -1153,4 +1177,8 @@
     }
     return rc;
+#else
+    RT_NOREF(pGVM, idCpu);
+    return  VERR_NOT_IMPLEMENTED;
+#endif
 }
 
@@ -3006,4 +3034,5 @@
 VMMR0_INT_DECL(int)  NEMR0UpdateStatistics(PGVM pGVM, VMCPUID idCpu)
 {
+#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     /*
      * Validate the call.
@@ -3065,8 +3094,11 @@
     }
     return rc;
+#else
+    RT_NOREF(pGVM, idCpu);
+    return VINF_SUCCESS;
+#endif
 }
 
 
-#if 1 && defined(DEBUG_bird)
 /**
  * Debug only interface for poking around and exploring Hyper-V stuff.
@@ -3078,4 +3110,5 @@
 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.
@@ -3164,5 +3197,8 @@
     }
     return rc;
+#else   /* !DEBUG_bird */
+    RT_NOREF(pGVM, idCpu, u64Arg);
+    return VERR_NOT_SUPPORTED;
+#endif /* !DEBUG_bird */
 }
-#endif /* DEBUG_bird */
-
+
Index: /trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp	(revision 91691)
+++ /trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp	(revision 91692)
@@ -174,8 +174,10 @@
 /** Pointer to the NtDeviceIoControlFile import table entry. */
 static decltype(NtDeviceIoControlFile) **g_ppfnVidNtDeviceIoControlFile;
+#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(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. */
@@ -241,4 +243,6 @@
 *   Internal Functions                                                                                                           *
 *********************************************************************************************************************************/
+DECLINLINE(int) nemR3NativeGCPhys2R3PtrReadOnly(PVM pVM, RTGCPHYS GCPhys, const void **ppv);
+DECLINLINE(int) nemR3NativeGCPhys2R3PtrWriteable(PVM pVM, RTGCPHYS GCPhys, void **ppv);
 
 /*
@@ -791,4 +795,5 @@
 }
 
+#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED)
 
 /**
@@ -845,4 +850,5 @@
 }
 
+#endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED) */
 #if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED)
 
@@ -985,4 +991,6 @@
 static int nemR3WinInitDiscoverIoControlProperties(PVM pVM, PRTERRINFO pErrInfo)
 {
+    RT_NOREF(pVM, pErrInfo);
+
     /*
      * Probe the I/O control information for select VID APIs so we can use
@@ -990,4 +998,5 @@
      *
      */
+#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED)
     decltype(NtDeviceIoControlFile) * const pfnOrg = *g_ppfnVidNtDeviceIoControlFile;
 
@@ -1019,4 +1028,5 @@
             g_IoCtlGetPartitionProperty.uFunction, g_IoCtlGetPartitionProperty.cbInput, g_IoCtlGetPartitionProperty.cbOutput));
 
+#endif
     int rcRet = VINF_SUCCESS;
 #if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED)
@@ -1103,6 +1113,8 @@
 
     /* 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;
Index: /trunk/src/VBox/VMM/include/NEMInternal.h
===================================================================
--- /trunk/src/VBox/VMM/include/NEMInternal.h	(revision 91691)
+++ /trunk/src/VBox/VMM/include/NEMInternal.h	(revision 91692)
@@ -48,6 +48,6 @@
  */
 # define NEM_WIN_USE_HYPERCALLS_FOR_PAGES
-//# 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_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. */
@@ -193,8 +193,10 @@
     uint32_t volatile           cMappedPages;
 
+#  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. */
@@ -371,5 +373,5 @@
 typedef struct NEMR0PERVCPU
 {
-# ifdef RT_OS_WINDOWS
+# if defined(RT_OS_WINDOWS) && defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES)
     /** Hypercall input/ouput page. */
     NEMR0HYPERCALLDATA          HypercallData;
@@ -387,4 +389,5 @@
 {
 # ifdef RT_OS_WINDOWS
+#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     /** The partition ID. */
     uint64_t                    idHvPartition;
@@ -395,4 +398,5 @@
     /** 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. */
@@ -406,8 +410,10 @@
 #  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
