Index: trunk/include/VBox/vmm/dbgf.h
===================================================================
--- trunk/include/VBox/vmm/dbgf.h	(revision 107226)
+++ trunk/include/VBox/vmm/dbgf.h	(revision 107227)
@@ -1812,6 +1812,7 @@
 typedef enum DBGFREG
 {
+    DBGFREG_X86_FIRST = 0,
     /* General purpose registers: */
-    DBGFREG_AL  = 0,
+    DBGFREG_AL  = DBGFREG_X86_FIRST,
     DBGFREG_AX  = DBGFREG_AL,
     DBGFREG_EAX = DBGFREG_AL,
@@ -2055,6 +2056,8 @@
     DBGFREG_IDTR,
 
-    /** The end of the x86 registers. */
-    DBGFREG_X86_END = DBGFREG_IDTR,
+    /** The last of the x86 registers. */
+    DBGFREG_X86_LAST = DBGFREG_IDTR,
+    /* Misnomer. */
+    DBGFREG_X86_END = DBGFREG_X86_LAST,
 
     /** @name ARMv8 register identifiers.
Index: trunk/include/VBox/vmm/pgm.h
===================================================================
--- trunk/include/VBox/vmm/pgm.h	(revision 107226)
+++ trunk/include/VBox/vmm/pgm.h	(revision 107227)
@@ -1328,5 +1328,7 @@
                                          const void *pvBinary, uint32_t cbBinary, uint8_t fFlags, const char *pszDesc);
 VMMR3DECL(int)      PGMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMROMPROT enmProt);
+# if defined(VBOX_VMM_TARGET_X86) || defined(VBOX_VMM_TARGET_AGNOSTIC)
 VMMDECL(void)       PGMR3PhysSetA20(PVMCPU pVCpu, bool fEnable);
+# endif
 
 VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags,
Index: trunk/include/VBox/vmm/tm.h
===================================================================
--- trunk/include/VBox/vmm/tm.h	(revision 107226)
+++ trunk/include/VBox/vmm/tm.h	(revision 107227)
@@ -172,5 +172,5 @@
 VMM_INT_DECL(bool)      TMCpuTickIsTicking(PVMCPUCC pVCpu);
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
 VMM_INT_DECL(void)      TMCpuSetVTimerNextActivation(PVMCPUCC pVCpu, uint64_t cNanoSecs);
 VMM_INT_DECL(uint64_t)  TMCpuGetVTimerActivationNano(PVMCPUCC pVCpu);
Index: trunk/include/VBox/vmm/vm.h
===================================================================
--- trunk/include/VBox/vmm/vm.h	(revision 107226)
+++ trunk/include/VBox/vmm/vm.h	(revision 107227)
@@ -56,4 +56,11 @@
 # pragma D depends_on library CPUMInternal.d
 # define VMM_INCLUDED_SRC_include_CPUMInternal_h
+# define VBOX_VMM_TARGET_AGNOSTIC
+#endif
+
+#if !defined(VBOX_VMM_TARGET_AGNOSTIC) \
+ && !defined(VBOX_VMM_TARGET_X86) \
+ && !defined(VBOX_VMM_TARGET_ARMV8)
+# error "VMM target not defined"
 #endif
 
@@ -130,5 +137,5 @@
     VMCPUSTATE volatile     enmState;
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
     uint32_t                u32Alignment0;
     /** The number of nano seconds when the vTimer of the associated vCPU is supposed to activate
@@ -288,23 +295,29 @@
     } gim;
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    /** GIC part. */
-    union VMCPUUNIONGIC
-    {
+    /* Interrupt controller, target specific. */
+    RT_GCC_EXTENSION
+    union
+    {
+#if defined(VBOX_VMM_TARGET_ARMV8) || defined(VBOX_VMM_TARGET_AGNOSTIC)
+        /** GIC part. */
+        union
+        {
 # ifdef VMM_INCLUDED_SRC_include_GICInternal_h
-        struct GICCPU       s;
+            struct GICCPU       s;
 # endif
-        uint8_t             padding[3840];      /* multiple of 64 */
-    } gic;
-#else
-    /** APIC part. */
-    union VMCPUUNIONAPIC
-    {
+            uint8_t             padding[3840];      /* multiple of 64 */
+        } gic;
+#endif
+#if defined(VBOX_VMM_TARGET_X86) || defined(VBOX_VMM_TARGET_AGNOSTIC)
+        /** APIC part. */
+        union
+        {
 # ifdef VMM_INCLUDED_SRC_include_APICInternal_h
-        struct APICCPU      s;
+            struct APICCPU      s;
 # endif
-        uint8_t             padding[3840];      /* multiple of 64 */
-    } apic;
-#endif
+            uint8_t             padding[3840];      /* multiple of 64 */
+        } apic;
+#endif
+    };
 
     /*
@@ -483,5 +496,5 @@
 
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_ARMV8) || defined(VBOX_VMM_TARGET_AGNOSTIC)
 /** This action forces the VM to inject an IRQ into the guest. */
 # define VMCPU_FF_INTERRUPT_IRQ             RT_BIT_64(VMCPU_FF_INTERRUPT_IRQ_BIT)
@@ -490,5 +503,6 @@
 # define VMCPU_FF_INTERRUPT_FIQ             RT_BIT_64(VMCPU_FF_INTERRUPT_FIQ_BIT)
 # define VMCPU_FF_INTERRUPT_FIQ_BIT         1
-#else
+#endif
+#if defined(VBOX_VMM_TARGET_X86) || defined(VBOX_VMM_TARGET_AGNOSTIC)
 /** This action forces the VM to check any pending interrupts on the APIC. */
 # define VMCPU_FF_INTERRUPT_APIC            RT_BIT_64(VMCPU_FF_INTERRUPT_APIC_BIT)
@@ -541,8 +555,9 @@
 #define VMCPU_FF_HM_UPDATE_CR3              RT_BIT_64(VMCPU_FF_HM_UPDATE_CR3_BIT)
 #define VMCPU_FF_HM_UPDATE_CR3_BIT          12
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_ARMV8) || defined(VBOX_VMM_TARGET_AGNOSTIC)
 # define VMCPU_FF_VTIMER_ACTIVATED          RT_BIT_64(VMCPU_FF_VTIMER_ACTIVATED_BIT)
 # define VMCPU_FF_VTIMER_ACTIVATED_BIT      13
-#else
+#endif
+#if defined(VBOX_VMM_TARGET_X86) || defined(VBOX_VMM_TARGET_AGNOSTIC)
 /* Bit 13 used to be VMCPU_FF_HM_UPDATE_PAE_PDPES. */
 #endif
@@ -618,15 +633,18 @@
 #define VM_FF_EXTERNAL_HALTED_MASK              (  VM_FF_CHECK_VM_STATE | VM_FF_DBGF    | VM_FF_REQUEST \
                                                  | VM_FF_PDM_QUEUES     | VM_FF_PDM_DMA | VM_FF_EMT_RENDEZVOUS )
+
+#ifndef VBOX_VMM_TARGET_AGNOSTIC
 /** Externally forced VMCPU actions. Used to quit the idle/wait loop. */
-#if defined(VBOX_VMM_TARGET_ARMV8)
-# define VMCPU_FF_EXTERNAL_HALTED_MASK          (  VMCPU_FF_INTERRUPT_IRQ | VMCPU_FF_INTERRUPT_FIQ \
+# if defined(VBOX_VMM_TARGET_ARMV8)
+#  define VMCPU_FF_EXTERNAL_HALTED_MASK         (  VMCPU_FF_INTERRUPT_IRQ | VMCPU_FF_INTERRUPT_FIQ \
                                                  | VMCPU_FF_REQUEST       | VMCPU_FF_INTERRUPT_NMI  | VMCPU_FF_INTERRUPT_SMI \
                                                  | VMCPU_FF_UNHALT        | VMCPU_FF_TIMER          | VMCPU_FF_DBGF \
                                                  | VMCPU_FF_VTIMER_ACTIVATED)
-#else
-# define VMCPU_FF_EXTERNAL_HALTED_MASK          (  VMCPU_FF_UPDATE_APIC | VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC \
+# else
+#  define VMCPU_FF_EXTERNAL_HALTED_MASK         (  VMCPU_FF_UPDATE_APIC | VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC \
                                                  | VMCPU_FF_REQUEST     | VMCPU_FF_INTERRUPT_NMI  | VMCPU_FF_INTERRUPT_SMI \
                                                  | VMCPU_FF_UNHALT      | VMCPU_FF_TIMER          | VMCPU_FF_DBGF \
                                                  | VMCPU_FF_INTERRUPT_NESTED_GUEST)
+# endif
 #endif
 
@@ -635,14 +653,16 @@
                                                  | VM_FF_DEBUG_SUSPEND  | VM_FF_PGM_NEED_HANDY_PAGES | VM_FF_PGM_NO_MEMORY \
                                                  | VM_FF_EMT_RENDEZVOUS )
+#ifndef VBOX_VMM_TARGET_AGNOSTIC
 /** High priority VMCPU pre-execution actions. */
-#if defined(VBOX_VMM_TARGET_ARMV8)
-# define VMCPU_FF_HIGH_PRIORITY_PRE_MASK        (  VMCPU_FF_TIMER        | VMCPU_FF_INTERRUPT_IRQ     | VMCPU_FF_INTERRUPT_FIQ \
+# if defined(VBOX_VMM_TARGET_ARMV8)
+#  define VMCPU_FF_HIGH_PRIORITY_PRE_MASK       (  VMCPU_FF_TIMER        | VMCPU_FF_INTERRUPT_IRQ     | VMCPU_FF_INTERRUPT_FIQ \
                                                  | VMCPU_FF_DBGF )
-#else
-# define VMCPU_FF_HIGH_PRIORITY_PRE_MASK        (  VMCPU_FF_TIMER        | VMCPU_FF_INTERRUPT_APIC     | VMCPU_FF_INTERRUPT_PIC \
+# else
+#  define VMCPU_FF_HIGH_PRIORITY_PRE_MASK       (  VMCPU_FF_TIMER        | VMCPU_FF_INTERRUPT_APIC     | VMCPU_FF_INTERRUPT_PIC \
                                                  | VMCPU_FF_UPDATE_APIC  | VMCPU_FF_DBGF \
                                                  | VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL \
                                                  | VMCPU_FF_INTERRUPT_NESTED_GUEST | VMCPU_FF_VMX_MTF  | VMCPU_FF_VMX_APIC_WRITE \
                                                  | VMCPU_FF_VMX_PREEMPT_TIMER | VMCPU_FF_VMX_NMI_WINDOW | VMCPU_FF_VMX_INT_WINDOW )
+# endif
 #endif
 
@@ -685,5 +705,5 @@
 #endif
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86) || defined(VBOX_VMM_TARGET_AGNOSTIC)
 /** VMCPU flags that cause the REP[|NE|E] STRINS loops to yield, interrupts
  *  enabled. */
@@ -1504,21 +1524,27 @@
     } gim;
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    union
-    {
+    /** Interrupt controller, target specific. */
+    RT_GCC_EXTENSION
+    union
+    {
+#if defined(VBOX_VMM_TARGET_ARMV8) || defined(VBOX_VMM_TARGET_AGNOSTIC)
+        union
+        {
 # ifdef VMM_INCLUDED_SRC_include_GICInternal_h
-        struct GIC  s;
+            struct GIC  s;
 # endif
-        uint8_t     padding[128];       /* multiple of 8 */
-    } gic;
-#else
-    union
-    {
+            uint8_t     padding[128];   /* multiple of 8 */
+        } gic;
+#endif
+#if defined(VBOX_VMM_TARGET_X86) || defined(VBOX_VMM_TARGET_AGNOSTIC)
+        union
+        {
 # ifdef VMM_INCLUDED_SRC_include_APICInternal_h
-        struct APIC s;
+            struct APIC s;
 # endif
-        uint8_t     padding[128];       /* multiple of 8 */
-    } apic;
-#endif
+            uint8_t     padding[128];   /* multiple of 8 */
+        } apic;
+#endif
+    };
 
     /* ---- begin small stuff ---- */
Index: trunk/src/VBox/HostDrivers/Support/testcase/Makefile.kmk
===================================================================
--- trunk/src/VBox/HostDrivers/Support/testcase/Makefile.kmk	(revision 107226)
+++ trunk/src/VBox/HostDrivers/Support/testcase/Makefile.kmk	(revision 107227)
@@ -83,5 +83,5 @@
 
 tstInt_TEMPLATE       = VBoxR3SignedExe
-tstInt_DEFS           = $(VMM_COMMON_DEFS)
+tstInt_DEFS           = VBOX_VMM_TARGET_AGNOSTIC $(VMM_COMMON_DEFS)
 tstInt_SOURCES        = tstInt.cpp
 tstInt_LIBS           = $(LIB_RUNTIME)
Index: trunk/src/VBox/HostDrivers/Support/testcase/tstInt.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/Support/testcase/tstInt.cpp	(revision 107226)
+++ trunk/src/VBox/HostDrivers/Support/testcase/tstInt.cpp	(revision 107227)
@@ -106,5 +106,5 @@
             if (RT_SUCCESS(rc))
             {
-                PVM pVM = CreateVMReq.pVMR3;
+                PVM const pVM = CreateVMReq.pVMR3;
                 AssertRelease(RT_VALID_PTR(pVM));
                 AssertRelease(pVM->pVMR0ForCall == CreateVMReq.pVMR0);
Index: trunk/src/VBox/VMM/Makefile.kmk
===================================================================
--- trunk/src/VBox/VMM/Makefile.kmk	(revision 107226)
+++ trunk/src/VBox/VMM/Makefile.kmk	(revision 107227)
@@ -62,5 +62,5 @@
 VBoxVMM_SONAME.linux = VBoxVMM.so
 
-VBoxVMM_DEFS     = VBOX_IN_VMM IN_VMM_R3 IN_DIS IN_GMM_R3 IN_DBG $(VMM_COMMON_DEFS)
+VBoxVMM_DEFS     = VBOX_VMM_TARGET_X86 VBOX_IN_VMM IN_VMM_R3 IN_DIS IN_GMM_R3 IN_DBG $(VMM_COMMON_DEFS)
 ## @todo eliminate IN_GMM_R3
 ifdef VBOX_WITH_PREALLOC_RAM_BY_DEFAULT
@@ -835,5 +835,5 @@
  VMMR0_SYSSUFF   = .r0
 
- VMMR0_DEFS      = VBOX_IN_VMM IN_VMM_R0 IN_RT_R0 IN_DIS DIS_CORE_ONLY IN_GVMM_R0 IN_GMM_R0 IN_INTNET_R0 \
+ VMMR0_DEFS      = VBOX_VMM_TARGET_AGNOSTIC VBOX_IN_VMM IN_VMM_R0 IN_RT_R0 IN_DIS DIS_CORE_ONLY IN_GVMM_R0 IN_GMM_R0 IN_INTNET_R0 \
  	$(VMM_COMMON_DEFS) RTASSERT_HAVE_SHOULD_PANIC
  ## @todo eliminate IN_GVMM_R0 IN_GMM_R0
@@ -1043,5 +1043,5 @@
  LIBRARIES += SSMStandalone
  SSMStandalone_TEMPLATE = VBoxR3Exe
- SSMStandalone_DEFS    = VBOX_IN_VMM IN_VMM_R3 IN_VMM_STATIC SSM_STANDALONE CPUM_DB_STANDALONE $(VMM_COMMON_DEFS)
+ SSMStandalone_DEFS    = VBOX_VMM_TARGET_AGNOSTIC VBOX_IN_VMM IN_VMM_R3 IN_VMM_STATIC SSM_STANDALONE CPUM_DB_STANDALONE $(VMM_COMMON_DEFS)
  SSMStandalone_INCS    = include
  SSMStandalone_SOURCES = \
Index: trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp	(revision 107227)
@@ -661,5 +661,6 @@
 
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
+
 /**
  * Sets the number of nanoseconds from now when the vTiemr is supposed to expire next.
@@ -688,3 +689,4 @@
     return pVCpu->cNsVTimerActivate;
 }
-#endif
+
+#endif /* VBOX_VMM_TARGET_ARMV8 */
Index: trunk/src/VBox/VMM/VMMR3/DBGF.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGF.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/DBGF.cpp	(revision 107227)
@@ -1598,27 +1598,27 @@
          * Do minimal parsing.  No real need to involve the disassembler here.
          */
-        if (   (u32Insn & 0xfffffc1f) == 0xd65f0000 /* RET */
-            || (u32Insn & 0xfffffc1f) == 0xd65f081f /* RETAA */
-            || (u32Insn & 0xfffffc1f) == 0xd65f0c1f /* RETAB */
-            || (u32Insn & 0xffffffff) == 0xd69f03e0 /* ERET */
-            || (u32Insn & 0xffffffff) == 0xd69f0bff /* ERETAA */
-            || (u32Insn & 0xffffffff) == 0xd69f0fff /* ERETAB */)
+        if (   (u32Insn & UINT32_C(0xfffffc1f)) == UINT32_C(0xd65f0000) /* RET */
+            || (u32Insn & UINT32_C(0xfffffc1f)) == UINT32_C(0xd65f081f) /* RETAA */
+            || (u32Insn & UINT32_C(0xfffffc1f)) == UINT32_C(0xd65f0c1f) /* RETAB */
+            || (u32Insn & UINT32_C(0xffffffff)) == UINT32_C(0xd69f03e0) /* ERET */
+            || (u32Insn & UINT32_C(0xffffffff)) == UINT32_C(0xd69f0bff) /* ERETAA */
+            || (u32Insn & UINT32_C(0xffffffff)) == UINT32_C(0xd69f0fff) /* ERETAB */)
             return DBGFSTEPINSTRTYPE_RET;
-        else if (   (u32Insn & 0xfffffc1f) == 0xd63f0000 /* BLR */
-                 || (u32Insn & 0xfffffc1f) == 0xd63f081f /* BLRAAZ */
-                 || (u32Insn & 0xfffffc1f) == 0xd63f0c1f /* BLRABZ */
-                 || (u32Insn & 0xfffffc00) == 0xd73f0800 /* BLRAA */
-                 || (u32Insn & 0xfffffc00) == 0xd73f0c00 /* BLRAB */
-                 || (u32Insn & 0xfc000000) == 0x14000000 /* BL */
-                 || (u32Insn & 0xffe0001f) == 0xd4000001 /* SVC */
-                 || (u32Insn & 0xffe0001f) == 0xd4000002 /* HVC */
-                 || (u32Insn & 0xffe0001f) == 0xd4000003 /* SMC */
-                 || (u32Insn & 0xffe0001f) == 0xd4200000 /* BRK */
-                 || (u32Insn & 0xffe0001f) == 0xd4400000 /* HLT */)
+        if (   (u32Insn & UINT32_C(0xfffffc1f)) == UINT32_C(0xd63f0000) /* BLR */
+            || (u32Insn & UINT32_C(0xfffffc1f)) == UINT32_C(0xd63f081f) /* BLRAAZ */
+            || (u32Insn & UINT32_C(0xfffffc1f)) == UINT32_C(0xd63f0c1f) /* BLRABZ */
+            || (u32Insn & UINT32_C(0xfffffc00)) == UINT32_C(0xd73f0800) /* BLRAA */
+            || (u32Insn & UINT32_C(0xfffffc00)) == UINT32_C(0xd73f0c00) /* BLRAB */
+            || (u32Insn & UINT32_C(0xfc000000)) == UINT32_C(0x14000000) /* BL */
+            || (u32Insn & UINT32_C(0xffe0001f)) == UINT32_C(0xd4000001) /* SVC */
+            || (u32Insn & UINT32_C(0xffe0001f)) == UINT32_C(0xd4000002) /* HVC */
+            || (u32Insn & UINT32_C(0xffe0001f)) == UINT32_C(0xd4000003) /* SMC */
+            || (u32Insn & UINT32_C(0xffe0001f)) == UINT32_C(0xd4200000) /* BRK */
+            || (u32Insn & UINT32_C(0xffe0001f)) == UINT32_C(0xd4400000) /* HLT */)
             return DBGFSTEPINSTRTYPE_CALL;
-        else
-            return DBGFSTEPINSTRTYPE_OTHER;
-    }
-#else
+        return DBGFSTEPINSTRTYPE_OTHER;
+    }
+
+#elif defined(VBOX_VMM_TARGET_X86)
     /*
      * Read the instruction.
@@ -1694,4 +1694,7 @@
         }
     }
+
+#else
+# error "port me"
 #endif
 
Index: trunk/src/VBox/VMM/VMMR3/DBGFCoreWrite.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGFCoreWrite.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/DBGFCoreWrite.cpp	(revision 107227)
@@ -329,5 +329,8 @@
 static void dbgfR3GetCoreCpu(PVMCPU pVCpu, PDBGFCORECPU pDbgfCpu)
 {
-#define DBGFCOPYSEL(a_dbgfsel, a_cpumselreg) \
+    PCCPUMCTX const pCtx = CPUMQueryGuestCtxPtr(pVCpu);
+
+#ifdef VBOX_VMM_TARGET_X86
+# define DBGFCOPYSEL(a_dbgfsel, a_cpumselreg) \
     do { \
         (a_dbgfsel).uBase  = (a_cpumselreg).u64Base; \
@@ -337,10 +340,4 @@
     } while (0)
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    AssertReleaseFailed();
-    RT_NOREF(pVCpu, pDbgfCpu);
-#else
-    PVM       pVM  = pVCpu->CTX_SUFF(pVM);
-    PCCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu);
     pDbgfCpu->rax             = pCtx->rax;
     pDbgfCpu->rbx             = pCtx->rbx;
@@ -395,10 +392,19 @@
     pDbgfCpu->aXcr[1]         = pCtx->aXcr[1];
     AssertCompile(sizeof(pDbgfCpu->ext) == sizeof(pCtx->XState));
+
+    PVM const pVM  = pVCpu->CTX_SUFF(pVM);
     pDbgfCpu->cbExt = pVM->cpum.ro.GuestFeatures.cbMaxExtendedState;
     if (RT_LIKELY(pDbgfCpu->cbExt))
         memcpy(&pDbgfCpu->ext, &pCtx->XState, pDbgfCpu->cbExt);
+
+# undef DBGFCOPYSEL
+
+#elif defined(VBOX_VMM_TARGET_ARMV8)
+    RT_NOREF(pCtx, pDbgfCpu);
+    AssertReleaseFailed();
+
+#else
+# error "port me"
 #endif
-
-#undef DBGFCOPYSEL
 }
 
Index: trunk/src/VBox/VMM/VMMR3/DBGFCpu.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGFCpu.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/DBGFCpu.cpp	(revision 107227)
@@ -55,8 +55,10 @@
     Assert(idCpu == VMMGetCpuId(pVM));
     PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu);
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
     CPUM_IMPORT_EXTRN_RET(pVCpu, CPUMCTX_EXTRN_PSTATE);
+#elif defined(VBOX_VMM_TARGET_X86)
+    CPUM_IMPORT_EXTRN_RET(pVCpu, CPUMCTX_EXTRN_CR0 | CPUMCTX_EXTRN_EFER);
 #else
-    CPUM_IMPORT_EXTRN_RET(pVCpu, CPUMCTX_EXTRN_CR0 | CPUMCTX_EXTRN_EFER);
+# error "port me"
 #endif
     *penmMode = CPUMGetGuestMode(pVCpu);
@@ -98,8 +100,10 @@
     Assert(idCpu == VMMGetCpuId(pVM));
     PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu);
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
     CPUM_IMPORT_EXTRN_RET(pVCpu, CPUMCTX_EXTRN_PSTATE);
+#elif defined(VBOX_VMM_TARGET_X86)
+    CPUM_IMPORT_EXTRN_RET(pVCpu, CPUMCTX_EXTRN_CR0 | CPUMCTX_EXTRN_EFER);
 #else
-    CPUM_IMPORT_EXTRN_RET(pVCpu, CPUMCTX_EXTRN_CS | CPUMCTX_EXTRN_EFER);
+# error "port me"
 #endif
     *pfIn64BitCode = CPUMIsGuestIn64BitCode(pVCpu);
@@ -129,5 +133,5 @@
 
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
 /**
  * Wrapper around CPUMIsGuestInV86Code.
@@ -162,8 +166,5 @@
     AssertReturn(idCpu < pUVM->pVM->cCpus, false);
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    /* This is a public visible API, so we need to fill in a stub. */
-    return false;
-#else
+#ifdef VBOX_VMM_TARGET_X86
     bool fInV86Code;
     int rc = VMR3ReqPriorityCallWaitU(pUVM, idCpu, (PFNRT)dbgfR3CpuInV86Code, 3, pUVM->pVM, idCpu, &fInV86Code);
