Index: trunk/src/VBox/VMM/include/PDMInternal.h
===================================================================
--- trunk/src/VBox/VMM/include/PDMInternal.h	(revision 107984)
+++ trunk/src/VBox/VMM/include/PDMInternal.h	(revision 108132)
@@ -48,8 +48,9 @@
 #include <VBox/vmm/pdmcommon.h>
 #include <VBox/vmm/pdmtask.h>
-#ifdef VBOX_VMM_TARGET_ARMV8
+#if defined(VBOX_VMM_TARGET_X86) || defined(VBOX_VMM_TARGET_AGNOSTIC)
+# include <VBox/vmm/pdmapic.h>
+#endif
+#if defined(VBOX_VMM_TARGET_ARMV8) || defined(VBOX_VMM_TARGET_AGNOSTIC)
 # include <VBox/vmm/pdmgic.h>
-#else
-# include <VBox/vmm/pdmapic.h>
 #endif
 #include <VBox/sup.h>
@@ -1828,15 +1829,17 @@
 #  define PDM_TO_APICBACKEND(a_pVM)          (&((a_pVM)->pdm.s.Ic.u.x86.ApicBackend))
 #  define PDMCPU_TO_APICBACKEND(a_pVCpu)     (&((a_pVCpu)->CTX_SUFF(pVM)->pdm.s.Ic.u.x86.ApicBackend))
-#else
+# else
 #  define PDM_TO_APICBACKEND(a_pVM)          (&((a_pVM)->pdmr0.s.Ic.u.x86.ApicBackend))
 #  define PDMCPU_TO_APICBACKEND(a_pVCpu)     (&((a_pVCpu)->CTX_SUFF(pVM)->pdmr0.s.Ic.u.x86.ApicBackend))
-#endif
+# endif
 #else
 # ifdef IN_RING3
 #  define PDM_TO_GICBACKEND(a_pVM)           (&((a_pVM)->pdm.s.Ic.u.armv8.GicBackend))
 #  define PDMCPU_TO_GICBACKEND(a_pVCpu)      (&((a_pVCpu)->CTX_SUFF(pVM)->pdm.s.Ic.u.armv8.GicBackend))
-#else
-# error "Implement me"
-#endif
+# else
+#  ifndef VBOX_WITH_MINIMAL_R0 /* hack for AllPdbTypeHack.cpp */
+#   error "Implement me"
+#  endif
+# endif
 #endif
 
Index: trunk/src/VBox/VMM/include/PGMInline.h
===================================================================
--- trunk/src/VBox/VMM/include/PGMInline.h	(revision 107984)
+++ trunk/src/VBox/VMM/include/PGMInline.h	(revision 108132)
@@ -1162,4 +1162,5 @@
 }
 
+#ifndef VBOX_WITH_ONLY_PGM_NEM_MODE
 
 /**
@@ -1190,14 +1191,14 @@
      * Just deal with the simple case here.
      */
-#ifdef VBOX_STRICT
+# ifdef VBOX_STRICT
     PVMCC pVM = pPool->CTX_SUFF(pVM); NOREF(pVM);
-#endif
-#ifdef LOG_ENABLED
+# endif
+# ifdef LOG_ENABLED
     const unsigned uOrg = PGM_PAGE_GET_TRACKING(pPhysPage);
-#endif
+# endif
     const unsigned cRefs = PGM_PAGE_GET_TD_CREFS(pPhysPage);
     if (cRefs == 1)
     {
-#if 0 /* for more debug info */
+# if 0 /* for more debug info */
         AssertMsg(   pPoolPage->idx == PGM_PAGE_GET_TD_IDX(pPhysPage)
                   && iPte == PGM_PAGE_GET_PTE_INDEX(pPhysPage),
@@ -1207,8 +1208,8 @@
                    pPool->aPages[PGM_PAGE_GET_TD_IDX(pPhysPage)].enmKind,
                    ((uint64_t *)pPoolPage->CTX_SUFF(pvPage))[iPte]));
-#else
+# else
         Assert(pPoolPage->idx == PGM_PAGE_GET_TD_IDX(pPhysPage));
         Assert(iPte == PGM_PAGE_GET_PTE_INDEX(pPhysPage));
-#endif
+# endif
         /* Invalidate the tracking data. */
         PGM_PAGE_SET_TRACKING(pVM, pPhysPage, 0);
@@ -1316,4 +1317,5 @@
 }
 
+#endif /* !VBOX_WITH_ONLY_PGM_NEM_MODE */
 
 /** @} */
Index: trunk/src/VBox/VMM/include/PGMInternal.h
===================================================================
--- trunk/src/VBox/VMM/include/PGMInternal.h	(revision 107984)
+++ trunk/src/VBox/VMM/include/PGMInternal.h	(revision 108132)
@@ -76,5 +76,5 @@
  * Optimization for PAE page tables that are modified often
  */
-#ifndef VBOX_VMM_TARGET_ARMV8
+#if !defined(VBOX_VMM_TARGET_ARMV8) && !defined(VBOX_WITH_ONLY_PGM_NEM_MODE)
 # define PGMPOOL_WITH_OPTIMIZED_DIRTY_PT
 #endif
@@ -2513,5 +2513,9 @@
 /** @name A20 gate macros
  * @{ */
-#define PGM_WITH_A20
+#if defined(VBOX_VMM_TARGET_X86) || defined(DOXYGEN_RUNNING)
+# define PGM_WITH_A20
+#elif !defined(VBOX_VMM_TARGET_ARMV8) && !defined(IN_TSTVMSTRUCT)
+# error "Misconfig"
+#endif
 #ifdef PGM_WITH_A20
 # define PGM_A20_IS_ENABLED(a_pVCpu)                        ((a_pVCpu)->pgm.s.fA20Enabled)
@@ -4000,4 +4004,5 @@
 void            pgmR3PhysAssertSharedPageChecksums(PVM pVM);
 
+# ifndef VBOX_WITH_ONLY_PGM_NEM_MODE
 int             pgmR3PoolInit(PVM pVM);
 void            pgmR3PoolRelocate(PVM pVM);
@@ -4007,9 +4012,11 @@
 DECLCALLBACK(VBOXSTRICTRC) pgmR3PoolClearAllRendezvous(PVM pVM, PVMCPU pVCpu, void *fpvFlushRemTbl);
 void            pgmR3PoolWriteProtectPages(PVM pVM);
+# endif
 
 #endif /* IN_RING3 */
-#ifdef IN_RING0
+#ifndef VBOX_WITH_ONLY_PGM_NEM_MODE
+# ifdef IN_RING0
 int             pgmR0PoolInitVM(PGVM pGVM);
-#endif
+# endif
 int             pgmPoolAlloc(PVMCC pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, PGMPOOLACCESS enmAccess, bool fA20Enabled,
                              uint16_t iUser, uint32_t iUserTable, bool fLockPage, PPPGMPOOLPAGE ppPage);
@@ -4076,4 +4083,5 @@
 int             pgmR3ReEnterShadowModeAfterPoolFlush(PVM pVM, PVMCPU pVCpu);
 void            pgmR3RefreshShadowModeAfterA20Change(PVMCPU pVCpu);
+#endif  /* !VBOX_WITH_ONLY_PGM_NEM_MODE */
 
 int             pgmShwMakePageSupervisorAndWritable(PVMCPUCC pVCpu, RTGCPTR GCPtr, bool fBigPage, uint32_t fOpFlags);