@@ -171,4 +172,6 @@
         return false;
     return fInV86Code;
+#else
+    return false;
 #endif
 }
Index: trunk/src/VBox/VMM/VMMR3/DBGFDisas.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGFDisas.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/DBGFDisas.cpp	(revision 107227)
@@ -68,5 +68,5 @@
     /** The address space for resolving symbol. */
     RTDBGAS         hDbgAs;
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
     /** Pointer to the first byte in the segment. */
     RTGCUINTPTR     GCPtrSegBase;
@@ -115,13 +115,12 @@
                                  RTGCPTR GCPtr, uint32_t fFlags, PDBGFDISASSTATE pState)
 {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifndef VBOX_VMM_TARGET_X86
+    RT_NOREF_PV(pSelInfo);
+    pState->f64Bits         = CPUMIsGuestIn64BitCode(pVCpu);
+#else
     pState->GCPtrSegBase    = pSelInfo->GCPtrBase;
     pState->GCPtrSegEnd     = pSelInfo->cbLimit + 1 + (RTGCUINTPTR)pSelInfo->GCPtrBase;
     pState->cbSegLimit      = pSelInfo->cbLimit;
     pState->f64Bits         = enmMode >= PGMMODE_AMD64 && pSelInfo->u.Raw.Gen.u1Long;
-#else
-    RT_NOREF(pSelInfo);
-
-    pState->f64Bits         = CPUMGetGuestCodeBits(pVCpu) == 64;
 #endif
     pState->enmMode         = enmMode;
@@ -142,5 +141,5 @@
             enmCpuMode = CPUMGetGuestDisMode(pVCpu);
             break;
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
         case DBGF_DISAS_FLAGS_16BIT_MODE:
         case DBGF_DISAS_FLAGS_16BIT_REAL_MODE:
@@ -153,5 +152,5 @@
             enmCpuMode = DISCPUMODE_64BIT;
             break;
-#else
+#elif defined(VBOX_VMM_TARGET_ARMV8)
         case DBGF_DISAS_FLAGS_16BIT_MODE: /** @todo r=aeichner This is a bit abusive... */
         case DBGF_DISAS_FLAGS_16BIT_REAL_MODE:
@@ -164,4 +163,6 @@
             enmCpuMode = DISCPUMODE_ARMV8_A64;
             break;
+#else
+# error "port me"
 #endif
     }
@@ -237,5 +238,5 @@
     for (;;)
     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
         RTGCUINTPTR GCPtr = pDis->uInstrAddr + offInstr + pState->GCPtrSegBase;
 #else
@@ -269,6 +270,5 @@
         }
 
-        uint32_t cb = GUEST_PAGE_SIZE - (GCPtr & GUEST_PAGE_OFFSET_MASK);
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
         /*
          * Check the segment limit.
@@ -276,8 +276,11 @@
         if (!pState->f64Bits && pDis->uInstrAddr + offInstr > pState->cbSegLimit)
             return VERR_OUT_OF_SELECTOR_BOUNDS;
+#endif
 
         /*
          * Calc how much we can read, maxing out the read.
          */
+        uint32_t cb = GUEST_PAGE_SIZE - (GCPtr & GUEST_PAGE_OFFSET_MASK);
+#ifdef VBOX_VMM_TARGET_X86
         if (!pState->f64Bits)
         {
@@ -313,5 +316,4 @@
 {
     PDBGFDISASSTATE pState   = (PDBGFDISASSTATE)pDis;
-    PCDBGFSELINFO   pSelInfo = (PCDBGFSELINFO)pvUser;
 
     /*
@@ -320,5 +322,7 @@
     DBGFADDRESS     Addr;
     int             rc;
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
+    PCDBGFSELINFO   pSelInfo = (PCDBGFSELINFO)pvUser;
+
     /* Start with CS. */
     if (   DIS_FMT_SEL_IS_REG(u32Sel)
@@ -349,7 +353,7 @@
         rc = VERR_SYMBOL_NOT_FOUND;
     }
+
 #else
-    RT_NOREF(pSelInfo, u32Sel);
-
+    RT_NOREF(pvUser, u32Sel);
     DBGFR3AddrFromFlat(pState->pVM->pUVM, &Addr, uAddress);
     rc = VINF_SUCCESS;
@@ -410,11 +414,5 @@
     int     rc;
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    DBGFSELINFO     SelInfo; RT_ZERO(SelInfo);
-    const PGMMODE   enmMode = PGMGetGuestMode(pVCpu);
-    const bool      fRealModeAddress = false;
-    if (fFlags & DBGF_DISAS_FLAGS_CURRENT_GUEST)
-        GCPtr = CPUMGetGuestFlatPC(pVCpu);
-#else
+#ifdef VBOX_VMM_TARGET_X86
     /*
      * Get the Sel and GCPtr if fFlags requests that.
@@ -542,5 +540,11 @@
         }
     }
-#endif
+
+#else  /* !VBOX_VMM_TARGET_X86 */
+    const PGMMODE   enmMode = PGMGetGuestMode(pVCpu);
+    const bool      fRealModeAddress = false;
+    if (fFlags & DBGF_DISAS_FLAGS_CURRENT_GUEST)
+        GCPtr = CPUMGetGuestFlatPC(pVCpu);
+#endif /* !VBOX_VMM_TARGET_X86 */
 
     /*
@@ -548,5 +552,9 @@
      */
     DBGFDISASSTATE State;
+#ifdef VBOX_VMM_TARGET_X86
     rc = dbgfR3DisasInstrFirst(pVM, pVCpu, &SelInfo, enmMode, GCPtr, fFlags, &State);
+#else
+    rc = dbgfR3DisasInstrFirst(pVM, pVCpu, NULL, enmMode, GCPtr, fFlags, &State);
+#endif
     if (RT_FAILURE(rc))
     {
@@ -562,14 +570,16 @@
      */
     char szBuf[512];
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
     DISFormatArmV8Ex(&State.Dis, szBuf, sizeof(szBuf),
                      DIS_FMT_FLAGS_RELATIVE_BRANCH,
                      fFlags & DBGF_DISAS_FLAGS_NO_SYMBOLS ? NULL : dbgfR3DisasGetSymbol,
                      NULL);
-#else
+#elif defined(VBOX_VMM_TARGET_X86)
     DISFormatYasmEx(&State.Dis, szBuf, sizeof(szBuf),
                     DIS_FMT_FLAGS_RELATIVE_BRANCH,
                     fFlags & DBGF_DISAS_FLAGS_NO_SYMBOLS ? NULL : dbgfR3DisasGetSymbol,
                     &SelInfo);
+#else
+# error "port me"
 #endif
 
@@ -651,8 +661,10 @@
         pDisState->Param3    = State.Dis.aParams[2];
         pDisState->Param4    = State.Dis.aParams[3];
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
         memcpy(&pDisState->armv8, &State.Dis.armv8, sizeof(State.Dis.armv8));
+#elif defined(VBOX_VMM_TARGET_X86)
+        memcpy(&pDisState->x86, &State.Dis.x86, sizeof(State.Dis.x86));
 #else
-        memcpy(&pDisState->x86, &State.Dis.x86, sizeof(State.Dis.x86));
+# error "port me"
 #endif
     }
Index: trunk/src/VBox/VMM/VMMR3/DBGFMem.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGFMem.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/DBGFMem.cpp	(revision 107227)
@@ -359,5 +359,5 @@
 
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
 /**
  * Worker for DBGFR3SelQueryInfo that calls into SELM.
@@ -409,5 +409,5 @@
     return rc;
 }
-#endif
+#endif /* VBOX_VMM_TARGET_X86 */
 
 
@@ -447,12 +447,12 @@
     memset(pSelInfo, 0, sizeof(*pSelInfo));
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
+    /*
+     * Dispatch the request to a worker running on the target CPU.
+     */
+    return VMR3ReqPriorityCallWaitU(pUVM, idCpu, (PFNRT)dbgfR3SelQueryInfo, 5, pUVM, idCpu, Sel, fFlags, pSelInfo);
+#else
     RT_NOREF(Sel);
     return VERR_NOT_SUPPORTED;
-#else
-    /*
-     * Dispatch the request to a worker running on the target CPU.
-     */
-    return VMR3ReqPriorityCallWaitU(pUVM, idCpu, (PFNRT)dbgfR3SelQueryInfo, 5, pUVM, idCpu, Sel, fFlags, pSelInfo);
 #endif
 }
@@ -496,4 +496,5 @@
 
 
+#ifdef VBOX_WITH_HWVIRT
 /**
  * Converts a PGM paging mode to a set of DBGFPGDMP_XXX flags.
@@ -506,5 +507,5 @@
     switch (enmMode)
     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+# ifdef VBOX_VMM_TARGET_X86
         case PGMMODE_32_BIT:
             return DBGFPGDMP_FLAGS_PSE;
@@ -525,16 +526,17 @@
         case PGMMODE_EPT:
             return DBGFPGDMP_FLAGS_EPT;
+
+# elif defined(VBOX_VMM_TARGET_ARM64)
+       /** @todo arm64: dumping page tables. */
+# else
+#  error "port me"
+# endif
         case PGMMODE_NONE:
             return 0;
         default:
             AssertFailedReturn(UINT32_MAX);
-#else
-        case PGMMODE_NONE:
-            return 0;
-        default:
-            AssertFailedReturn(UINT32_MAX);
-#endif
-    }
-}
+    }
+}
+#endif /* VBOX_WITH_HWVIRT */
 
 
@@ -586,17 +588,17 @@
                 return VINF_SUCCESS;
             }
-
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_WITH_HWVIRT)
             if (fFlags & DBGFPGDMP_FLAGS_CURRENT_CR3)
                 cr3 = PGMGetHyperCR3(pVCpu);
-#endif
             if (fFlags & DBGFPGDMP_FLAGS_CURRENT_MODE)
                 fFlags |= dbgfR3PagingDumpModeToFlags(PGMGetShadowMode(pVCpu));
+#else
+            pHlp->pfnPrintf(pHlp, "Expected shadowing mode PGMMODE_NONE, found %d!\n", PGMGetShadowMode(pVCpu));
+            return VINF_SUCCESS;
+#endif
         }
         else
         {
-#if defined(VBOX_VMM_TARGET_ARMV8)
-            AssertReleaseFailed();
-#else
+#ifdef VBOX_VMM_TARGET_X86
             if (fFlags & DBGFPGDMP_FLAGS_CURRENT_CR3)
                 cr3 = CPUMGetGuestCR3(pVCpu);
@@ -608,4 +610,10 @@
                 fFlags |= CPUMGetGuestEFER(pVCpu) & (MSR_K6_EFER_LME | MSR_K6_EFER_NXE);
             }
+#elif defined(VBOX_VMM_TARGET_ARMV8)
+            /** @todo arm64: port me   */
+            AssertReleaseFailed();
+            return VERR_NOT_IMPLEMENTED;
+#else
+# error "port me"
 #endif
         }
@@ -645,4 +653,6 @@
                                 uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp)
 {
+/** @todo adjust this for ARMv8. Probably need two root parameters (instead of
+ * cr3) as well as a bunch new flags. */
     /*
      * Input validation.
Index: trunk/src/VBox/VMM/VMMR3/DBGFR3Bp.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGFR3Bp.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/DBGFR3Bp.cpp	(revision 107227)
@@ -177,5 +177,5 @@
 #include <iprt/assert.h>
 #include <iprt/mem.h>
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
 # include <iprt/armv8.h>
 #endif
@@ -1786,9 +1786,5 @@
     RT_NOREF(pvUser);
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    RT_NOREF(pVM, pVCpu);
-    AssertReleaseFailed();
-    return VERR_NOT_IMPLEMENTED;
-#else
+#ifdef VBOX_VMM_TARGET_X86
     /*
      * CPU 0 updates the enabled hardware breakpoint counts.
@@ -1810,4 +1806,10 @@
 
     return CPUMRecalcHyperDRx(pVCpu, UINT8_MAX);
+
+#else
+    /** @todo arm64: hardware breakpoints. */
+    RT_NOREF(pVM, pVCpu);
+    AssertReleaseFailed();
+    return VERR_NOT_IMPLEMENTED;
 #endif
 }
@@ -1855,34 +1857,29 @@
              * as the VMX code intercepts #BP only when at least one int3 breakpoint is enabled.
              * A racing vCPU might trigger it and forward it to the guest causing panics/crashes/havoc. */
+            /*
+             * Save original instruction and replace a breakpoint instruction.
+             */
 #ifdef VBOX_VMM_TARGET_ARMV8
-            /*
-             * Save original instruction and replace with brk
-             */
-            rc = PGMPhysSimpleReadGCPhys(pVM, &pBp->Pub.u.Sw.Arch.armv8.u32Org, pBp->Pub.u.Sw.PhysAddr, sizeof(pBp->Pub.u.Sw.Arch.armv8.u32Org));
-            if (RT_SUCCESS(rc))
-            {
-                static const uint32_t s_u32Brk = Armv8A64MkInstrBrk(0xc0de);
-                rc = PGMPhysSimpleWriteGCPhys(pVM, pBp->Pub.u.Sw.PhysAddr, &s_u32Brk, sizeof(s_u32Brk));
-            }
+            static const uint32_t s_BreakpointInstr = Armv8A64MkInstrBrk(0xc0de);
+            rc = PGMPhysSimpleReadGCPhys(pVM, &pBp->Pub.u.Sw.Arch.armv8.u32Org, pBp->Pub.u.Sw.PhysAddr,
+                                         sizeof(pBp->Pub.u.Sw.Arch.armv8.u32Org));
+#elif defined(VBOX_VMM_TARGET_X86)
+            static const uint8_t  s_BreakpointInstr = 0xcc;
+            rc = PGMPhysSimpleReadGCPhys(pVM, &pBp->Pub.u.Sw.Arch.x86.bOrg, pBp->Pub.u.Sw.PhysAddr,
+                                         sizeof(pBp->Pub.u.Sw.Arch.x86.bOrg));
 #else
-            /*
-             * Save current byte and write the int3 instruction byte.
-             */
-            rc = PGMPhysSimpleReadGCPhys(pVM, &pBp->Pub.u.Sw.Arch.x86.bOrg, pBp->Pub.u.Sw.PhysAddr, sizeof(pBp->Pub.u.Sw.Arch.x86.bOrg));
-            if (RT_SUCCESS(rc))
-            {
-                static const uint8_t s_bInt3 = 0xcc;
-                rc = PGMPhysSimpleWriteGCPhys(pVM, pBp->Pub.u.Sw.PhysAddr, &s_bInt3, sizeof(s_bInt3));
-            }
+# error "port me"
 #endif
             if (RT_SUCCESS(rc))
             {
-                ASMAtomicIncU32(&pVM->dbgf.s.cEnabledSwBreakpoints);
-                Log(("DBGF: Set breakpoint at %RGv (Phys %RGp)\n", pBp->Pub.u.Sw.GCPtr, pBp->Pub.u.Sw.PhysAddr));
-            }
-
-            if (RT_FAILURE(rc))
-                dbgfR3BpSetEnabled(pBp, false /*fEnabled*/);
-
+                rc = PGMPhysSimpleWriteGCPhys(pVM, pBp->Pub.u.Sw.PhysAddr, &s_BreakpointInstr, sizeof(s_BreakpointInstr));
+                if (RT_SUCCESS(rc))
+                {
+                    ASMAtomicIncU32(&pVM->dbgf.s.cEnabledSwBreakpoints);
+                    Log(("DBGF: Set breakpoint at %RGv (Phys %RGp)\n", pBp->Pub.u.Sw.GCPtr, pBp->Pub.u.Sw.PhysAddr));
+                    break;
+                }
+            }
+            dbgfR3BpSetEnabled(pBp, false /*fEnabled*/);
             break;
         }
@@ -1952,5 +1949,6 @@
             if (   RT_SUCCESS(rc)
                 && u32Current == Armv8A64MkInstrBrk(0xc0de))
-                rc = PGMPhysSimpleWriteGCPhys(pVM, pBp->Pub.u.Sw.PhysAddr, &pBp->Pub.u.Sw.Arch.armv8.u32Org, sizeof(pBp->Pub.u.Sw.Arch.armv8.u32Org));
+                rc = PGMPhysSimpleWriteGCPhys(pVM, pBp->Pub.u.Sw.PhysAddr, &pBp->Pub.u.Sw.Arch.armv8.u32Org,
+                                              sizeof(pBp->Pub.u.Sw.Arch.armv8.u32Org));
 #else
             uint8_t bCurrent = 0;
@@ -1958,7 +1956,7 @@
             if (   RT_SUCCESS(rc)
                 && bCurrent == 0xcc)
-                rc = PGMPhysSimpleWriteGCPhys(pVM, pBp->Pub.u.Sw.PhysAddr, &pBp->Pub.u.Sw.Arch.x86.bOrg, sizeof(pBp->Pub.u.Sw.Arch.x86.bOrg));
+                rc = PGMPhysSimpleWriteGCPhys(pVM, pBp->Pub.u.Sw.PhysAddr, &pBp->Pub.u.Sw.Arch.x86.bOrg,
+                                              sizeof(pBp->Pub.u.Sw.Arch.x86.bOrg));
 #endif
-
             if (RT_SUCCESS(rc))
             {
@@ -1991,5 +1989,5 @@
 
 /**
- * Worker for DBGFR3BpHit() differnetiating on the breakpoint type.
+ * Worker for DBGFR3BpHit() differentiating on the breakpoint type.
  *
  * @returns Strict VBox status code.
@@ -2015,4 +2013,6 @@
             if (rcStrict == VINF_SUCCESS)
             {
+                /** @todo Need to take more care with the reading there if the breakpoint is
+                 *        on the edge of a page. */
                 uint8_t abInstr[DBGF_BP_INSN_MAX];
                 RTGCPTR const GCPtrInstr = CPUMGetGuestFlatPC(pVCpu);
@@ -2020,11 +2020,12 @@
                 if (rcStrict == VINF_SUCCESS)
                 {
-#ifdef VBOX_VMM_TARGET_ARMV8
-                    AssertFailed();
-                    rcStrict = VERR_NOT_IMPLEMENTED;
-#else
+#ifdef VBOX_VMM_TARGET_X86
                     /* Replace the int3 with the original instruction byte. */
                     abInstr[0] = pBp->Pub.u.Sw.Arch.x86.bOrg;
                     rcStrict = IEMExecOneWithPrefetchedByPC(pVCpu, GCPtrInstr, &abInstr[0], sizeof(abInstr));
+#else
+                    /** @todo arm64: implement stepping over breakpoint. Fix unnecessary opcode reading. */
+                    AssertFailed();
+                    rcStrict = VERR_NOT_IMPLEMENTED;
 #endif
                     if (   rcStrict == VINF_SUCCESS
Index: trunk/src/VBox/VMM/VMMR3/DBGFR3Flow.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGFR3Flow.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/DBGFR3Flow.cpp	(revision 107227)
@@ -232,14 +232,15 @@
     if (   uOpc == OP_ARMV8_A64_B
         || uOpc == OP_ARMV8_A64_BC)
-    {
-        return    pDis->armv8.enmCond == kDisArmv8InstrCond_Al
-               || pDis->armv8.enmCond == kDisArmv8InstrCond_Al1;
-    }
+        return pDis->armv8.enmCond == kDisArmv8InstrCond_Al
+            || pDis->armv8.enmCond == kDisArmv8InstrCond_Al1;
 
     return false;
+
+#elif defined(VBOX_VMM_TARGET_X86)
+    RT_NOREF_PV(pDis);
+    return uOpc == OP_JMP;
+
 #else
-    RT_NOREF(pDis);
-
-    return uOpc == OP_JMP;
+# error "port me"
 #endif
 }
@@ -269,7 +270,11 @@
 
     return false;
+
+#elif defined(VBOX_VMM_TARGET_X86)
+    RT_NOREF_PV(fOpType);
+    return uOpc == OP_CALL;
+
 #else
-    RT_NOREF(fOpType);
-    return uOpc == OP_CALL;
+# error "port me"
 #endif
 }
@@ -285,22 +290,20 @@
 {
 #ifdef VBOX_VMM_TARGET_ARMV8
-    if (   uOpc == OP_ARMV8_A64_RET
+    return uOpc == OP_ARMV8_A64_RET
         || uOpc == OP_ARMV8_A64_RETAA
         || uOpc == OP_ARMV8_A64_RETAB
         || uOpc == OP_ARMV8_A64_ERET
         || uOpc == OP_ARMV8_A64_ERETAA
-        || uOpc == OP_ARMV8_A64_ERETAB)
-        return true;
-
-    return false;
-#else
-    if (   uOpc == OP_RETN
+        || uOpc == OP_ARMV8_A64_ERETAB;
+
+#elif defined(VBOX_VMM_TARGET_X86)
+    return uOpc == OP_RETN
         || uOpc == OP_RETF
         || uOpc == OP_IRET
         || uOpc == OP_SYSEXIT
-        || uOpc == OP_SYSRET)
-        return true;
-
-    return false;
+        || uOpc == OP_SYSRET;
+
+#else
+# error "port me"
 #endif
 }
@@ -316,6 +319,6 @@
 static bool dbgfR3FlowAddrEqual(PDBGFADDRESS pAddr1, PDBGFADDRESS pAddr2)
 {
-    return    pAddr1->Sel == pAddr2->Sel
-           && pAddr1->off == pAddr2->off;
+    return pAddr1->Sel == pAddr2->Sel
+        && pAddr1->off == pAddr2->off;
 }
 
@@ -330,6 +333,6 @@
 static bool dbgfR3FlowAddrLower(PDBGFADDRESS pAddr1, PDBGFADDRESS pAddr2)
 {
-    return    pAddr1->Sel == pAddr2->Sel
-           && pAddr1->off < pAddr2->off;
+    return pAddr1->Sel == pAddr2->Sel
+        && pAddr1->off < pAddr2->off;
 }
 
@@ -344,7 +347,7 @@
 static bool dbgfR3FlowAddrIntersect(PDBGFFLOWBBINT pFlowBb, PDBGFADDRESS pAddr)
 {
-    return    (pFlowBb->AddrStart.Sel == pAddr->Sel)
-           && (pFlowBb->AddrStart.off <= pAddr->off)
-           && (pFlowBb->AddrEnd.off >= pAddr->off);
+    return pFlowBb->AddrStart.Sel == pAddr->Sel
+        && pFlowBb->AddrStart.off <= pAddr->off
+        && pFlowBb->AddrEnd.off   >= pAddr->off;
 }
 
@@ -363,10 +366,7 @@
         if (pAddr1->off >= pAddr2->off)
             return pAddr1->off - pAddr2->off;
-        else
-            return pAddr2->off - pAddr1->off;
-    }
-    else
-        AssertFailed();
-
+        return pAddr2->off - pAddr1->off;
+    }
+    AssertFailed();
     return 0;
 }
@@ -774,15 +774,15 @@
                                              uint32_t cbInstr, bool fRelJmp, PDBGFADDRESS pAddrJmpTarget)
 {
-    int rc = VINF_SUCCESS;
-
     Assert(!dbgfR3FlowBranchTargetIsIndirect(pDisParam));
 
-    /* Relative jumps are always from the beginning of the next instruction. */
     *pAddrJmpTarget = *pAddrInstr;
-#ifdef VBOX_VMM_TARGET_ARMV8
-    /* On ARM relative jumps are always from the beginning of the curent instruction (b #0 will jump to itself for instance). */
+#ifdef VBOX_VMM_TARGET_X86
+    /* Relative to the next instruction. */
+    DBGFR3AddrAdd(pAddrJmpTarget, cbInstr);
+#elif defined(VBOX_VMM_TARGET_ARMV8)
+    /* Relative to the start of the instruction. */
     RT_NOREF(cbInstr);
 #else
-    DBGFR3AddrAdd(pAddrJmpTarget, cbInstr);
+# error "port me"
 #endif
 
@@ -799,5 +799,5 @@
             iRel = (int64_t)pDisParam->uValue;
         else
-            AssertFailedStmt(rc = VERR_NOT_SUPPORTED);
+            AssertFailedReturn(VERR_NOT_SUPPORTED);
 
         if (iRel < 0)
@@ -816,8 +816,8 @@
         }
         else
-            AssertFailedStmt(rc = VERR_INVALID_STATE);
-    }
-
-    return rc;
+            AssertFailedReturn(VERR_INVALID_STATE);
+    }
+
+    return VINF_SUCCESS;
 }
 
@@ -1386,9 +1386,9 @@
 
 #ifdef VBOX_VMM_TARGET_ARMV8
-                        PDISOPPARAM pParam =   uOpc == OP_ARMV8_A64_B || uOpc == OP_ARMV8_A64_BC
-                                             ? &DisState.Param1
-                                             : uOpc == OP_ARMV8_A64_CBZ || uOpc == OP_ARMV8_A64_CBNZ
-                                             ? &DisState.Param2  /* cbz/cbnz. */
-                                             : &DisState.Param3; /* tbz/tbnz. */
+                        PDISOPPARAM pParam = uOpc == OP_ARMV8_A64_B || uOpc == OP_ARMV8_A64_BC
+                                           ? &DisState.Param1
+                                           : uOpc == OP_ARMV8_A64_CBZ || uOpc == OP_ARMV8_A64_CBNZ
+                                           ? &DisState.Param2  /* cbz/cbnz. */
+                                           : &DisState.Param3; /* tbz/tbnz. */
 #else
                         PDISOPPARAM pParam = &DisState.Param1;
@@ -1466,17 +1466,15 @@
 static int dbgfR3FlowPopulate(PUVM pUVM, VMCPUID idCpu, PDBGFFLOWINT pThis, uint32_t cbDisasmMax, uint32_t fFlags)
 {
-    int rc = VINF_SUCCESS;
     PDBGFFLOWBBINT pFlowBb = dbgfR3FlowGetUnpopulatedBb(pThis);
-
     while (pFlowBb != NULL)
     {
-        rc = dbgfR3FlowBbProcess(pUVM, idCpu, pThis, pFlowBb, cbDisasmMax, fFlags);
-        if (RT_FAILURE(rc))
-            break;
-
-        pFlowBb = dbgfR3FlowGetUnpopulatedBb(pThis);
-    }
-
-    return rc;
+        int rc = dbgfR3FlowBbProcess(pUVM, idCpu, pThis, pFlowBb, cbDisasmMax, fFlags);
+        if (RT_SUCCESS(rc))
+            pFlowBb = dbgfR3FlowGetUnpopulatedBb(pThis);
+        else
+            return rc;
+    }
+
+    return VINF_SUCCESS;
 }
 
@@ -1506,5 +1504,5 @@
 
     /* Create the control flow graph container. */
-    int rc = VINF_SUCCESS;
+    int rc;
     PDBGFFLOWINT pThis = (PDBGFFLOWINT)RTMemAllocZ(sizeof(DBGFFLOWINT));
     if (RT_LIKELY(pThis))
Index: trunk/src/VBox/VMM/VMMR3/DBGFReg.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGFReg.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/DBGFReg.cpp	(revision 107227)
@@ -298,21 +298,24 @@
 
     /* The descriptors. */
-    uint32_t cLookupRecs = 0;
-    uint32_t iDesc;
+#ifdef VBOX_VMM_TARGET_X86
+    DBGFREG const  enmCpuFirst = DBGFREG_X86_FIRST;
+    DBGFREG const  enmCpuLast  = DBGFREG_X86_LAST;
+#elif defined(VBOX_VMM_TARGET_ARMV8)
+    DBGFREG const  enmCpuFirst = DBGFREG_ARMV8_FIRST;
+    DBGFREG const  enmCpuLast  = DBGFREG_ARMV8_LAST;
+#else
+# error "port me"
+#endif
+    unsigned const cCpuDescs   = (unsigned)enmCpuLast - (unsigned)enmCpuFirst + 1;
+    uint32_t       cLookupRecs = 0;
+    uint32_t       iDesc;
     for (iDesc = 0; paRegisters[iDesc].pszName != NULL; iDesc++)
     {
         AssertMsgReturn(dbgfR3RegIsNameValid(paRegisters[iDesc].pszName, 0), ("%s (#%u)\n", paRegisters[iDesc].pszName, iDesc), VERR_INVALID_NAME);
 
-        if (enmType == DBGFREGSETTYPE_CPU)
-#if defined(VBOX_VMM_TARGET_ARMV8)
-            /** @todo This needs a general solution to avoid architecture dependent stuff here. */
-            AssertMsgReturn(iDesc < (unsigned)DBGFREG_END,
-                            ("%d iDesc=%d\n", paRegisters[iDesc].enmReg, iDesc),
+        if (enmType == DBGFREGSETTYPE_CPU) /* The CPU descriptors must be in enum order. */
+            AssertMsgReturn(iDesc < cCpuDescs && (unsigned)paRegisters[iDesc].enmReg == iDesc + (unsigned)enmCpuFirst,
+                            ("%d iDesc=%u+%d=%u\n", paRegisters[iDesc].enmReg, iDesc, enmCpuFirst, iDesc + (unsigned)enmCpuFirst),
                             VERR_INVALID_PARAMETER);
-#else
-            AssertMsgReturn(iDesc < (unsigned)DBGFREG_END && (unsigned)paRegisters[iDesc].enmReg == iDesc,
-                            ("%d iDesc=%d\n", paRegisters[iDesc].enmReg, iDesc),
-                            VERR_INVALID_PARAMETER);
-#endif
         else
             AssertReturn(paRegisters[iDesc].enmReg == DBGFREG_END, VERR_INVALID_PARAMETER);
@@ -906,13 +909,15 @@
          * Look up the register and get the register value.
          */
-#ifndef VBOX_VMM_TARGET_ARMV8
-        if (RT_LIKELY(pSet->cDescs > (size_t)enmReg))
+#ifdef VBOX_VMM_TARGET_X86
+        DBGFREG const  enmCpuFirst = DBGFREG_X86_FIRST;
+#elif defined(VBOX_VMM_TARGET_ARMV8)
+        DBGFREG const  enmCpuFirst = DBGFREG_ARMV8_FIRST;
+#else
+# error "port me"
+#endif
+        uint32_t const idxDesc = (uint32_t)enmReg - (uint32_t)enmCpuFirst;
+        if (RT_LIKELY(idxDesc < pSet->cDescs))
         {
-            PCDBGFREGDESC pDesc = &pSet->paDescs[enmReg];
-#else
-        if (RT_LIKELY(pSet->cDescs > (size_t)(enmReg - DBGFREG_ARMV8_FIRST)))
-        {
-            PCDBGFREGDESC pDesc = &pSet->paDescs[enmReg - DBGFREG_ARMV8_FIRST];
-#endif
+            PCDBGFREGDESC const pDesc = &pSet->paDescs[idxDesc];
 
             pValue->au64[0] = pValue->au64[1] = 0;
Index: trunk/src/VBox/VMM/VMMR3/DBGFStack.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGFStack.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/DBGFStack.cpp	(revision 107227)
@@ -76,8 +76,10 @@
     {
         m_State.u32Magic     = RTDBGUNWINDSTATE_MAGIC;
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
         m_State.enmArch      = RTLDRARCH_ARM64;
+#elif defined(VBOX_VMM_TARGET_X86)
+        m_State.enmArch      = RTLDRARCH_AMD64;
 #else
-        m_State.enmArch      = RTLDRARCH_AMD64;
+# error "port me"
 #endif
         m_State.pfnReadStack = dbgfR3StackReadCallback;
@@ -86,5 +88,5 @@
         if (pInitialCtx)
         {
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
             AssertCompile(RT_ELEMENTS(m_State.u.armv8.auGprs) == RT_ELEMENTS(pInitialCtx->aGRegs));
 
@@ -95,5 +97,6 @@
             for (uint32_t i = 0; i < RT_ELEMENTS(m_State.u.armv8.auGprs); i++)
                 m_State.u.armv8.auGprs[i] = pInitialCtx->aGRegs[i].x;
-#else
+
+#elif defined(VBOX_VMM_TARGET_X86)
             m_State.u.x86.auRegs[X86_GREG_xAX] = pInitialCtx->rax;
             m_State.u.x86.auRegs[X86_GREG_xCX] = pInitialCtx->rcx;
@@ -174,9 +177,11 @@
 static DECLCALLBACK(int) dbgfR3StackReadCallback(PRTDBGUNWINDSTATE pThis, RTUINTPTR uSp, size_t cbToRead, void *pvDst)
 {
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
     Assert(pThis->enmArch == RTLDRARCH_ARM64);
-#else
+#elif defined(VBOX_VMM_TARGET_X86)
     Assert(   pThis->enmArch == RTLDRARCH_AMD64
            || pThis->enmArch == RTLDRARCH_X86_32);
+#else
+# error "port me"
 #endif
 
@@ -188,7 +193,5 @@
     else
     {
-#if defined(VBOX_VMM_TARGET_ARMV8)
-        DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &SrcAddr, uSp);
-#else
+#ifdef VBOX_VMM_TARGET_X86
         if (   pThis->enmArch == RTLDRARCH_X86_32
             || pThis->enmArch == RTLDRARCH_X86_16)
@@ -201,4 +204,6 @@
         else
             DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &SrcAddr, uSp);
+#else
+        DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &SrcAddr, uSp);
 #endif
     }
@@ -221,5 +226,5 @@
 static bool dbgfR3UnwindCtxSetPcAndSp(PDBGFUNWINDCTX pUnwindCtx, PCDBGFADDRESS pAddrPC, PCDBGFADDRESS pAddrStack)
 {
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
     Assert(pUnwindCtx->m_State.enmArch == RTLDRARCH_ARM64);
 
@@ -228,5 +233,6 @@
     Assert(!DBGFADDRESS_IS_FAR(pAddrStack));
     pUnwindCtx->m_State.u.armv8.uSpEl1 = pAddrStack->FlatPtr; /** @todo EL0 stack pointer. */
-#else
+
+#elif defined(VBOX_VMM_TARGET_X86)
     Assert(   pUnwindCtx->m_State.enmArch == RTLDRARCH_AMD64
            || pUnwindCtx->m_State.enmArch == RTLDRARCH_X86_32);
@@ -246,4 +252,7 @@
         pUnwindCtx->m_State.u.x86.auSegs[X86_SREG_SS]  = pAddrStack->Sel;
     }
+
+#else
+# error "port me"
 #endif
 
@@ -502,5 +511,4 @@
 
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
 /**
  * Internal worker routine.
@@ -510,4 +518,12 @@
  *      4  return address
  *      0  old fp; current fp points here
+ *
+ * On x86 the typical stack frame layout is like this:
+ *     ..  ..
+ *     16  parameter 2
+ *     12  parameter 1
+ *      8  parameter 0
+ *      4  return address
+ *      0  old ebp; current ebp points here
  */
 DECL_NO_INLINE(static, int) dbgfR3StackWalk(PDBGFUNWINDCTX pUnwindCtx, PDBGFSTACKFRAME pFrame, bool fFirst)
@@ -552,217 +568,10 @@
      * Figure the return address size and use the old PC to guess stack item size.
      */
+#ifdef VBOX_VMM_TARGET_ARMV8
     unsigned const cbRetAddr   = 8;
     unsigned const cbStackItem = 8; /** @todo AARCH32. */
     PVMCPUCC const pVCpu = pUnwindCtx->m_pUVM->pVM->apCpusR3[pUnwindCtx->m_idCpu];
 
-    /*
-     * Read the raw frame data.
-     * We double cbRetAddr in case we have a far return.
-     */
-    union
-    {
-        uint64_t *pu64;
-        uint32_t *pu32;
-        uint8_t  *pb;
-        void     *pv;
-    } u, uRet, uArgs, uBp;
-    size_t cbRead = cbRetAddr * 2 + cbStackItem + sizeof(pFrame->Args);
-    u.pv = alloca(cbRead);
-    uBp = u;
-    uRet.pb = u.pb + cbStackItem;
-    uArgs.pb = u.pb + cbStackItem + cbRetAddr;
-
-    Assert(DBGFADDRESS_IS_VALID(&pFrame->AddrFrame));
-    int rc = dbgfR3StackRead(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, u.pv, &pFrame->AddrFrame, cbRead, &cbRead);
-    if (   RT_FAILURE(rc)
-        || cbRead < cbRetAddr + cbStackItem)
-        pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_LAST;
-
-    /*
-     * Return Frame address.
-     *
-     * If we used unwind info to get here, the unwind register context will be
-     * positioned after the return instruction has been executed.  We start by
-     * picking up the rBP register here for return frame and will try improve
-     * on it further down by using unwind info.
-     */
-    pFrame->AddrReturnFrame = pFrame->AddrFrame;
-    if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
-    {
-        AssertFailed(); /** @todo */
-    }
-    else
-    {
-        switch (cbStackItem)
-        {
-            case 4:     pFrame->AddrReturnFrame.off = *uBp.pu32; break;
-            case 8:     pFrame->AddrReturnFrame.off = CPUMGetGCPtrPacStripped(pVCpu, *uBp.pu64); break;
-            default:    AssertMsgFailedReturn(("cbStackItem=%d\n", cbStackItem), VERR_DBGF_STACK_IPE_1);
-        }
-
-        pFrame->AddrReturnFrame.FlatPtr += pFrame->AddrReturnFrame.off - pFrame->AddrFrame.off;
-    }
-
-    /*
-     * Return Stack Address.
-     */
-    pFrame->AddrReturnStack = pFrame->AddrReturnFrame;
-    if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
-    {
-        AssertFailed();
-    }
-    else
-    {
-        pFrame->AddrReturnStack.off     += cbStackItem + cbRetAddr;
-        pFrame->AddrReturnStack.FlatPtr += cbStackItem + cbRetAddr;
-    }
-
-    /*
-     * Return PC.
-     */
-    pFrame->AddrReturnPC = pFrame->AddrPC;
-    if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
-    {
-        AssertFailed();
-    }
-    else
-    {
-        switch (pFrame->enmReturnType)
-        {
-            case RTDBGRETURNTYPE_NEAR64:
-                if (DBGFADDRESS_IS_VALID(&pFrame->AddrReturnPC))
-                {
-                    pFrame->AddrReturnPC.FlatPtr += CPUMGetGCPtrPacStripped(pVCpu, *uRet.pu64) - pFrame->AddrReturnPC.off;
-                    pFrame->AddrReturnPC.off      = CPUMGetGCPtrPacStripped(pVCpu, *uRet.pu64);
-                }
-                else
-                    DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &pFrame->AddrReturnPC, CPUMGetGCPtrPacStripped(pVCpu, *uRet.pu64));
-                break;
-            default:
-                AssertMsgFailed(("enmReturnType=%d\n", pFrame->enmReturnType));
-                return VERR_INVALID_PARAMETER;
-        }
-    }
-
-
-    pFrame->pSymReturnPC  = DBGFR3AsSymbolByAddrA(pUnwindCtx->m_pUVM, pUnwindCtx->m_hAs, &pFrame->AddrReturnPC,
-                                                  RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL | RTDBGSYMADDR_FLAGS_SKIP_ABS_IN_DEFERRED,
-                                                  NULL /*poffDisp*/, NULL /*phMod*/);
-    pFrame->pLineReturnPC = DBGFR3AsLineByAddrA(pUnwindCtx->m_pUVM, pUnwindCtx->m_hAs, &pFrame->AddrReturnPC,
-                                                NULL /*poffDisp*/, NULL /*phMod*/);
-
-    /*
-     * Frame bitness flag.
-     */
-    /** @todo use previous return type for this? */
-    pFrame->fFlags &= ~(DBGFSTACKFRAME_FLAGS_32BIT | DBGFSTACKFRAME_FLAGS_64BIT);
-    switch (cbStackItem)
-    {
-        case 4: pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_32BIT; break;
-        case 8: pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_64BIT; break;
-        default:    AssertMsgFailedReturn(("cbStackItem=%d\n", cbStackItem), VERR_DBGF_STACK_IPE_2);
-    }
-
-    /*
-     * The arguments.
-     */
-    memcpy(&pFrame->Args, uArgs.pv, sizeof(pFrame->Args));
-
-    /*
-     * Collect register changes.
-     * Then call the OS layer to assist us (e.g. NT trap frames).
-     */
-    if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
-    {
-        AssertFailed();
-    }
-
-    /*
-     * Try use unwind information to locate the return frame pointer (for the
-     * next loop iteration).
-     */
-    Assert(!(pFrame->fFlags & DBGFSTACKFRAME_FLAGS_UNWIND_INFO_RET));
-    pFrame->enmReturnFrameReturnType = RTDBGRETURNTYPE_INVALID;
-    if (!(pFrame->fFlags & DBGFSTACKFRAME_FLAGS_LAST))
-    {
-        /* Set PC and SP if we didn't unwind our way here (context will then point
-           and the return PC and SP already). */
-        if (!(pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO))
-        {
-            dbgfR3UnwindCtxSetPcAndSp(pUnwindCtx, &pFrame->AddrReturnPC, &pFrame->AddrReturnStack);
-            pUnwindCtx->m_State.u.armv8.auGprs[ARMV8_A64_REG_BP] = pFrame->AddrReturnFrame.off;
-        }
-        if (pUnwindCtx->m_State.enmArch == RTLDRARCH_ARM64)
-            pUnwindCtx->m_State.u.armv8.Loaded.fAll = 0;
-        else
-            AssertFailed();
-        if (dbgfR3UnwindCtxDoOneFrame(pUnwindCtx))
-        {
-            Assert(!pUnwindCtx->m_fIsHostRing0);
-
-            DBGFADDRESS AddrReturnFrame = pFrame->AddrReturnFrame;
-            DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &AddrReturnFrame, pUnwindCtx->m_State.u.armv8.FrameAddr);
-            pFrame->AddrReturnFrame = AddrReturnFrame;
-
-            pFrame->enmReturnFrameReturnType = pUnwindCtx->m_State.enmRetType;
-            pFrame->fFlags                  |= DBGFSTACKFRAME_FLAGS_UNWIND_INFO_RET;
-        }
-    }
-
-    return VINF_SUCCESS;
-}
-#else
-/**
- * Internal worker routine.
- *
- * On x86 the typical stack frame layout is like this:
- *     ..  ..
- *     16  parameter 2
- *     12  parameter 1
- *      8  parameter 0
- *      4  return address
- *      0  old ebp; current ebp points here
- */
-DECL_NO_INLINE(static, int) dbgfR3StackWalk(PDBGFUNWINDCTX pUnwindCtx, PDBGFSTACKFRAME pFrame, bool fFirst)
-{
-    /*
-     * Stop if we got a read error in the previous run.
-     */
-    if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_LAST)
-        return VERR_NO_MORE_FILES;
-
-    /*
-     * Advance the frame (except for the first).
-     */
-    if (!fFirst) /** @todo we can probably eliminate this fFirst business... */
-    {
-        /* frame, pc and stack is taken from the existing frames return members. */
-        pFrame->AddrFrame = pFrame->AddrReturnFrame;
-        pFrame->AddrPC    = pFrame->AddrReturnPC;
-        pFrame->pSymPC    = pFrame->pSymReturnPC;
-        pFrame->pLinePC   = pFrame->pLineReturnPC;
-
-        /* increment the frame number. */
-        pFrame->iFrame++;
-
-        /* UNWIND_INFO_RET -> USED_UNWIND; return type */
-        if (!(pFrame->fFlags & DBGFSTACKFRAME_FLAGS_UNWIND_INFO_RET))
-            pFrame->fFlags &= ~DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO;
-        else
-        {
-            pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO;
-            pFrame->fFlags &= ~DBGFSTACKFRAME_FLAGS_UNWIND_INFO_RET;
-            if (pFrame->enmReturnFrameReturnType != RTDBGRETURNTYPE_INVALID)
-            {
-                pFrame->enmReturnType = pFrame->enmReturnFrameReturnType;
-                pFrame->enmReturnFrameReturnType = RTDBGRETURNTYPE_INVALID;
-            }
-        }
-        pFrame->fFlags &= ~DBGFSTACKFRAME_FLAGS_TRAP_FRAME;
-    }
-
-    /*
-     * Figure the return address size and use the old PC to guess stack item size.
-     */
+#elif defined(VBOX_VMM_TARGET_X86)
     /** @todo this is bogus... */
     unsigned cbRetAddr = RTDbgReturnTypeSize(pFrame->enmReturnType);
@@ -797,4 +606,5 @@
             }
     }
+#endif
 
     /*
@@ -810,5 +620,5 @@
         void     *pv;
     } u, uRet, uArgs, uBp;
-    size_t cbRead = cbRetAddr*2 + cbStackItem + sizeof(pFrame->Args);
+    size_t cbRead = cbRetAddr * 2 + cbStackItem + sizeof(pFrame->Args);
     u.pv = alloca(cbRead);
     uBp = u;
@@ -833,4 +643,8 @@
     if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
     {
+#ifdef VBOX_VMM_TARGET_ARMV8
+        AssertFailed(); /** @todo */
+
+#elif defined(VBOX_VMM_TARGET_X86)
         if (   pFrame->enmReturnType == RTDBGRETURNTYPE_IRET32_PRIV
             || pFrame->enmReturnType == RTDBGRETURNTYPE_IRET64)
@@ -846,4 +660,5 @@
             pFrame->AddrReturnFrame.FlatPtr += pFrame->AddrReturnFrame.off - pFrame->AddrFrame.off;
         }
+#endif /* VBOX_VMM_TARGET_X86 */
     }
     else
@@ -851,10 +666,17 @@
         switch (cbStackItem)
         {
+#ifdef VBOX_VMM_TARGET_ARMV8
+            case 8:     pFrame->AddrReturnFrame.off = CPUMGetGCPtrPacStripped(pVCpu, *uBp.pu64); break;
+#else
+            case 8:     pFrame->AddrReturnFrame.off = *uBp.pu64; break;
+#endif
+            case 4:     pFrame->AddrReturnFrame.off = *uBp.pu32; break;
+#ifdef VBOX_VMM_TARGET_X86
             case 2:     pFrame->AddrReturnFrame.off = *uBp.pu16; break;
-            case 4:     pFrame->AddrReturnFrame.off = *uBp.pu32; break;
-            case 8:     pFrame->AddrReturnFrame.off = *uBp.pu64; break;
+#endif
             default:    AssertMsgFailedReturn(("cbStackItem=%d\n", cbStackItem), VERR_DBGF_STACK_IPE_1);
         }
 
+#ifdef VBOX_VMM_TARGET_X86
         /* Watcom tries to keep the frame pointer odd for far returns. */
         if (   cbStackItem <= 4
@@ -872,15 +694,15 @@
                 else if (pFrame->enmReturnType == RTDBGRETURNTYPE_NEAR32)
                 {
-#if 1
+# if 1
                     /* Assumes returning 32-bit code. */
                     pFrame->fFlags       |= DBGFSTACKFRAME_FLAGS_USED_ODD_EVEN;
                     pFrame->enmReturnType = RTDBGRETURNTYPE_FAR32;
                     cbRetAddr = 8;
-#else
+# else
                     /* Assumes returning 16-bit code. */
                     pFrame->fFlags       |= DBGFSTACKFRAME_FLAGS_USED_ODD_EVEN;
                     pFrame->enmReturnType = RTDBGRETURNTYPE_FAR16;
                     cbRetAddr = 4;
-#endif
+# endif
                 }
             }
@@ -901,4 +723,5 @@
             uArgs.pb = u.pb + cbStackItem + cbRetAddr;
         }
+#endif /* VBOX_VMM_TARGET_X86 */
 
         pFrame->AddrReturnFrame.FlatPtr += pFrame->AddrReturnFrame.off - pFrame->AddrFrame.off;
@@ -911,4 +734,8 @@
     if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
     {
+#ifdef VBOX_VMM_TARGET_ARMV8
+        AssertFailed();
+
+#elif defined(VBOX_VMM_TARGET_X86)
         if (   pFrame->enmReturnType == RTDBGRETURNTYPE_IRET32_PRIV
             || pFrame->enmReturnType == RTDBGRETURNTYPE_IRET64)
@@ -924,4 +751,5 @@
             pFrame->AddrReturnStack.FlatPtr += pFrame->AddrReturnStack.off - pFrame->AddrStack.off;
         }
+#endif /* VBOX_VMM_TARGET_X86 */
     }
     else
@@ -937,4 +765,8 @@
     if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
     {
+#ifdef VBOX_VMM_TARGET_ARMV8
+        AssertFailed();
+
+#elif defined(VBOX_VMM_TARGET_X86)
         if (RTDbgReturnTypeIsNear(pFrame->enmReturnType))
         {
@@ -945,7 +777,26 @@
             DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnPC,
                                  pUnwindCtx->m_State.u.x86.auSegs[X86_SREG_CS], pUnwindCtx->m_State.uPc);
+#endif
     }
     else
     {
+#ifdef VBOX_VMM_TARGET_ARMV8
+        switch (pFrame->enmReturnType)
+        {
+            case RTDBGRETURNTYPE_NEAR64:
+                if (DBGFADDRESS_IS_VALID(&pFrame->AddrReturnPC))
+                {
+                    pFrame->AddrReturnPC.FlatPtr += CPUMGetGCPtrPacStripped(pVCpu, *uRet.pu64) - pFrame->AddrReturnPC.off;
+                    pFrame->AddrReturnPC.off      = CPUMGetGCPtrPacStripped(pVCpu, *uRet.pu64);
+                }
+                else
+                    DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &pFrame->AddrReturnPC, CPUMGetGCPtrPacStripped(pVCpu, *uRet.pu64));
+                break;
+            default:
+                AssertMsgFailed(("enmReturnType=%d\n", pFrame->enmReturnType));
+                return VERR_INVALID_PARAMETER;
+        }
+
+#elif defined(VBOX_VMM_TARGET_X86)
         int rc2;
         switch (pFrame->enmReturnType)
@@ -1020,4 +871,5 @@
                 return VERR_INVALID_PARAMETER;
         }
+#endif /* VBOX_VMM_TARGET_X86 */
     }
 
@@ -1036,7 +888,9 @@
     switch (cbStackItem)
     {
-        case 2: pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_16BIT; break;
         case 4: pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_32BIT; break;
         case 8: pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_64BIT; break;
+#ifdef VBOX_VMM_TARGET_X86
+        case 2: pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_16BIT; break;
+#endif
         default:    AssertMsgFailedReturn(("cbStackItem=%d\n", cbStackItem), VERR_DBGF_STACK_IPE_2);
     }
@@ -1053,4 +907,5 @@
     if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
     {
+#if defined(VBOX_VMM_TARGET_X86)
         rc = dbgfR3StackWalkCollectRegisterChanges(pUnwindCtx->m_pUVM, pFrame, &pUnwindCtx->m_State);
         if (RT_FAILURE(rc))
@@ -1065,4 +920,7 @@
                 return rc;
         }
+#else
+        AssertFailed();
+#endif
     }
 
@@ -1080,6 +938,18 @@
         {
             dbgfR3UnwindCtxSetPcAndSp(pUnwindCtx, &pFrame->AddrReturnPC, &pFrame->AddrReturnStack);
+#ifdef VBOX_VMM_TARGET_ARMV8
+            pUnwindCtx->m_State.u.armv8.auGprs[ARMV8_A64_REG_BP] = pFrame->AddrReturnFrame.off;
+#elif defined(VBOX_VMM_TARGET_X86)
             pUnwindCtx->m_State.u.x86.auRegs[X86_GREG_xBP] = pFrame->AddrReturnFrame.off;
-        }
+#endif
+        }
+
+#ifdef VBOX_VMM_TARGET_ARMV8
+        if (pUnwindCtx->m_State.enmArch == RTLDRARCH_ARM64)
+            pUnwindCtx->m_State.u.armv8.Loaded.fAll = 0;
+        else
+            AssertFailed();
+
+#elif defined(VBOX_VMM_TARGET_X86)
         /** @todo Reevaluate CS if the previous frame return type isn't near. */
         if (   pUnwindCtx->m_State.enmArch == RTLDRARCH_AMD64
@@ -1089,14 +959,24 @@
         else
             AssertFailed();
+#endif
+
         if (dbgfR3UnwindCtxDoOneFrame(pUnwindCtx))
         {
+#ifdef VBOX_VMM_TARGET_ARMV8
+            Assert(!pUnwindCtx->m_fIsHostRing0);
+#elif defined(VBOX_VMM_TARGET_X86)
             if (pUnwindCtx->m_fIsHostRing0)
                 DBGFR3AddrFromHostR0(&pFrame->AddrReturnFrame, pUnwindCtx->m_State.u.x86.FrameAddr.off);
             else
+#endif
             {
                 DBGFADDRESS AddrReturnFrame = pFrame->AddrReturnFrame;
+#ifdef VBOX_VMM_TARGET_ARMV8
+                DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &AddrReturnFrame, pUnwindCtx->m_State.u.armv8.FrameAddr);
+#elif defined(VBOX_VMM_TARGET_X86)
                 rc = DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &AddrReturnFrame,
                                           pUnwindCtx->m_State.u.x86.FrameAddr.sel, pUnwindCtx->m_State.u.x86.FrameAddr.off);
                 if (RT_SUCCESS(rc))
+#endif
                     pFrame->AddrReturnFrame = AddrReturnFrame;
             }
@@ -1108,5 +988,4 @@
     return VINF_SUCCESS;
 }
-#endif
 
 
@@ -1137,12 +1016,10 @@
 
     int rc = VINF_SUCCESS;
-#if defined(VBOX_VMM_TARGET_ARMV8)
     if (pAddrPC)
         pCur->AddrPC = *pAddrPC;
+#ifdef VBOX_VMM_TARGET_ARMV8
     else
         DBGFR3AddrFromFlat(pUVM, &pCur->AddrPC, pCtx->Pc.u64);
-#else
-    if (pAddrPC)
-        pCur->AddrPC = *pAddrPC;
+#elif defined(VBOX_VMM_TARGET_X86)
     else if (enmCodeType != DBGFCODETYPE_GUEST)
         DBGFR3AddrFromFlat(pUVM, &pCur->AddrPC, pCtx->rip);
@@ -1167,5 +1044,6 @@
             PVMCPU const   pVCpu      = pUVM->pVM->apCpusR3[idCpu];
             CPUMMODE const enmCpuMode = CPUMGetGuestMode(pVCpu);
-#if defined(VBOX_VMM_TARGET_ARMV8)
+
+#ifdef VBOX_VMM_TARGET_ARMV8
             /** @todo */
             Assert(enmCpuMode == CPUMMODE_ARMV8_AARCH64); RT_NOREF(enmCpuMode);
@@ -1173,5 +1051,6 @@
             if (enmReturnType == RTDBGRETURNTYPE_INVALID)
                 pCur->enmReturnType = RTDBGRETURNTYPE_NEAR64;
-#else
+
+#elif defined(VBOX_VMM_TARGET_X86)
             if (enmCpuMode == CPUMMODE_REAL)
             {
@@ -1196,5 +1075,5 @@
         }
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
         if (enmReturnType == RTDBGRETURNTYPE_INVALID)
             switch (pCur->AddrPC.fFlags & DBGFADDRESS_FLAGS_TYPE_MASK)
@@ -1213,26 +1092,23 @@
 
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
         if (pAddrStack)
             pCur->AddrStack = *pAddrStack;
+#ifdef VBOX_VMM_TARGET_ARMV8
         else
             DBGFR3AddrFromFlat(pUVM, &pCur->AddrStack, pCtx->aSpReg[1].u64 & fAddrMask); /** @todo EL0 stack. */
-
-        Assert(!(pCur->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO));
-        if (pAddrFrame)
-            pCur->AddrFrame = *pAddrFrame;
-        else
-            DBGFR3AddrFromFlat(pUVM, &pCur->AddrFrame, pCtx->aGRegs[ARMV8_A64_REG_BP].x & fAddrMask);
-#else
-        if (pAddrStack)
-            pCur->AddrStack = *pAddrStack;
+#elif defined(VBOX_VMM_TARGET_X86)
         else if (enmCodeType != DBGFCODETYPE_GUEST)
             DBGFR3AddrFromFlat(pUVM, &pCur->AddrStack, pCtx->rsp & fAddrMask);
         else
             rc = DBGFR3AddrFromSelOff(pUVM, idCpu, &pCur->AddrStack, pCtx->ss.Sel, pCtx->rsp & fAddrMask);
+#endif
 
         Assert(!(pCur->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO));
         if (pAddrFrame)
             pCur->AddrFrame = *pAddrFrame;
+#ifdef VBOX_VMM_TARGET_ARMV8
+        else
+            DBGFR3AddrFromFlat(pUVM, &pCur->AddrFrame, pCtx->aGRegs[ARMV8_A64_REG_BP].x & fAddrMask);
+#elif defined(VBOX_VMM_TARGET_X86)
         else if (enmCodeType != DBGFCODETYPE_GUEST)
             DBGFR3AddrFromFlat(pUVM, &pCur->AddrFrame, pCtx->rbp & fAddrMask);
@@ -1250,7 +1126,7 @@
             pCur->enmReturnType = UnwindCtx.m_State.enmRetType;
             pCur->fFlags |= DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO;
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
             DBGFR3AddrFromFlat(pUVM, &pCur->AddrFrame, UnwindCtx.m_State.u.armv8.FrameAddr);
-#else
+#elif defined(VBOX_VMM_TARGET_X86)
             if (!UnwindCtx.m_fIsHostRing0)
                 rc = DBGFR3AddrFromSelOff(UnwindCtx.m_pUVM, UnwindCtx.m_idCpu, &pCur->AddrFrame,
Index: trunk/src/VBox/VMM/VMMR3/EM.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/EM.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/EM.cpp	(revision 107227)
@@ -116,5 +116,6 @@
 
     int rc = CFGMR3QueryBoolDef(pCfgEM, "IemExecutesAll", &pVM->em.s.fIemExecutesAll,
-#if defined(RT_ARCH_ARM64) && defined(RT_OS_DARWIN) && !defined(VBOX_VMM_TARGET_ARMV8)
+#if (defined(VBOX_VMM_TARGET_X86)   && !defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) \
+ || (defined(VBOX_VMM_TARGET_ARMV8) && !defined(RT_ARCH_ARM64)) /** @todo not main exec engine = iem/recomp would be better... */
                                 true
 #else
@@ -706,5 +707,5 @@
 #endif /* LOG_ENABLED || VBOX_STRICT */
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
 
 /**
@@ -852,5 +853,5 @@
 }
 
-#endif /* VBOX_VMM_TARGET_ARMV8 */
+#endif /* VBOX_VMM_TARGET_X86 */
 
 /**
@@ -885,14 +886,19 @@
                     rc = EMR3HmSingleInstruction(pVM, pVCpu, 0 /*fFlags*/);
 #endif
-#if !defined(VBOX_VMM_TARGET_ARMV8)
                 else if (pVCpu->em.s.enmState == EMSTATE_DEBUG_GUEST_NEM)
                     rc = VBOXSTRICTRC_TODO(emR3NemSingleInstruction(pVM, pVCpu, 0 /*fFlags*/));
                 else
                 {
+#if defined(VBOX_VMM_TARGET_X86) /** @todo IEM/arm64 */
                     rc = IEMExecOne(pVCpu); /** @todo add dedicated interface... */
                     if (rc == VINF_SUCCESS || rc == VINF_EM_RESCHEDULE)
                         rc = VINF_EM_DBG_STEPPED;
+#else
+                    AssertFailed();
+                    rc = VBOXSTRICTRC_TODO(emR3NemSingleInstruction(pVM, pVCpu, 0 /*fFlags*/));
+#endif
                 }
 
+#ifdef VBOX_VMM_TARGET_X86
                 if (rc != VINF_EM_EMULATE_SPLIT_LOCK)
                 { /* likely */ }
@@ -903,8 +909,4 @@
                         rc = VINF_EM_DBG_STEPPED;
                 }
-#else
-                AssertMsg(pVCpu->em.s.enmState == EMSTATE_DEBUG_GUEST_NEM,
-                          ("%u\n", pVCpu->em.s.enmState));
-                rc = VBOXSTRICTRC_TODO(emR3NemSingleInstruction(pVM, pVCpu, 0 /*fFlags*/));
 #endif
                 break;
@@ -1072,6 +1074,8 @@
 #ifdef VBOX_VMM_TARGET_ARMV8
     LogFlow(("emR3RecompilerExecute/%u: (pc=%RGv)\n", pVCpu->idCpu, (RTGCPTR)pVCpu->cpum.GstCtx.Pc.u64));
+#elif defined(VBOX_VMM_TARGET_X86)
+    LogFlow(("emR3RecompilerExecute/%u: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip));
 #else
-    LogFlow(("emR3RecompilerExecute/%u: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip));
+# error "port me"
 #endif
 
@@ -1085,6 +1089,6 @@
 #ifdef LOG_ENABLED
 # if defined(VBOX_VMM_TARGET_ARMV8)
-        Log3(("EM: pc=%08x\n", CPUMGetGuestFlatPC(pVCpu)));
-# else
+        Log3(("EM: pc=%08RX64\n", CPUMGetGuestFlatPC(pVCpu)));
+# elif defined(VBOX_VMM_TARGET_X86)
         if (!pVCpu->cpum.GstCtx.eflags.Bits.u1VM)
             Log(("EMR%d: %04X:%08RX64 RSP=%08RX64 IF=%d CR0=%x eflags=%x\n", CPUMGetGuestCPL(pVCpu), pVCpu->cpum.GstCtx.cs.Sel,
@@ -1093,4 +1097,6 @@
         else
             Log(("EMV86: %04X:%08X IF=%d\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF));
+# else
+#  error "port me"
 # endif
 #endif
@@ -1174,5 +1180,5 @@
          * Check if we can switch back to the main execution engine now.
          */
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_WITH_HWVIRT
         if (VM_IS_HM_ENABLED(pVM))
         {
@@ -1274,5 +1280,5 @@
         PDMCritSectBothFF(pVM, pVCpu);
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
     /* Update CR3 (Nested Paging case for HM). */
     if (VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_HM_UPDATE_CR3))
@@ -1312,6 +1318,6 @@
 }
 
-
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
+
 /**
  * Helper for emR3ForcedActions() for VMX external interrupt VM-exit.
@@ -1323,5 +1329,5 @@
 static int emR3VmxNstGstIntrIntercept(PVMCPU pVCpu)
 {
-#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
+# ifdef VBOX_WITH_NESTED_HWVIRT_VMX
     /* Handle the "external interrupt" VM-exit intercept. */
     if (    CPUMIsGuestVmxPinCtlsSet(&pVCpu->cpum.GstCtx, VMX_PIN_CTLS_EXT_INT_EXIT)
@@ -1334,7 +1340,7 @@
         return VBOXSTRICTRC_VAL(rcStrict);
     }
-#else
+# else
     RT_NOREF(pVCpu);
-#endif
+# endif
     return VINF_NO_CHANGE;
 }
@@ -1350,5 +1356,5 @@
 static int emR3SvmNstGstIntrIntercept(PVMCPU pVCpu)
 {
-#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
+# ifdef VBOX_WITH_NESTED_HWVIRT_SVM
     /* Handle the physical interrupt intercept (can be masked by the nested hypervisor). */
     if (CPUMIsGuestSvmCtrlInterceptSet(pVCpu, &pVCpu->cpum.GstCtx, SVM_CTRL_INTERCEPT_INTR))
@@ -1366,7 +1372,7 @@
         return VINF_EM_TRIPLE_FAULT;
     }
-#else
+# else
     NOREF(pVCpu);
-#endif
+# endif
     return VINF_NO_CHANGE;
 }
@@ -1382,5 +1388,5 @@
 static int emR3SvmNstGstVirtIntrIntercept(PVMCPU pVCpu)
 {
-#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
+# ifdef VBOX_WITH_NESTED_HWVIRT_SVM
     if (CPUMIsGuestSvmCtrlInterceptSet(pVCpu, &pVCpu->cpum.GstCtx, SVM_CTRL_INTERCEPT_VINTR))
     {
@@ -1395,11 +1401,11 @@
         return VINF_EM_TRIPLE_FAULT;
     }
-#else
+# else
     NOREF(pVCpu);
-#endif
+# endif
     return VINF_NO_CHANGE;
 }
-#endif
-
+
+#endif /* VBOX_VMM_TARGET_X86 */
 
 /**
@@ -1658,5 +1664,5 @@
             TMR3TimerQueuesDo(pVM);
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
         /*
          * Pick up asynchronously posted interrupts into the APIC.
@@ -1803,5 +1809,5 @@
             Assert(!VMCPU_FF_IS_ANY_SET(pVCpu, VMCPU_FF_VMX_APIC_WRITE | VMCPU_FF_VMX_MTF | VMCPU_FF_VMX_PREEMPT_TIMER));
         }
-# endif
+# endif /* VBOX_WITH_NESTED_HWVIRT_VMX */
 
         /*
@@ -1959,7 +1965,6 @@
         }
 
-#else /* VBOX_VMM_TARGET_ARMV8 */
+#else  /* VBOX_VMM_TARGET_ARMV8 */
         bool fWakeupPending = false;
-
         if (VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_VTIMER_ACTIVATED))
         {
@@ -2081,8 +2086,10 @@
         /* check that we got them all  */
         AssertCompile(VM_FF_HIGH_PRIORITY_PRE_MASK == (VM_FF_TM_VIRTUAL_SYNC | VM_FF_DBGF | VM_FF_CHECK_VM_STATE | VM_FF_DEBUG_SUSPEND | VM_FF_PGM_NEED_HANDY_PAGES | VM_FF_PGM_NO_MEMORY | VM_FF_EMT_RENDEZVOUS));
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
         AssertCompile(VMCPU_FF_HIGH_PRIORITY_PRE_MASK == (VMCPU_FF_TIMER | VMCPU_FF_INTERRUPT_IRQ | VMCPU_FF_INTERRUPT_FIQ | VMCPU_FF_DBGF));
+#elif defined(VBOX_VMM_TARGET_X86)
+        AssertCompile(VMCPU_FF_HIGH_PRIORITY_PRE_MASK == (VMCPU_FF_TIMER | VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_UPDATE_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL | VMCPU_FF_DBGF | VMCPU_FF_INTERRUPT_NESTED_GUEST | VMCPU_FF_VMX_MTF | VMCPU_FF_VMX_APIC_WRITE | VMCPU_FF_VMX_PREEMPT_TIMER | VMCPU_FF_VMX_INT_WINDOW | VMCPU_FF_VMX_NMI_WINDOW));
 #else
-        AssertCompile(VMCPU_FF_HIGH_PRIORITY_PRE_MASK == (VMCPU_FF_TIMER | VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_UPDATE_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL | VMCPU_FF_DBGF | VMCPU_FF_INTERRUPT_NESTED_GUEST | VMCPU_FF_VMX_MTF | VMCPU_FF_VMX_APIC_WRITE | VMCPU_FF_VMX_PREEMPT_TIMER | VMCPU_FF_VMX_INT_WINDOW | VMCPU_FF_VMX_NMI_WINDOW));
+# error "port me"
 #endif
     }
@@ -2209,5 +2216,5 @@
                 fFFDone = false;
 
-#if defined(VBOX_STRICT) && !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_STRICT) && defined(VBOX_VMM_TARGET_X86)
             CPUMAssertGuestRFlagsCookie(pVM, pVCpu);
 #endif
@@ -2233,5 +2240,5 @@
                     if (!pVM->em.s.fIemExecutesAll)
                     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_WITH_HWVIRT
                         if (VM_IS_HM_ENABLED(pVM))
                         {
@@ -2597,5 +2604,5 @@
                     else if (rc == VINF_SUCCESS)
                         rc = VINF_EM_RESCHEDULE; /* Need to check whether we can run in HM or NEM again. */
-#ifndef VBOX_VMM_TARGET_ARMV8
+#ifdef VBOX_VMM_TARGET_X86
                     if (rc != VINF_EM_EMULATE_SPLIT_LOCK)
                     { /* likely */ }
@@ -2624,5 +2631,5 @@
                     if (TRPMHasTrap(pVCpu))
                         rc = VINF_EM_RESCHEDULE;
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
                     /* MWAIT has a special extension where it's woken up when
                        an interrupt is pending even when IF=0. */
@@ -2649,18 +2656,22 @@
                     else
                     {
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
                         const uint32_t fWaitHalted = 0; /* WFI/WFE always return when an interrupt happens. */
-#else
+#elif defined(VBOX_VMM_TARGET_X86)
                         const uint32_t fWaitHalted = (CPUMGetGuestEFlags(pVCpu) & X86_EFL_IF) ? 0 : VMWAITHALTED_F_IGNORE_IRQS;
 #endif
                         rc = VMR3WaitHalted(pVM, pVCpu, fWaitHalted);
+
                         /* We're only interested in NMI/SMIs here which have their own FFs, so we don't need to
                            check VMCPU_FF_UPDATE_APIC here. */
                         if (   rc == VINF_SUCCESS
-#if defined(VBOX_VMM_TARGET_ARMV8)
-                            && VMCPU_FF_IS_ANY_SET(pVCpu,   VMCPU_FF_INTERRUPT_NMI | VMCPU_FF_INTERRUPT_SMI | VMCPU_FF_VTIMER_ACTIVATED
-                                                          | VMCPU_FF_INTERRUPT_FIQ | VMCPU_FF_INTERRUPT_IRQ)
+#ifdef VBOX_VMM_TARGET_ARMV8
+                            && VMCPU_FF_IS_ANY_SET(pVCpu,   VMCPU_FF_INTERRUPT_NMI | VMCPU_FF_INTERRUPT_SMI
+                                                          | VMCPU_FF_INTERRUPT_FIQ | VMCPU_FF_INTERRUPT_IRQ
+                                                          | VMCPU_FF_VTIMER_ACTIVATED)
+#elif defined(VBOX_VMM_TARGET_X86)
+                            && VMCPU_FF_IS_ANY_SET(pVCpu, VMCPU_FF_INTERRUPT_NMI | VMCPU_FF_INTERRUPT_SMI | VMCPU_FF_UNHALT)
 #else
-                            && VMCPU_FF_IS_ANY_SET(pVCpu, VMCPU_FF_INTERRUPT_NMI | VMCPU_FF_INTERRUPT_SMI | VMCPU_FF_UNHALT)
+# error "port me"
 #endif
                             )
Index: trunk/src/VBox/VMM/VMMR3/EMR3Dbg.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/EMR3Dbg.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/EMR3Dbg.cpp	(revision 107227)
@@ -169,5 +169,5 @@
             break;
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86) && defined(VBOX_WITH_HWVIRT)
         case EMEXIT_F_KIND_VMX:
             pszExitName = HMGetVmxExitName(uFlagsAndType & EMEXIT_F_TYPE_MASK);
@@ -187,9 +187,6 @@
             break;
 
+#ifdef VBOX_VMM_TARGET_X86
         case EMEXIT_F_KIND_XCPT:
-#if defined(VBOX_VMM_TARGET_ARMV8)
-            pszExitName = NULL;
-            AssertReleaseFailed();
-#else
             switch (uFlagsAndType & EMEXIT_F_TYPE_MASK)
             {
@@ -232,6 +229,6 @@
                     break;
             }
+            break;
 #endif
-            break;
 
         default:
Index: trunk/src/VBox/VMM/VMMR3/EMR3Nem.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/EMR3Nem.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/EMR3Nem.cpp	(revision 107227)
@@ -97,8 +97,10 @@
         return VINF_EM_RESCHEDULE;
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    uint64_t const uOldPc = pVCpu->cpum.GstCtx.Pc.u64;
+#ifdef VBOX_VMM_TARGET_ARMV8
+    uint64_t const uOldPc  = pVCpu->cpum.GstCtx.Pc.u64;
+#elif defined(VBOX_VMM_TARGET_X86)
+    uint64_t const uOldRip = pVCpu->cpum.GstCtx.rip;
 #else
-    uint64_t const uOldRip = pVCpu->cpum.GstCtx.rip;
+# error "port me"
 #endif
     for (;;)
@@ -147,5 +149,5 @@
          * Done?
          */
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
         CPUM_ASSERT_NOT_EXTRN(pVCpu, CPUMCTX_EXTRN_PC);
         if (   (rcStrict != VINF_SUCCESS && rcStrict != VINF_EM_DBG_STEPPED)
@@ -160,5 +162,6 @@
             return rcStrict;
         }
-#else
+
+#elif defined(VBOX_VMM_TARGET_X86)
         CPUM_ASSERT_NOT_EXTRN(pVCpu, CPUMCTX_EXTRN_RIP);
         if (   (rcStrict != VINF_SUCCESS && rcStrict != VINF_EM_DBG_STEPPED)
@@ -173,4 +176,7 @@
             return rcStrict;
         }
+
+#else
+# error "port me"
 #endif
     }
@@ -201,8 +207,7 @@
      * Log it.
      */
-#ifdef VBOX_VMM_TARGET_ARMV8
+# ifdef VBOX_VMM_TARGET_ARMV8
     Log(("EMINS: %RGv SP_EL0=%RGv SP_EL1=%RGv\n", (RTGCPTR)pVCpu->cpum.GstCtx.Pc.u64,
-                                                  (RTGCPTR)pVCpu->cpum.GstCtx.aSpReg[0].u64,
-                                                  (RTGCPTR)pVCpu->cpum.GstCtx.aSpReg[1].u64));
+         (RTGCPTR)pVCpu->cpum.GstCtx.aSpReg[0].u64, (RTGCPTR)pVCpu->cpum.GstCtx.aSpReg[1].u64));
     if (pszPrefix)
     {
@@ -210,5 +215,5 @@
         DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, pszPrefix);
     }
-# else
+# elif defined(VBOX_VMM_TARGET_X86)
     Log(("EMINS: %04x:%RGv RSP=%RGv\n", pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip, (RTGCPTR)pVCpu->cpum.GstCtx.rsp));
     if (pszPrefix)
@@ -217,4 +222,6 @@
         DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, pszPrefix);
     }
+# else
+#  error "port me"
 # endif
 #endif
@@ -375,6 +382,8 @@
 #ifdef VBOX_VMM_TARGET_ARMV8
     LogFlow(("emR3NemExecute%d: (pc=%RGv)\n", pVCpu->idCpu, (RTGCPTR)pVCpu->cpum.GstCtx.Pc.u64));
+#elif defined(VBOX_VMM_TARGET_X86)
+    LogFlow(("emR3NemExecute%d: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip));
 #else
-    LogFlow(("emR3NemExecute%d: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip));
+# error "port me"
 #endif
     *pfFFDone = false;
@@ -411,8 +420,9 @@
         }
 
-#if defined(LOG_ENABLED) && !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef LOG_ENABLED
         /*
          * Log important stuff before entering GC.
          */
+# ifdef VBOX_VMM_TARGET_X86
         if (TRPMHasTrap(pVCpu))
             Log(("CPU%d: Pending hardware interrupt=0x%x cs:rip=%04X:%RGv\n", pVCpu->idCpu, TRPMGetTrapNo(pVCpu), pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip));
@@ -441,8 +451,20 @@
             }
         }
+# elif defined(VBOX_VMM_TARGET_ARMV8)
+        if (!(pVCpu->cpum.GstCtx.fExtrn & CPUMCTX_EXTRN_PC))
+        {
+            /** @todo better logging */
+            if (pVM->cCpus == 1)
+                Log(("NEM: %RX64\n", pVCpu->cpum.GstCtx.Pc.u64));
+            else
+                Log(("NEM-CPU%d: %RX64\n", pVCpu->idCpu, pVCpu->cpum.GstCtx.Pc.u64));
+        }
+# else
+#  error "port me"
+# endif
         else if (pVM->cCpus == 1)
             Log(("NEMRx: -> NEMR3RunGC\n"));
         else
-            Log(("NEMRx-CPU%u: -> NEMR3RunGC\n",  pVCpu->idCpu));
+            Log(("NEMRx-CPU%u: -> NEMR3RunGC\n", pVCpu->idCpu));
 #endif /* LOG_ENABLED */
 
Index: trunk/src/VBox/VMM/VMMR3/GIM.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/GIM.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/GIM.cpp	(revision 107227)
@@ -74,5 +74,5 @@
 #include <iprt/string.h>
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86)
 /* Include all GIM providers. */
 # include "GIMMinimalInternal.h"
@@ -163,5 +163,5 @@
          *        'most up-to-date implementation' version number when 0. Otherwise,
          *        we'll have abiguities when loading the state of older VMs. */
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86)
         if (!RTStrCmp(szProvider, "Minimal"))
         {
@@ -210,5 +210,5 @@
     switch (pVM->gim.s.enmProviderId)
     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86)
         case GIMPROVIDERID_MINIMAL:
             return gimR3MinimalInitCompleted(pVM);
@@ -261,5 +261,5 @@
     switch (pVM->gim.s.enmProviderId)
     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86)
         case GIMPROVIDERID_HYPERV:
             rc = gimR3HvSave(pVM, pSSM);
@@ -326,5 +326,5 @@
     switch (pVM->gim.s.enmProviderId)
     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86)
         case GIMPROVIDERID_HYPERV:
             rc = gimR3HvLoad(pVM, pSSM);
@@ -350,11 +350,9 @@
 static DECLCALLBACK(int) gimR3LoadDone(PVM pVM, PSSMHANDLE pSSM)
 {
-#if defined(VBOX_VMM_TARGET_ARMV8)
     RT_NOREF(pSSM);
-#endif
 
     switch (pVM->gim.s.enmProviderId)
     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86)
         case GIMPROVIDERID_HYPERV:
             return gimR3HvLoadDone(pVM, pSSM);
@@ -379,5 +377,5 @@
     switch (pVM->gim.s.enmProviderId)
     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86)
         case GIMPROVIDERID_HYPERV:
             return gimR3HvTerm(pVM);
@@ -387,7 +385,6 @@
 #endif
         default:
-            break;
-    }
-    return VINF_SUCCESS;
+            return VINF_SUCCESS;
+    }
 }
 
@@ -403,11 +400,9 @@
 VMMR3_INT_DECL(void) GIMR3Relocate(PVM pVM, RTGCINTPTR offDelta)
 {
-#if defined(VBOX_VMM_TARGET_ARMV8)
     RT_NOREF(offDelta);
-#endif
 
     switch (pVM->gim.s.enmProviderId)
     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86)
         case GIMPROVIDERID_HYPERV:
             gimR3HvRelocate(pVM, offDelta);
@@ -432,10 +427,12 @@
     switch (pVM->gim.s.enmProviderId)
     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86)
         case GIMPROVIDERID_HYPERV:
-            return gimR3HvReset(pVM);
+            gimR3HvReset(pVM);
+            break;
 
         case GIMPROVIDERID_KVM:
-            return gimR3KvmReset(pVM);
+            gimR3KvmReset(pVM);
+            break;
 #endif
         default:
@@ -474,12 +471,11 @@
     switch (pVM->gim.s.enmProviderId)
     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#if defined(VBOX_VMM_TARGET_X86)
         case GIMPROVIDERID_HYPERV:
             return gimR3HvGetDebugSetup(pVM, pDbgSetup);
 #endif
         default:
-            break;
-    }
-    return VERR_GIM_NO_DEBUG_CONNECTION;
+            return VERR_GIM_NO_DEBUG_CONNECTION;
+    }
 }
 
Index: trunk/src/VBox/VMM/VMMR3/IEMR3.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/IEMR3.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/IEMR3.cpp	(revision 107227)
@@ -37,4 +37,5 @@
 #include <VBox/vmm/mm.h>
 #include <VBox/vmm/ssm.h>
+/** @todo this isn't sustainable.   */
 #if defined(VBOX_VMM_TARGET_ARMV8)
 # include "IEMInternal-armv8.h"
Index: trunk/src/VBox/VMM/VMMR3/MM.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/MM.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/MM.cpp	(revision 107227)
@@ -171,5 +171,5 @@
 #include <iprt/assert.h>
 #include <iprt/string.h>
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
 # include <iprt/file.h>
 #endif
@@ -271,6 +271,6 @@
 }
 
-
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
+
 /**
  * Initializes the given RAM range with data from the given file.
@@ -287,10 +287,10 @@
     if (RT_SUCCESS(rc))
     {
-        uint8_t abRead[GUEST_PAGE_SIZE];
         RTGCPHYS GCPhys = GCPhysStart;
 
         for (;;)
         {
-            size_t cbThisRead = 0;
+            uint8_t abRead[GUEST_PAGE_SIZE];
+            size_t  cbThisRead = 0;
             rc = RTFileRead(hFile, &abRead[0], sizeof(abRead), &cbThisRead);
             if (RT_FAILURE(rc))
@@ -391,50 +391,32 @@
         if (u64GCPhysStart >= _4G)
             pVM->mm.s.cbRamAbove4GB += u64MemSize;
-        else if (u64GCPhysStart + u64MemSize > _4G)
+        else if (u64GCPhysStart + u64MemSize <= _4G)
+            pVM->mm.s.cbRamBelow4GB += (uint32_t)u64MemSize;
+        else
         {
-            uint64_t cbRamAbove4GB = (u64GCPhysStart + u64MemSize) - _4G;
+            uint64_t const cbRamAbove4GB = u64GCPhysStart + u64MemSize - _4G;
             pVM->mm.s.cbRamAbove4GB += cbRamAbove4GB;
-            pVM->mm.s.cbRamBelow4GB += (u64MemSize - cbRamAbove4GB);
+            pVM->mm.s.cbRamBelow4GB += u64MemSize - cbRamAbove4GB;
         }
-        else
-            pVM->mm.s.cbRamBelow4GB += (uint32_t)u64MemSize;
-    }
-
-    return rc;
-}
-#endif
-
-
-/**
- * Initializes the MM parts which depends on PGM being initialized.
- *
- * @returns VBox status code.
- * @param   pVM         The cross context VM structure.
- * @remark  No cleanup necessary since MMR3Term() will be called on failure.
- */
-VMMR3DECL(int) MMR3InitPaging(PVM pVM)
-{
-    LogFlow(("MMR3InitPaging:\n"));
-
-    /*
-     * Query the CFGM values.
-     */
-    int rc;
-    PCFGMNODE pMMCfg = CFGMR3GetChild(CFGMR3GetRoot(pVM), "MM");
-    if (!pMMCfg)
-    {
-        rc = CFGMR3InsertNode(CFGMR3GetRoot(pVM), "MM", &pMMCfg);
-        AssertRCReturn(rc, rc);
-    }
-
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    rc = mmR3InitRamArmV8(pVM, pMMCfg);
-#else
+    }
+
+    return rc;
+}
+
+#elif defined(VBOX_VMM_TARGET_X86)
+
+/**
+ * RAM setup function for X86.
+ */
+static int mmR3InitRamX86(PVM pVM, PCFGMNODE pMMCfg)
+{
+    RT_NOREF(pMMCfg);
+
     /** @cfgm{/RamSize, uint64_t, 0, 16TB, 0}
      * Specifies the size of the base RAM that is to be set up during
      * VM initialization.
      */
-    uint64_t cbRam;
-    rc = CFGMR3QueryU64(CFGMR3GetRoot(pVM), "RamSize", &cbRam);
+    uint64_t cbRam = 0;
+    int rc = CFGMR3QueryU64(CFGMR3GetRoot(pVM), "RamSize", &cbRam);
     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
         cbRam = 0;
@@ -450,5 +432,5 @@
      * to avoid mapping RAM to the range normally used for PCI memory regions.
      * Must be aligned on a 4MB boundary. */
-    uint32_t cbRamHole;
+    uint32_t cbRamHole = 0;
     rc = CFGMR3QueryU32Def(CFGMR3GetRoot(pVM), "RamHoleSize", &cbRamHole, MM_RAM_HOLE_SIZE_DEFAULT);
     AssertLogRelMsgRCReturn(rc, ("Configuration error: Failed to query integer \"RamHoleSize\", rc=%Rrc.\n", rc), rc);
@@ -561,5 +543,40 @@
         }
     }
-#endif /* !VBOX_VMM_TARGET_ARMV8 */
+
+    AssertMsg(pVM->mm.s.cBasePages == cBasePages || RT_FAILURE(rc), ("%RX64 != %RX64\n", pVM->mm.s.cBasePages, cBasePages));
+    return rc;
+}
+
+#endif /* VBOX_VMM_TARGET_X86 */
+
+/**
+ * Initializes the MM parts which depends on PGM being initialized.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The cross context VM structure.
+ * @remark  No cleanup necessary since MMR3Term() will be called on failure.
+ */
+VMMR3DECL(int) MMR3InitPaging(PVM pVM)
+{
+    LogFlow(("MMR3InitPaging:\n"));
+
+    /*
+     * Query the CFGM values.
+     */
+    int rc;
+    PCFGMNODE pMMCfg = CFGMR3GetChild(CFGMR3GetRoot(pVM), "MM");
+    if (!pMMCfg)
+    {
+        rc = CFGMR3InsertNode(CFGMR3GetRoot(pVM), "MM", &pMMCfg);
+        AssertRCReturn(rc, rc);
+    }
+
+#ifdef VBOX_VMM_TARGET_ARMV8
+    rc = mmR3InitRamArmV8(pVM, pMMCfg);
+#elif defined(VBOX_VMM_TARGET_X86)
+    rc = mmR3InitRamX86(pVM, pMMCfg);
+#else
+# error "port me"
+#endif
 
     /*
@@ -568,7 +585,4 @@
      */
     pVM->mm.s.fDoneMMR3InitPaging = true;
-#if !defined(VBOX_VMM_TARGET_ARMV8)
-    AssertMsg(pVM->mm.s.cBasePages == cBasePages || RT_FAILURE(rc), ("%RX64 != %RX64\n", pVM->mm.s.cBasePages, cBasePages));
-#endif
 
     LogFlow(("MMR3InitPaging: returns %Rrc\n", rc));
Index: trunk/src/VBox/VMM/VMMR3/NEMR3.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/NEMR3.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/NEMR3.cpp	(revision 107227)
@@ -103,5 +103,5 @@
                                   "|VmxLbr"
 #endif
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
                                   "|VTimerInterrupt"
 #endif
@@ -140,5 +140,5 @@
     }
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
     /** @cfgm{/NEM/VTimerInterrupt, uint32_t}
      * Specifies the interrupt identifier for the VTimer. */
@@ -182,6 +182,5 @@
             if (pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
             {
-#ifndef VBOX_VMM_TARGET_ARMV8 /* NEM is the only option on ARM for now, so calling it turtle and snail mode
-                               * is a bit unfair as long as we don't have a native hypervisor to compare against :). */
+#ifndef VBOX_WITH_HWVIRT /* Don't complain if there are no other alternatives. */
 # ifdef RT_OS_WINDOWS /* The WHv* API is extremely slow at handling VM exits. The AppleHv and
                          KVM APIs are much faster, thus the different mode name. :-) */
Index: trunk/src/VBox/VMM/VMMR3/NEMR3NativeTemplate-linux.cpp.h
===================================================================
--- trunk/src/VBox/VMM/VMMR3/NEMR3NativeTemplate-linux.cpp.h	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/NEMR3NativeTemplate-linux.cpp.h	(revision 107227)
@@ -66,8 +66,8 @@
 
         CAP_ENTRY__L(KVM_CAP_IRQCHIP),                       /* 0 */
-#ifdef VBOX_VMM_TARGET_ARMV8
+#ifdef VBOX_VMM_TARGET_X86
+        CAP_ENTRY_ML(KVM_CAP_HLT),
+#else
         CAP_ENTRY__L(KVM_CAP_HLT),
-#else
-        CAP_ENTRY_ML(KVM_CAP_HLT),
 #endif
         CAP_ENTRY__L(KVM_CAP_MMU_SHADOW_CACHE_CONTROL),
@@ -120,8 +120,8 @@
         CAP_ENTRY__L(KVM_CAP_XEN_HVM),
 #endif
-#ifdef VBOX_VMM_TARGET_ARMV8
+#ifdef VBOX_VMM_TARGET_X86
+        CAP_ENTRY_ML(KVM_CAP_ADJUST_CLOCK),
+#else
         CAP_ENTRY__L(KVM_CAP_ADJUST_CLOCK),
-#else
-        CAP_ENTRY_ML(KVM_CAP_ADJUST_CLOCK),
 #endif
         CAP_ENTRY__L(KVM_CAP_INTERNAL_ERROR_DATA),           /* 40 */
@@ -142,8 +142,8 @@
         CAP_ENTRY__L(KVM_CAP_DEBUGREGS),                     /* 50 */
 #endif
-#ifdef VBOX_VMM_TARGET_ARMV8
+#ifdef VBOX_VMM_TARGET_X86
+        CAP_ENTRY__S(KVM_CAP_X86_ROBUST_SINGLESTEP, fRobustSingleStep),
+#else
         CAP_ENTRY__L(KVM_CAP_X86_ROBUST_SINGLESTEP),
-#else
-        CAP_ENTRY__S(KVM_CAP_X86_ROBUST_SINGLESTEP, fRobustSingleStep),
 #endif
         CAP_ENTRY__L(KVM_CAP_PPC_OSI),
@@ -305,10 +305,10 @@
         CAP_ENTRY__L(KVM_CAP_S390_DIAG318),
         CAP_ENTRY__L(KVM_CAP_STEAL_TIME),
-#ifdef VBOX_VMM_TARGET_ARMV8
+#ifdef VBOX_VMM_TARGET_X86
+        CAP_ENTRY_ML(KVM_CAP_X86_USER_SPACE_MSR),            /* (since 5.10) */
+        CAP_ENTRY_ML(KVM_CAP_X86_MSR_FILTER),
+#else
         CAP_ENTRY__L(KVM_CAP_X86_USER_SPACE_MSR),            /* (since 5.10) */
         CAP_ENTRY__L(KVM_CAP_X86_MSR_FILTER),
-#else
-        CAP_ENTRY_ML(KVM_CAP_X86_USER_SPACE_MSR),            /* (since 5.10) */
-        CAP_ENTRY_ML(KVM_CAP_X86_MSR_FILTER),
 #endif
         CAP_ENTRY__L(KVM_CAP_ENFORCE_PV_FEATURE_CPUID),      /* 190 */
Index: trunk/src/VBox/VMM/VMMR3/PDM.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/PDM.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/PDM.cpp	(revision 107227)
@@ -1031,10 +1031,12 @@
     {
         PVMCPU pVCpu = pVM->apCpusR3[idCpu];
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
         SSMR3PutU32(pSSM, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_IRQ));
         SSMR3PutU32(pSSM, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_FIQ));
-#else
+#elif defined(VBOX_VMM_TARGET_X86)
         SSMR3PutU32(pSSM, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_APIC));
         SSMR3PutU32(pSSM, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC));
+#else
+# error "port me"
 #endif
         SSMR3PutU32(pSSM, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_NMI));
@@ -1066,13 +1068,15 @@
     {
         PVMCPU pVCpu = pVM->apCpusR3[idCpu];
-#if defined(VBOX_VMM_TARGET_ARMV8)
+# ifdef VBOX_VMM_TARGET_ARMV8
         LogFlow(("pdmR3LoadPrep: VCPU %u %s%s\n", idCpu,
                 VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_IRQ) ? " VMCPU_FF_INTERRUPT_IRQ" : "",
                 VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_FIQ) ? " VMCPU_FF_INTERRUPT_FIQ" : ""));
-#else
+# elif defined(VBOX_VMM_TARGET_X86)
         LogFlow(("pdmR3LoadPrep: VCPU %u %s%s\n", idCpu,
                 VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_APIC) ? " VMCPU_FF_INTERRUPT_APIC" : "",
                 VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC)  ? " VMCPU_FF_INTERRUPT_PIC" : ""));
-#endif
+# else
+#  error "port me"
+# endif
     }
 #endif
@@ -1090,10 +1094,12 @@
     {
         PVMCPU pVCpu = pVM->apCpusR3[idCpu];
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
         VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_IRQ);
         VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_FIQ);
-#else
+#elif defined(VBOX_VMM_TARGET_X86)
         VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_APIC);
         VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_PIC);
+#else
+# error "port me"
 #endif
         VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_NMI);
@@ -1157,14 +1163,17 @@
                 return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
             }
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
             AssertLogRelMsg(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_IRQ),
                             ("VCPU%03u: VMCPU_FF_INTERRUPT_IRQ set! Devices shouldn't set interrupts during state restore...\n", idCpu));
             if (fInterruptPending)
                 VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_IRQ);
-#else
+
+#elif defined(VBOX_VMM_TARGET_X86)
             AssertLogRelMsg(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_APIC),
                             ("VCPU%03u: VMCPU_FF_INTERRUPT_APIC set! Devices shouldn't set interrupts during state restore...\n", idCpu));
             if (fInterruptPending)
                 VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_APIC);
+#else
+# error "port me"
 #endif
 
@@ -1179,14 +1188,17 @@
                 return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
             }
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
             AssertLogRelMsg(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_FIQ),
                             ("VCPU%03u: VMCPU_FF_INTERRUPT_FIQ set!  Devices shouldn't set interrupts during state restore...\n", idCpu));
             if (fInterruptPending)
                 VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_FIQ);
-#else
+
+#elif defined(VBOX_VMM_TARGET_X86)
             AssertLogRelMsg(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC),
                             ("VCPU%03u: VMCPU_FF_INTERRUPT_PIC set!  Devices shouldn't set interrupts during state restore...\n", idCpu));
             if (fInterruptPending)
                 VMCPU_FF_SET(pVCpu, VMCPU_FF_INTERRUPT_PIC);
+#else
+# error "port me"
 #endif
 
@@ -1730,10 +1742,12 @@
 VMMR3_INT_DECL(void) PDMR3ResetCpu(PVMCPU pVCpu)
 {
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
     VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_IRQ);
     VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_FIQ);
-#else
+#elif defined(VBOX_VMM_TARGET_X86)
     VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_APIC);
     VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_PIC);
+#else
+# error "port me"
 #endif
     VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_NMI);
Index: trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp	(revision 107227)
@@ -35,5 +35,5 @@
 #include <VBox/vmm/pgm.h>
 #include <VBox/vmm/hm.h>
-#ifndef VBOX_VMM_TARGET_ARMV8
+#ifdef VBOX_VMM_TARGET_X86
 # include <VBox/vmm/pdmapic.h>
 #endif
@@ -67,10 +67,10 @@
     Assert(pVM->enmVMState != VMSTATE_LOADING || pVM->pdm.s.fStateLoaded);
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
+    PVMCPU pVCpu = pVM->apCpusR3[0];  /* for PIC we always deliver to CPU 0, SMP uses APIC */
+    PDMApicSetLocalInterrupt(pVCpu, 0 /* u8Pin */, 1 /* u8Level */, VINF_SUCCESS /* rcRZ */);
+#else
     AssertReleaseFailed();
     RT_NOREF(pVM);
-#else
-    PVMCPU pVCpu = pVM->apCpusR3[0];  /* for PIC we always deliver to CPU 0, SMP uses APIC */
-    PDMApicSetLocalInterrupt(pVCpu, 0 /* u8Pin */, 1 /* u8Level */, VINF_SUCCESS /* rcRZ */);
 #endif
 }
@@ -86,10 +86,10 @@
     Assert(pVM->enmVMState != VMSTATE_LOADING || pVM->pdm.s.fStateLoaded);
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
+    PVMCPU pVCpu = pVM->apCpusR3[0];  /* for PIC we always deliver to CPU 0, SMP uses APIC */
+    PDMApicSetLocalInterrupt(pVCpu, 0 /* u8Pin */,  0 /* u8Level */, VINF_SUCCESS /* rcRZ */);
+#else
     AssertReleaseFailed();
     RT_NOREF(pVM);
-#else
-    PVMCPU pVCpu = pVM->apCpusR3[0];  /* for PIC we always deliver to CPU 0, SMP uses APIC */
-    PDMApicSetLocalInterrupt(pVCpu, 0 /* u8Pin */,  0 /* u8Level */, VINF_SUCCESS /* rcRZ */);
 #endif
 }
@@ -140,11 +140,11 @@
     LogFlow(("pdmR3IoApicHlp_ApicBusDeliver: caller='%s'/%d: u8Dest=%RX8 u8DestMode=%RX8 u8DeliveryMode=%RX8 uVector=%RX8 u8Polarity=%RX8 u8TriggerMode=%RX8 uTagSrc=%#x\n",
              pDevIns->pReg->szName, pDevIns->iInstance, u8Dest, u8DestMode, u8DeliveryMode, uVector, u8Polarity, u8TriggerMode, uTagSrc));
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
+    PVM pVM = pDevIns->Internal.s.pVMR3;
+    return PDMApicBusDeliver(pVM, u8Dest, u8DestMode, u8DeliveryMode, uVector, u8Polarity, u8TriggerMode, uTagSrc);
+#else
     AssertReleaseFailed();
     RT_NOREF(pDevIns, u8Dest, u8DestMode, u8DeliveryMode, uVector, u8Polarity, u8TriggerMode, uTagSrc);
     return VERR_NOT_IMPLEMENTED;
-#else
-    PVM pVM = pDevIns->Internal.s.pVMR3;
-    return PDMApicBusDeliver(pVM, u8Dest, u8DestMode, u8DeliveryMode, uVector, u8Polarity, u8TriggerMode, uTagSrc);
 #endif
 }
Index: trunk/src/VBox/VMM/VMMR3/PDMDevice.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/PDMDevice.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/PDMDevice.cpp	(revision 107227)
@@ -34,8 +34,8 @@
 #include "PDMInternal.h"
 #include <VBox/vmm/pdm.h>
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
 # include <VBox/vmm/gic.h>
 # include <VBox/vmm/pmu.h>
-#else
+#elif defined(VBOX_VMM_TARGET_X86)
 # include <VBox/vmm/pdmapic.h>
 #endif
@@ -700,26 +700,23 @@
     RegCB.pCfgNode         = NULL;
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    /*
-     * Register the internal VMM GIC device.
-     */
+    /*
+     * Register internal VMM devices.
+     */
+#ifdef VBOX_VMM_TARGET_ARMV8
+    /* Register the internal VMM GIC device. */
     int rc = pdmR3DevReg_Register(&RegCB.Core, &g_DeviceGIC);
     AssertRCReturn(rc, rc);
 
-    /*
-     * Register the internal VMM GIC device, NEM variant.
-     */
+    /* Register the internal VMM GIC device, NEM variant. */
     rc = pdmR3DevReg_Register(&RegCB.Core, &g_DeviceGICNem);
     AssertRCReturn(rc, rc);
 
-    /*
-     * Register the internal VMM PMU device.
-     */
+    /* Register the internal VMM PMU device. */
     rc = pdmR3DevReg_Register(&RegCB.Core, &g_DevicePMU);
     AssertRCReturn(rc, rc);
-#else
-    /*
-     * Register the internal VMM APIC device.
-     */
+#endif
+
+#ifdef VBOX_VMM_TARGET_X86
+    /* Register the internal VMM APIC device. */
     int rc = pdmR3DevReg_Register(&RegCB.Core, &g_DeviceAPIC);
     AssertRCReturn(rc, rc);
Index: trunk/src/VBox/VMM/VMMR3/PGM.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/PGM.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/PGM.cpp	(revision 107227)
@@ -2000,5 +2000,5 @@
         VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL);
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
         if (!pVCpu->pgm.s.fA20Enabled)
         {
Index: trunk/src/VBox/VMM/VMMR3/PGMDbg.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/PGMDbg.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/PGMDbg.cpp	(revision 107227)
@@ -1084,5 +1084,5 @@
         else
         {
-#ifndef VBOX_VMM_TARGET_ARMV8
+#ifdef VBOX_VMM_TARGET_X86
             Assert(WalkGst.enmType != PGMPTWALKGSTTYPE_INVALID);
 #endif
@@ -1095,5 +1095,5 @@
              */
             uint64_t cPagesCanSkip;
-#ifndef VBOX_VMM_TARGET_ARMV8
+#ifdef VBOX_VMM_TARGET_X86
             switch (Walk.uLevel)
             {
@@ -1144,5 +1144,7 @@
                 continue;
             }
-#else
+
+#elif defined(VBOX_VMM_TARGET_ARMV8)
+
             /** @todo Sketch, needs creating proper defines for constants in armv8.h and using these
              * instead of hardcoding these here. */
@@ -1178,4 +1180,6 @@
                 continue;
             }
+#else
+# error "port me"
 #endif
         }
@@ -1185,8 +1189,10 @@
             break;
         cPages -= cIncPages;
-#ifndef VBOX_VMM_TARGET_ARMV8
+#ifdef VBOX_VMM_TARGET_X86
         GCPtr += (RTGCPTR)cIncPages << X86_PT_PAE_SHIFT;
+#elif defined(VBOX_VMM_TARGET_ARMV8)
+        GCPtr += (RTGCPTR)cIncPages << 12;
 #else
-        GCPtr += (RTGCPTR)cIncPages << 12;
+# error "port me"
 #endif
 
Index: trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp	(revision 107227)
@@ -6322,5 +6322,5 @@
 *********************************************************************************************************************************/
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
 /**
  * Sets the Address Gate 20 state.
@@ -6335,5 +6335,5 @@
     if (pVCpu->pgm.s.fA20Enabled != fEnable)
     {
-#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
+# ifdef VBOX_WITH_NESTED_HWVIRT_VMX
         PCCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu);
         if (   CPUMIsGuestInVmxRootMode(pCtx)
@@ -6343,22 +6343,22 @@
             return;
         }
-#endif
+# endif
         pVCpu->pgm.s.fA20Enabled = fEnable;
         pVCpu->pgm.s.GCPhysA20Mask = ~((RTGCPHYS)!fEnable << 20);
         if (VM_IS_NEM_ENABLED(pVCpu->CTX_SUFF(pVM)))
             NEMR3NotifySetA20(pVCpu, fEnable);
-#ifdef PGM_WITH_A20
+# ifdef PGM_WITH_A20
         VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3);
         pgmR3RefreshShadowModeAfterA20Change(pVCpu);
         HMFlushTlb(pVCpu);
-#endif
-#if 0 /* PGMGetPage will apply the A20 mask to the GCPhys it returns, so we must invalid both sides of the TLB. */
+# endif
+# if 0 /* PGMGetPage will apply the A20 mask to the GCPhys it returns, so we must invalid both sides of the TLB. */
         IEMTlbInvalidateAllPhysical(pVCpu);
-#else
+# else
         IEMTlbInvalidateAllGlobal(pVCpu);
-#endif
+# endif
         STAM_REL_COUNTER_INC(&pVCpu->pgm.s.cA20Changes);
     }
 }
-#endif
-
+#endif /* VBOX_VMM_TARGET_X86 */
+
Index: trunk/src/VBox/VMM/VMMR3/PGMSavedState.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/PGMSavedState.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/PGMSavedState.cpp	(revision 107227)
@@ -3331,5 +3331,5 @@
                 AssertLogRelRCReturn(rc, rc);
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
                 /* Update the PSE, NX flags and validity masks. */
                 pVCpu->pgm.s.fGst32BitPageSizeExtension = CPUMIsGuestPageSizeExtEnabled(pVCpu);
Index: trunk/src/VBox/VMM/VMMR3/TM.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/TM.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/TM.cpp	(revision 107227)
@@ -818,5 +818,5 @@
         PVMCPU pVCpu = pVM->apCpusR3[i];
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
         pVCpu->cNsVTimerActivate   = UINT64_MAX;
 #endif
@@ -1315,5 +1315,5 @@
         pVCpu->tm.s.u64TSC         = 0;
         pVCpu->tm.s.u64TSCLastSeen = 0;
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
         pVCpu->cNsVTimerActivate   = UINT64_MAX;
 #endif
Index: trunk/src/VBox/VMM/VMMR3/TRPM.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/TRPM.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/TRPM.cpp	(revision 107227)
@@ -387,9 +387,5 @@
 VMMR3DECL(int) TRPMR3InjectEvent(PVM pVM, PVMCPU pVCpu, TRPMEVENT enmEvent, bool *pfInjected)
 {
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    RT_NOREF(pVM, pVCpu, enmEvent, pfInjected);
-    AssertReleaseFailed();
-    return VERR_NOT_IMPLEMENTED;
-#else
+#ifdef VBOX_VMM_TARGET_X86
     PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu);
     Assert(!CPUMIsInInterruptShadow(pCtx));
@@ -453,5 +449,10 @@
     return VINF_EM_RESCHEDULE;
 # endif
-#endif
+
+#else  /* !VBOX_VMM_TARGET_X86 */
+    RT_NOREF(pVM, pVCpu, enmEvent, pfInjected);
+    AssertReleaseFailed();
+    return VERR_NOT_IMPLEMENTED;
+#endif /* !VBOX_VMM_TARGET_X86 */
 }
 
Index: trunk/src/VBox/VMM/VMMR3/VM.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/VM.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/VM.cpp	(revision 107227)
@@ -875,8 +875,8 @@
                         if (RT_SUCCESS(rc))
                         {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
                             rc = SELMR3Init(pVM);
+                            if (RT_SUCCESS(rc))
 #endif
-                            if (RT_SUCCESS(rc))
                             {
                                 rc = TRPMR3Init(pVM);
@@ -906,8 +906,8 @@
                                                             if (RT_SUCCESS(rc))
                                                             {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
                                                                 rc = GCMR3Init(pVM);
+                                                                if (RT_SUCCESS(rc))
 #endif
-                                                                if (RT_SUCCESS(rc))
                                                                 {
                                                                     rc = PDMR3Init(pVM);
@@ -933,5 +933,5 @@
                                                                         AssertRC(rc2);
                                                                     }
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
                                                                     int rc2 = GCMR3Term(pVM);
                                                                     AssertRC(rc2);
@@ -958,5 +958,5 @@
                                     AssertRC(rc2);
                                 }
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
                                 int rc2 = SELMR3Term(pVM);
                                 AssertRC(rc2);
@@ -1081,9 +1081,9 @@
     CPUMR3Relocate(pVM);
     HMR3Relocate(pVM);
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
     SELMR3Relocate(pVM);
 #endif
     VMMR3Relocate(pVM, offDelta);
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
     SELMR3Relocate(pVM);                /* !hack! fix stack! */
 #endif
@@ -2237,5 +2237,5 @@
         rc = TRPMR3Term(pVM);
         AssertRC(rc);
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
         rc = SELMR3Term(pVM);
         AssertRC(rc);
@@ -2621,5 +2621,5 @@
         PDMR3Reset(pVM);
         PGMR3Reset(pVM);
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
         SELMR3Reset(pVM);
 #endif
@@ -4241,5 +4241,5 @@
     switch (pVM->bMainExecutionEngine)
     {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_WITH_HWVIRT
         case VM_EXEC_ENGINE_HW_VIRT:
             return HMIsLongModeAllowed(pVM);
@@ -4248,4 +4248,7 @@
         case VM_EXEC_ENGINE_NATIVE_API:
             return NEMHCIsLongModeAllowed(pVM);
+
+        case VM_EXEC_ENGINE_IEM:
+            return true;
 
         case VM_EXEC_ENGINE_NOT_SET:
Index: trunk/src/VBox/VMM/VMMR3/VMEmt.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/VMEmt.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/VMEmt.cpp	(revision 107227)
@@ -568,7 +568,7 @@
     }
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    uint64_t cNsVTimerActivate = TMCpuGetVTimerActivationNano(pVCpu);
-    const bool fVTimerActive = cNsVTimerActivate != UINT64_MAX;
+#ifdef VBOX_VMM_TARGET_ARMV8
+    uint64_t   cNsVTimerActivate = TMCpuGetVTimerActivationNano(pVCpu);
+    const bool fVTimerActive     = cNsVTimerActivate != UINT64_MAX;
 #endif
 
@@ -590,10 +590,10 @@
         if (    VM_FF_IS_ANY_SET(pVM, VM_FF_EXTERNAL_HALTED_MASK)
             ||  VMCPU_FF_IS_ANY_SET(pVCpu, fMask)
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
             ||  cNsElapsedTimers >= cNsVTimerActivate
 #endif
             )
         {
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
             cNsVTimerActivate = 0;
 #endif
@@ -601,5 +601,5 @@
         }
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
         cNsVTimerActivate -= cNsElapsedTimers;
 #endif
@@ -614,5 +614,5 @@
             break;
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
         u64NanoTS = RT_MIN(cNsVTimerActivate, u64NanoTS);
 #endif
@@ -679,5 +679,5 @@
                 fBlockOnce = false;
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
             cNsVTimerActivate -= RT_MIN(cNsVTimerActivate, Elapsed);
             /* Did the vTimer expire? */
@@ -689,5 +689,5 @@
     //if (fSpinning) RTLogRelPrintf("spun for %RU64 ns %u loops; lag=%RU64 pct=%d\n", RTTimeNanoTS() - u64Now, cLoops, TMVirtualSyncGetLag(pVM), u32CatchUpPct);
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
     if (fVTimerActive)
     {
@@ -1157,10 +1157,10 @@
      * Check Relevant FFs.
      */
-#if defined(VBOX_VMM_TARGET_ARMV8)
-    const uint64_t fMaskInterrupts = ((fFlags & VMWAITHALTED_F_IGNORE_IRQS) ? VMCPU_FF_INTERRUPT_IRQ : 0)
+#ifdef VBOX_VMM_TARGET_ARMV8
+    const uint64_t fMaskIrqs = ((fFlags & VMWAITHALTED_F_IGNORE_IRQS) ? VMCPU_FF_INTERRUPT_IRQ : 0)
                                    | ((fFlags & VMWAITHALTED_F_IGNORE_FIQS) ? VMCPU_FF_INTERRUPT_FIQ : 0);
-    const uint64_t fMask = VMCPU_FF_EXTERNAL_HALTED_MASK & ~fMaskInterrupts;
+    const uint64_t fMask     = VMCPU_FF_EXTERNAL_HALTED_MASK & ~fMaskIrqs;
 #else
-    const uint64_t fMask = !(fFlags & VMWAITHALTED_F_IGNORE_IRQS)
+    const uint64_t fMask     = !(fFlags & VMWAITHALTED_F_IGNORE_IRQS)
         ? VMCPU_FF_EXTERNAL_HALTED_MASK
         : VMCPU_FF_EXTERNAL_HALTED_MASK & ~(VMCPU_FF_UPDATE_APIC | VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC);
Index: trunk/src/VBox/VMM/VMMR3/VMM.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/VMM.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/VMM.cpp	(revision 107227)
@@ -130,7 +130,7 @@
 #include <VBox/sup.h>
 #include <VBox/vmm/dbgf.h>
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
 # include <VBox/vmm/gic.h>
-#else
+#elif defined(VBOX_VMM_TARGET_X86)
 # include <VBox/vmm/pdmapic.h>
 #endif
@@ -146,5 +146,5 @@
 #include <iprt/assert.h>
 #include <iprt/alloc.h>
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
 # include <iprt/armv8.h>
 #endif
@@ -580,5 +580,5 @@
         case VMINITCOMPLETED_HM:
         {
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
             /*
              * Disable the periodic preemption timers if we can use the
@@ -1214,5 +1214,7 @@
 
 #ifdef VBOX_WITH_HWVIRT
-
+# ifndef VBOX_VMM_TARGET_X86
+#  error "config error"
+# endif
 /**
  * Executes guest code (Intel VT-x and AMD-V).
@@ -1223,10 +1225,4 @@
 VMMR3_INT_DECL(int) VMMR3HmRunGC(PVM pVM, PVMCPU pVCpu)
 {
-# if defined(VBOX_VMM_TARGET_ARMV8)
-    /* We should actually never get here as the only execution engine is NEM. */
-    RT_NOREF(pVM, pVCpu);
-    AssertReleaseFailed();
-    return VERR_NOT_SUPPORTED;
-# else
     Log2(("VMMR3HmRunGC: (cs:rip=%04x:%RX64)\n", CPUMGetGuestCS(pVCpu), CPUMGetGuestRIP(pVCpu)));
 
@@ -1234,16 +1230,16 @@
     do
     {
-#  ifdef NO_SUPCALLR0VMM
+# ifdef NO_SUPCALLR0VMM
         rc = VERR_GENERAL_FAILURE;
-#  else
+# else
         rc = SUPR3CallVMMR0Fast(VMCC_GET_VMR0_FOR_CALL(pVM), VMMR0_DO_HM_RUN, pVCpu->idCpu);
         if (RT_LIKELY(rc == VINF_SUCCESS))
             rc = pVCpu->vmm.s.iLastGZRc;
-#  endif
+# endif
     } while (rc == VINF_EM_RAW_INTERRUPT_HYPER);
 
-#  if 0 /** @todo triggers too often */
+# if 0 /** @todo triggers too often */
     Assert(!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_TO_R3));
-#  endif
+# endif
 
     /*
@@ -1260,10 +1256,9 @@
     }
     return vmmR3HandleRing0Assert(pVM, pVCpu);
-# endif
 }
 #endif /* VBOX_WITH_HWVIRT */
 
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
 
 /**
@@ -1318,5 +1313,5 @@
 }
 
-#else /* !VBOX_VMM_TARGET_ARMV8 */
+#elif defined(VBOX_VMM_TARGET_X86)
 
 /**
@@ -1404,7 +1399,5 @@
     PGMR3ResetCpu(pVM, pVCpu);
     PDMR3ResetCpu(pVCpu);   /* Only clears pending interrupts force flags */
-# if !defined(VBOX_VMM_TARGET_ARMV8)
     PDMR3ApicInitIpi(pVCpu);
-# endif
     TRPMR3ResetCpu(pVCpu);
     CPUMR3ResetCpu(pVM, pVCpu);
@@ -1449,5 +1442,5 @@
 }
 
-#endif /* !VBOX_VMM_TARGET_ARMV8 */
+#endif /* VBOX_VMM_TARGET_X86 */
 
 /**
@@ -2582,10 +2575,12 @@
         c = 0;
         f = fLocalForcedActions;
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
         PRINT_FLAG(VMCPU_FF_,INTERRUPT_IRQ);
         PRINT_FLAG(VMCPU_FF_,INTERRUPT_FIQ);
-#else
+#elif defined(VBOX_VMM_TARGET_X86)
         PRINT_FLAG(VMCPU_FF_,INTERRUPT_APIC);
         PRINT_FLAG(VMCPU_FF_,INTERRUPT_PIC);
+#else
+# error "port me"
 #endif
         PRINT_FLAG(VMCPU_FF_,TIMER);
Index: trunk/src/VBox/VMM/VMMR3/VMMGuruMeditation.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/VMMGuruMeditation.cpp	(revision 107226)
+++ trunk/src/VBox/VMM/VMMR3/VMMGuruMeditation.cpp	(revision 107227)
@@ -374,7 +374,4 @@
         case VERR_VMM_LONG_JMP_ERROR:
         {
-#if defined(VBOX_VMM_TARGET_ARMV8)
-            AssertReleaseFailed();
-#else
             /*
              * Active trap? This is only of partial interest when in hardware
@@ -390,7 +387,8 @@
             if (RT_SUCCESS(rc2))
                 pHlp->pfnPrintf(pHlp,
-                                "!! ACTIVE TRAP=%02x ERRCD=%RX32 CR2=%RGv PC=%RGr Type=%d cbInstr=%02x fIcebp=%RTbool (Guest!)\n",
-                                u8TrapNo, uErrorCode, uCR2, CPUMGetGuestRIP(pVCpu), enmType, cbInstr, fIcebp);
-
+                                "!! ACTIVE TRAP=%02x ERRCD=%RX32 CR2=%RGv FlatPC=%RGr Type=%d cbInstr=%02x fIcebp=%RTbool (Guest!)\n",
+                                u8TrapNo, uErrorCode, uCR2, CPUMGetGuestFlatPC(pVCpu), enmType, cbInstr, fIcebp);
+
+#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
             /*
              * Dump the relevant hypervisor registers and stack.
@@ -422,5 +420,5 @@
                 PRTHCUINTPTR const pBP = (PRTHCUINTPTR)&pVCpu->vmm.s.abAssertStack[  pVCpu->vmm.s.AssertJmpBuf.UnwindBp
                                                                                    - pVCpu->vmm.s.AssertJmpBuf.UnwindSp];
-#if HC_ARCH_BITS == 32
+# if HC_ARCH_BITS == 32
                 pHlp->pfnPrintf(pHlp,
                                 "eax=volatile ebx=%08x ecx=volatile edx=volatile esi=%08x edi=%08x\n"
@@ -429,6 +427,6 @@
                                 pBP[-3], pBP[-2], pBP[-1],
                                 pBP[1], pVCpu->vmm.s.AssertJmpBuf.SavedEbp - 8, pBP[0], pBP[-4]);
-#else
-# ifdef RT_OS_WINDOWS
+# else
+#  ifdef RT_OS_WINDOWS
                 pHlp->pfnPrintf(pHlp,
                                 "rax=volatile         rbx=%016RX64 rcx=volatile         rdx=volatile\n"
@@ -443,5 +441,5 @@
                                 pBP[-2], pBP[-1],
                                 pBP[1], pVCpu->vmm.s.AssertJmpBuf.UnwindRetSp, pBP[0], pBP[-8]);
-# else
+#  else
                 pHlp->pfnPrintf(pHlp,
                                 "rax=volatile         rbx=%016RX64 rcx=volatile         rdx=volatile\n"
@@ -455,6 +453,6 @@
                                 pBP[-2], pBP[-1],
                                 pBP[1], pVCpu->vmm.s.AssertJmpBuf.UnwindRetSp, pBP[0], pBP[-6]);
+#  endif
 # endif
-#endif
 
                 /* Callstack. */
@@ -472,14 +470,14 @@
                                     "!! Call Stack:\n"
                                     "!!\n");
-#if HC_ARCH_BITS == 32
+# if HC_ARCH_BITS == 32
                     pHlp->pfnPrintf(pHlp, "EBP      Ret EBP  Ret CS:EIP    Arg0     Arg1     Arg2     Arg3     CS:EIP        Symbol [line]\n");
-#else
+# else
                     pHlp->pfnPrintf(pHlp, "RBP              Ret RBP          Ret RIP          RIP              Symbol [line]\n");
-#endif
+# endif
                     for (PCDBGFSTACKFRAME pFrame = pFirstFrame;
                          pFrame;
                          pFrame = DBGFR3StackWalkNext(pFrame))
                     {
-#if HC_ARCH_BITS == 32
+# if HC_ARCH_BITS == 32
                         pHlp->pfnPrintf(pHlp,
                                         "%RHv %RHv %04RX32:%RHv %RHv %RHv %RHv %RHv",
@@ -493,5 +491,5 @@
                                         pFrame->Args.au32[3]);
                         pHlp->pfnPrintf(pHlp, " %RTsel:%08RHv", pFrame->AddrPC.Sel, pFrame->AddrPC.off);
-#else
+# else
                         pHlp->pfnPrintf(pHlp,
                                         "%RHv %RHv %RHv %RHv",
@@ -500,5 +498,5 @@
                                         (RTHCUINTPTR)pFrame->AddrReturnPC.off,
                                         (RTHCUINTPTR)pFrame->AddrPC.off);
-#endif
+# endif
                         if (pFrame->pSymPC)
                         {
@@ -588,5 +586,5 @@
                                 "!! Skipping ring-0 registers and stack, rcErr=%Rrc\n", rcErr);
             }
-#endif /* !VBOX_VMM_TARGET_ARMV8 */
+#endif /* RT_ARCH_AMD64 || RT_ARCH_X86 */
             break;
         }
Index: trunk/src/VBox/VMM/dwarfdump-to-offsets.sed
===================================================================
--- trunk/src/VBox/VMM/dwarfdump-to-offsets.sed	(revision 107226)
+++ trunk/src/VBox/VMM/dwarfdump-to-offsets.sed	(revision 107227)
@@ -75,11 +75,20 @@
         x
         H
-        x
-        s/\(_OFF_.*\)[\n]\(.*\)$/#define \2\1 \\/
-        p
     }
     /DW_AT_data_member_location/ {
-        s/^[[:space:]]*DW_AT_data_member_location[[:space:]]*/                /
-        p
+        s/^[[:space:]]*DW_AT_data_member_location[[:space:]]*//
+        s/[[:space:]]//g
+        x
+        H
+        x
+        s/\([(]0x[0-9a-zA-F]*[)]\)[\n]\(_OFF_.*\)[\n]\(.*\)$/#define \3\2 \1/p
+    }
+    # cleanup hold space.
+    /^[[:space:]]*$/ {
+        x
+        s/\([(]0x[0-9a-zA-F]*[)]\)[\n]\(_OFF_.*\)[\n]\(.*\)$/\3/
+        s/\(_OFF_.*\)[\n]\(.*\)$/\2/
+        x
+        d
     }
 }
Index: trunk/src/VBox/VMM/include/EMHandleRCTmpl.h
===================================================================
--- trunk/src/VBox/VMM/include/EMHandleRCTmpl.h	(revision 107226)
+++ trunk/src/VBox/VMM/include/EMHandleRCTmpl.h	(revision 107227)
@@ -112,5 +112,5 @@
             break;
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
         /*
          * Execute pending I/O Port access.
@@ -168,5 +168,5 @@
             break;
 
-#if !defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_X86
         case VINF_EM_EMULATE_SPLIT_LOCK:
             rc = VBOXSTRICTRC_TODO(emR3ExecuteSplitLockInstruction(pVM, pVCpu));
Index: trunk/src/VBox/VMM/include/NEMInternal.h
===================================================================
--- trunk/src/VBox/VMM/include/NEMInternal.h	(revision 107226)
+++ trunk/src/VBox/VMM/include/NEMInternal.h	(revision 107227)
@@ -39,8 +39,8 @@
 #include <VBox/vmm/vmapi.h>
 #ifdef RT_OS_WINDOWS
-#include <iprt/nt/hyperv.h>
-#include <iprt/critsect.h>
+# include <iprt/nt/hyperv.h>
+# include <iprt/critsect.h>
 #elif defined(RT_OS_DARWIN)
-# if defined(VBOX_VMM_TARGET_ARMV8)
+# ifdef VBOX_VMM_TARGET_ARMV8
 #  include <Hypervisor/Hypervisor.h>
 # else
@@ -112,5 +112,5 @@
 
 #ifdef RT_OS_DARWIN
-# if !defined(VBOX_VMM_TARGET_ARMV8)
+# ifndef VBOX_VMM_TARGET_ARMV8
 /** vCPU ID declaration to avoid dragging in HV headers here. */
 typedef unsigned hv_vcpuid_t;
@@ -128,12 +128,11 @@
 /** @} */
 
-# if defined(VBOX_VMM_TARGET_ARMV8)
 /** The CPUMCTX_EXTRN_XXX mask for IEM. */
-#  define NEM_DARWIN_CPUMCTX_EXTRN_MASK_FOR_IEM      (  IEM_CPUMCTX_EXTRN_MUST_MASK )
+# ifdef VBOX_VMM_TARGET_ARMV8
+#  define NEM_DARWIN_CPUMCTX_EXTRN_MASK_FOR_IEM     (  IEM_CPUMCTX_EXTRN_MUST_MASK )
 # else
-/** The CPUMCTX_EXTRN_XXX mask for IEM. */
-#  define NEM_DARWIN_CPUMCTX_EXTRN_MASK_FOR_IEM      (  IEM_CPUMCTX_EXTRN_MUST_MASK | CPUMCTX_EXTRN_INHIBIT_INT \
-                                                      | CPUMCTX_EXTRN_INHIBIT_NMI )
-#endif
+#  define NEM_DARWIN_CPUMCTX_EXTRN_MASK_FOR_IEM     (  IEM_CPUMCTX_EXTRN_MUST_MASK \
+                                                     | CPUMCTX_EXTRN_INHIBIT_INT | CPUMCTX_EXTRN_INHIBIT_NMI )
+# endif
 
 /** The CPUMCTX_EXTRN_XXX mask for IEM when raising exceptions. */
@@ -141,5 +140,5 @@
 
 
-# if defined(VBOX_VMM_TARGET_ARMV8)
+# ifdef VBOX_VMM_TARGET_ARMV8
 /**
  * MMIO2 tracking region.
@@ -221,5 +220,5 @@
     bool                        fUseDebugLoop;
 
-#if defined(VBOX_VMM_TARGET_ARMV8)
+#ifdef VBOX_VMM_TARGET_ARMV8
     /** The PPI interrupt number of the vTimer. */
     uint32_t                    u32GicPpiVTimer;
@@ -252,10 +251,10 @@
     /** Set if we've created the EMTs. */
     bool                        fCreatedEmts : 1;
-# if defined(VBOX_VMM_TARGET_ARMV8)
+# ifdef VBOX_VMM_TARGET_ARMV8
     bool                        fHypercallExit : 1;
     bool                        fGpaAccessFaultExit : 1;
     /** Cache line flush size as a power of two. */
     uint8_t                     cPhysicalAddressWidth;
-# else
+# elif defined(VBOX_VMM_TARGET_X86)
     /** WHvRunVpExitReasonX64Cpuid is supported. */
     bool                        fExtendedMsrExit : 1;
@@ -316,5 +315,5 @@
     } R0Stats;
 
-# if defined(VBOX_VMM_TARGET_ARMV8)
+# ifdef VBOX_VMM_TARGET_ARMV8
     /** Re-distributor memory region for all vCPUs. */
     RTGCPHYS                    GCPhysMmioBaseReDist;
@@ -332,5 +331,5 @@
     /** Set if EL2 is enabled. */
     bool                        fEl2Enabled  : 1;
-# if defined(VBOX_VMM_TARGET_ARMV8)
+# ifdef VBOX_VMM_TARGET_ARMV8
     /** @name vTimer related state.
      * @{ */
@@ -344,5 +343,5 @@
     hv_vcpu_config_t            hVCpuCfg;
     /** @} */
-# else
+# elif defined(VBOX_VMM_TARGET_X86)
     /** Set if hv_vm_space_create() was called successfully. */
     bool                        fCreatedAsid : 1;
@@ -381,5 +380,5 @@
     /** The last valid host LBR info stack range. */
     uint32_t                    idLbrInfoMsrLast;
-# endif
+# endif /* VBOX_VMM_TARGET_X86 */
 
     STAMCOUNTER                 StatMapPage;
@@ -387,5 +386,5 @@
     STAMCOUNTER                 StatMapPageFailed;
     STAMCOUNTER                 StatUnmapPageFailed;
-#endif /* RT_OS_WINDOWS */
+#endif /* RT_OS_DARWIN */
 } NEM;
 /** Pointer to NEM VM instance data. */
@@ -432,5 +431,5 @@
     /** Pointer to the KVM_RUN data exchange region. */
     R3PTRTYPE(struct kvm_run *) pRun;
-# if defined(VBOX_VMM_TARGET_ARMV8)
+# ifdef VBOX_VMM_TARGET_ARMV8
     /** The IRQ device levels from device_irq_level. */
     uint64_t                    fIrqDeviceLvls;
@@ -439,8 +438,8 @@
     /** Status of the FIQ line when last seen. */
     bool                        fFiqLastSeen;
-# else
+# elif defined(VBOX_VMM_TARGET_X86)
     /** The MSR_IA32_APICBASE value known to KVM. */
     uint64_t                    uKvmApicBase;
-#endif
+# endif
 
     /** @name Statistics
@@ -491,5 +490,5 @@
 
 #elif defined(RT_OS_WINDOWS)
-# ifndef VBOX_VMM_TARGET_ARMV8
+# ifdef VBOX_VMM_TARGET_X86
     /** The current state of the interrupt windows (NEM_WIN_INTW_F_XXX). */
     uint8_t                     fCurrentInterruptWindows;
@@ -543,5 +542,5 @@
 
 #elif defined(RT_OS_DARWIN)
-# if defined(VBOX_VMM_TARGET_ARMV8)
+# ifdef VBOX_VMM_TARGET_ARMV8
     /** The vCPU handle associated with the EMT executing this vCPU. */
     hv_vcpu_t                   hVCpu;
@@ -557,5 +556,6 @@
      * (for first guest exec call on the EMT after loading the saved state). */
     bool                        fIdRegsSynced;
-# else
+
+# elif defined(VBOX_VMM_TARGET_X86)
     /** The vCPU handle associated with the EMT executing this vCPU. */
     hv_vcpuid_t                 hVCpuId;
@@ -628,5 +628,5 @@
     /** Pointer to the VMX statistics. */
     PVMXSTATISTICS              pVmxStats;
-# endif
+# endif /* VBOX_VMM_TARGET_X86 */
 
     /** @name Statistics
@@ -641,8 +641,8 @@
     STAMCOUNTER                 StatImportOnReturnSkipped;
     STAMCOUNTER                 StatQueryCpuTick;
-#ifdef VBOX_WITH_STATISTICS
+# ifdef VBOX_WITH_STATISTICS
     STAMPROFILEADV              StatProfGstStateImport;
     STAMPROFILEADV              StatProfGstStateExport;
-#endif
+# endif
     /** @} */
 
Index: trunk/src/VBox/VMM/testcase/Makefile.kmk
===================================================================
--- trunk/src/VBox/VMM/testcase/Makefile.kmk	(revision 107226)
+++ trunk/src/VBox/VMM/testcase/Makefile.kmk	(revision 107227)
@@ -156,5 +156,5 @@
 ifdef VBOX_WITH_RAW_MODE
  tstVMStructRC_TEMPLATE = VBoxRcExe
- tstVMStructRC_DEFS     = VBOX_IN_VMM IN_VMM_RC IN_DIS IN_RT_RC VBOX_WITH_RAW_MODE $(VMM_COMMON_DEFS)
+ tstVMStructRC_DEFS     = VBOX_VMM_TARGET_AGNOSTIC VBOX_IN_VMM IN_VMM_RC IN_DIS IN_RT_RC VBOX_WITH_RAW_MODE $(VMM_COMMON_DEFS)
  ifdef VBOX_WITH_R0_LOGGING
   tstVMStructRC_DEFS   += VBOX_WITH_R0_LOGGING
@@ -170,5 +170,5 @@
  tstVMStructSize_CXXFLAGS += $(VBOX_GCC_Wno-invalid-offsetof)
 endif
-tstVMStructSize_DEFS    = VBOX_IN_VMM IN_VMM_R3 IN_DIS $(VMM_COMMON_DEFS)
+tstVMStructSize_DEFS    = VBOX_VMM_TARGET_AGNOSTIC VBOX_IN_VMM IN_VMM_R3 IN_DIS $(VMM_COMMON_DEFS)
 ifdef VBOX_WITH_RAW_MODE
  tstVMStructSize_DEFS  += VBOX_WITH_RAW_MODE
@@ -192,5 +192,5 @@
  tstAsmStructSize_CXXFLAGS += $(VBOX_GCC_Wno-invalid-offsetof)
 endif
-tstAsmStructs_DEFS      = VBOX_IN_VMM IN_VMM_R3 IN_DIS $(VMM_COMMON_DEFS)
+tstAsmStructs_DEFS      = VBOX_VMM_TARGET_AGNOSTIC VBOX_IN_VMM IN_VMM_R3 IN_DIS $(VMM_COMMON_DEFS)
 ifdef VBOX_WITH_RAW_MODE
  tstAsmStructs_DEFS    += VBOX_WITH_RAW_MODE
@@ -207,5 +207,5 @@
 ifdef VBOX_WITH_RAW_MODE
  tstAsmStructsRC_TEMPLATE = VBoxRcExe
- tstAsmStructsRC_DEFS   = VBOX_IN_VMM IN_VMM_RC IN_DIS IN_RT_RC VBOX_WITH_RAW_MODE $(VMM_COMMON_DEFS)
+ tstAsmStructsRC_DEFS   = VBOX_VMM_TARGET_AGNOSTIC VBOX_IN_VMM IN_VMM_RC IN_DIS IN_RT_RC VBOX_WITH_RAW_MODE $(VMM_COMMON_DEFS)
  ifdef VBOX_WITH_R0_LOGGING
   tstAsmStructsRC_DEFS += VBOX_WITH_R0_LOGGING
@@ -655,5 +655,5 @@
 
 tstIEMAImpl_TEMPLATE  = VBoxR3TstExe
-tstIEMAImpl_DEFS      = $(VMM_COMMON_DEFS) IEM_WITHOUT_ASSEMBLY IEM_WITHOUT_INSTRUCTION_STATS
+tstIEMAImpl_DEFS      = VBOX_VMM_TARGET_X86 $(VMM_COMMON_DEFS) IEM_WITHOUT_ASSEMBLY IEM_WITHOUT_INSTRUCTION_STATS
 tstIEMAImpl_SDKS      = VBoxSoftFloatR3Shared
 tstIEMAImpl_INCS      = ../include .
@@ -677,5 +677,5 @@
 tstIEMAImplAsm_TEMPLATE      := VBoxR3TstExe
 tstIEMAImplAsm_SDKS          := VBoxSoftFloatR3Shared
-tstIEMAImplAsm_DEFS           = $(VMM_COMMON_DEFS) IEM_WITH_ASSEMBLY IEM_WITHOUT_INSTRUCTION_STATS TSTIEMAIMPL_WITH_GENERATOR
+tstIEMAImplAsm_DEFS           = VBOX_VMM_TARGET_X86 $(VMM_COMMON_DEFS) IEM_WITH_ASSEMBLY IEM_WITHOUT_INSTRUCTION_STATS TSTIEMAIMPL_WITH_GENERATOR
 tstIEMAImplAsm_ASFLAGS.amd64 := -Werror
 tstIEMAImplAsm_ASFLAGS.x86   := -Werror
@@ -701,5 +701,5 @@
 tstIEMCheckMc_TEMPLATE  = VBoxR3TstExe
 tstIEMCheckMc_SOURCES   = tstIEMCheckMc.cpp
-tstIEMCheckMc_DEFS      = $(VMM_COMMON_DEFS) IEM_WITHOUT_INSTRUCTION_STATS
+tstIEMCheckMc_DEFS      = VBOX_VMM_TARGET_X86 $(VMM_COMMON_DEFS) IEM_WITHOUT_INSTRUCTION_STATS
 tstIEMCheckMc_LIBS      = $(LIB_RUNTIME)
 ifeq ($(KBUILD_TARGET),win)
@@ -713,5 +713,5 @@
 #
 tstIEMN8veProfiling_TEMPLATE := VBoxR3Exe
-tstIEMN8veProfiling_DEFS      = $(VMM_COMMON_DEFS)
+tstIEMN8veProfiling_DEFS      = VBOX_VMM_TARGET_AGNOSTIC $(VMM_COMMON_DEFS)
 tstIEMN8veProfiling_SOURCES  := tstIEMN8veProfiling.cpp
 tstIEMN8veProfiling_LIBS      = $(LIB_VMM) $(LIB_RUNTIME)
@@ -722,5 +722,5 @@
 tstSSM_TEMPLATE         = VBoxR3TstExe
 tstSSM_INCS             = $(VBOX_PATH_VMM_SRC)/include
-tstSSM_DEFS             = $(VMM_COMMON_DEFS)
+tstSSM_DEFS             = VBOX_VMM_TARGET_AGNOSTIC $(VMM_COMMON_DEFS)
 tstSSM_SOURCES          = tstSSM.cpp
 tstSSM_LIBS             = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
@@ -742,5 +742,5 @@
  tstCFGM_TEMPLATE        = VBoxR3SignedTstExe
 endif
-tstCFGM_DEFS             = $(VMM_COMMON_DEFS)
+tstCFGM_DEFS             = VBOX_VMM_TARGET_AGNOSTIC $(VMM_COMMON_DEFS)
 tstCFGM_SOURCES          = tstCFGM.cpp
 tstCFGM_LIBS             = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
@@ -781,5 +781,5 @@
  tstVMREQ_TEMPLATE        = VBoxR3SignedExe
 endif
-tstVMREQ_DEFS             = $(VMM_COMMON_DEFS)
+tstVMREQ_DEFS             = VBOX_VMM_TARGET_AGNOSTIC $(VMM_COMMON_DEFS)
 tstVMREQ_SOURCES          = tstVMREQ.cpp
 tstVMREQ_LIBS             = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
@@ -801,5 +801,5 @@
  tstAnimate_TEMPLATE        = VBoxR3SignedExe
 endif
-tstAnimate_DEFS             = $(VMM_COMMON_DEFS)
+tstAnimate_DEFS             = VBOX_VMM_TARGET_X86 $(VMM_COMMON_DEFS)
 tstAnimate_SOURCES          = tstAnimate.cpp
 tstAnimate_LIBS             = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
@@ -918,5 +918,5 @@
 #
 tstPDMQueue_TEMPLATE := VBoxR3Exe
-tstPDMQueue_DEFS     = $(VMM_COMMON_DEFS)
+tstPDMQueue_DEFS      = VBOX_VMM_TARGET_AGNOSTIC $(VMM_COMMON_DEFS)
 tstPDMQueue_SOURCES  := tstPDMQueue.cpp
 tstPDMQueue_LIBS     := $(LIB_VMM) $(LIB_RUNTIME)
@@ -940,5 +940,5 @@
   tstPDMAsyncCompletion_TEMPLATE       = VBoxR3SignedExe
  endif
- tstPDMAsyncCompletion_DEFS            = $(VMM_COMMON_DEFS)
+ tstPDMAsyncCompletion_DEFS            = VBOX_VMM_TARGET_AGNOSTIC $(VMM_COMMON_DEFS)
  tstPDMAsyncCompletion_INCS            = $(VBOX_PATH_VMM_SRC)/include
  tstPDMAsyncCompletion_SOURCES         = tstPDMAsyncCompletion.cpp
@@ -961,5 +961,5 @@
   tstPDMAsyncCompletionStress_TEMPLATE = VBoxR3SignedExe
  endif
- tstPDMAsyncCompletionStress_DEFS      = $(VMM_COMMON_DEFS)
+ tstPDMAsyncCompletionStress_DEFS      = VBOX_VMM_TARGET_AGNOSTIC $(VMM_COMMON_DEFS)
  tstPDMAsyncCompletionStress_INCS      = $(VBOX_PATH_VMM_SRC)/include
  tstPDMAsyncCompletionStress_SOURCES   = tstPDMAsyncCompletionStress.cpp
@@ -970,5 +970,5 @@
  PROGRAMS += tstSSM-2
  tstSSM-2_TEMPLATE      = VBoxR3TstExe
- tstSSM-2_DEFS          = IN_VMM_STATIC
+ tstSSM-2_DEFS          = VBOX_VMM_TARGET_AGNOSTIC IN_VMM_STATIC
  tstSSM-2_SOURCES       = tstSSM-2.cpp
  tstSSM-2_LIBS          = $(PATH_STAGE_LIB)/SSMStandalone$(VBOX_SUFF_LIB)
@@ -983,5 +983,5 @@
   || defined(VBOX_WITH_DTRACE_RC))
  tstVMStructDTrace_TEMPLATE = VBoxR3AutoTest
- tstVMStructDTrace_DEFS    = VBOX_IN_VMM IN_VMM_R3 IN_DIS $(VMM_COMMON_DEFS) IEM_WITHOUT_INSTRUCTION_STATS
+ tstVMStructDTrace_DEFS    = VBOX_VMM_TARGET_AGNOSTIC VBOX_IN_VMM IN_VMM_R3 IN_DIS $(VMM_COMMON_DEFS) IEM_WITHOUT_INSTRUCTION_STATS
  ifdef VBOX_WITH_RAW_MODE
   tstVMStructDTrace_DEFS  += VBOX_WITH_RAW_MODE
@@ -1025,5 +1025,5 @@
 		$(DEFS.$(KBUILD_TARGET_ARCH)) \
 		$(DEFS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
-		$(VMM_COMMON_DEFS) \
+		VBOX_VMM_TARGET_X86 $(VMM_COMMON_DEFS) \
 		) \
 	-f $(if $(eq $(KBUILD_TARGET),darwin),macho,$(if $(eq $(KBUILD_TARGET),win),coff,elf)) \
Index: trunk/src/VBox/VMM/tools/Makefile.kmk
===================================================================
--- trunk/src/VBox/VMM/tools/Makefile.kmk	(revision 107226)
+++ trunk/src/VBox/VMM/tools/Makefile.kmk	(revision 107227)
@@ -67,5 +67,5 @@
 endif
 VBoxCpuReport_TEMPLATE := VBoxR3Static
-VBoxCpuReport_DEFS      = VBOX_IN_VMM IN_VMM_R3 IN_VBOX_CPU_REPORT $(VMM_COMMON_DEFS)
+VBoxCpuReport_DEFS      = VBOX_VMM_TARGET_X86 VBOX_IN_VMM IN_VMM_R3 IN_VBOX_CPU_REPORT $(VMM_COMMON_DEFS)
 VBoxCpuReport_INCS      = ../include
 VBoxCpuReport_SOURCES   = \
