Index: /trunk/include/VBox/vmm/nem.h
===================================================================
--- /trunk/include/VBox/vmm/nem.h	(revision 72342)
+++ /trunk/include/VBox/vmm/nem.h	(revision 72343)
@@ -99,4 +99,5 @@
  * @{
  */
+VMM_INT_DECL(bool) NEMHCIsLongModeAllowed(PVM pVM);
 VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb);
 VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb,
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 72342)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 72343)
@@ -1115,5 +1115,5 @@
         InsertConfigInteger(pRoot, "HMEnabled", fHMEnabled);
 
-        /* /HM/xzy */
+        /* /HM/xyz */
         PCFGMNODE pHM;
         InsertConfigNode(pRoot, "HM", &pHM);
@@ -1185,4 +1185,16 @@
         if (i_isResetTurnedIntoPowerOff())
             InsertConfigInteger(pRoot, "PowerOffInsteadOfReset", 1);
+
+        /* Use NEM rather than HM. */
+        BOOL fUseNativeApi = false;
+        hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_UseNativeApi, &fUseNativeApi); H();
+        InsertConfigInteger(pHM, "UseNEMInstead", fUseNativeApi);
+
+        /*
+         * NEM
+         */
+        PCFGMNODE pNEM;
+        InsertConfigNode(pRoot, "NEM", &pNEM);
+        InsertConfigInteger(pNEM, "Allow64BitGuests", fIsGuest64Bit);
 
         /*
Index: /trunk/src/VBox/VMM/VMMAll/HMAll.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/HMAll.cpp	(revision 72342)
+++ /trunk/src/VBox/VMM/VMMAll/HMAll.cpp	(revision 72343)
@@ -358,10 +358,12 @@
 
 /**
- * Checks if this VM is long-mode capable.
+ * Checks if this VM is using HM and is long-mode capable.
+ *
+ * Use VMR3IsLongModeAllowed() instead of this, when possible.
  *
  * @returns true if long mode is allowed, false otherwise.
  * @param   pVM         The cross context VM structure.
- */
-/** @todo NEM: Check users of HMIsLongModeAllowed */
+ * @sa      VMR3IsLongModeAllowed, NEMHCIsLongModeAllowed
+ */
 VMM_INT_DECL(bool) HMIsLongModeAllowed(PVM pVM)
 {
Index: /trunk/src/VBox/VMM/VMMAll/NEMAll.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/NEMAll.cpp	(revision 72342)
+++ /trunk/src/VBox/VMM/VMMAll/NEMAll.cpp	(revision 72343)
@@ -25,4 +25,18 @@
 #include <VBox/vmm/vm.h>
 
+
+/**
+ * Checks if this VM is in NEM mode and is long-mode capable.
+ *
+ * Use VMR3IsLongModeAllowed() instead of this, when possible.
+ *
+ * @returns true if long mode is allowed, false otherwise.
+ * @param   pVM         The cross context VM structure.
+ * @sa      VMR3IsLongModeAllowed, HMIsLongModeAllowed
+ */
+VMM_INT_DECL(bool) NEMHCIsLongModeAllowed(PVM pVM)
+{
+    return pVM->nem.s.fAllow64BitGuests && VM_IS_NEM_ENABLED(pVM);
+}
 
 
Index: /trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp	(revision 72342)
+++ /trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp	(revision 72343)
@@ -1784,4 +1784,6 @@
         if (paValues[iReg].Reg64 != pCtx->msrEFER)
         {
+            if ((paValues[iReg].Reg64 ^ pCtx->msrEFER) & MSR_K6_EFER_NXE)
+                PGMNotifyNxeChanged(pVCpu, RT_BOOL(paValues[iReg].Reg64 & MSR_K6_EFER_NXE));
             pCtx->msrEFER = paValues[iReg].Reg64;
             fMaybeChangedMode = true;
Index: /trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp	(revision 72342)
+++ /trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp	(revision 72343)
@@ -24,4 +24,5 @@
 #include <VBox/vmm/dbgf.h>
 #include <VBox/vmm/hm.h>
+#include <VBox/vmm/nem.h>
 #include <VBox/vmm/ssm.h>
 #include "CPUMInternal.h"
@@ -4021,5 +4022,6 @@
                             && pVM->cpum.s.HostFeatures.fOpSysXSaveRstor
 #if HC_ARCH_BITS == 32 /* Seems this may be broken when doing 64-bit on 32-bit, just disable it for now. */
-                            && !HMIsLongModeAllowed(pVM)
+                            && (   !HMIsLongModeAllowed(pVM)
+                                || NEMIsLongModeAllowed(pVM))
 #endif
                             ;
Index: /trunk/src/VBox/VMM/VMMR3/NEMR3.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/NEMR3.cpp	(revision 72342)
+++ /trunk/src/VBox/VMM/VMMR3/NEMR3.cpp	(revision 72343)
@@ -76,5 +76,6 @@
     int rc = CFGMR3ValidateConfig(pCfgNem,
                                   "/NEM/",
-                                  "Enabled",
+                                  "Enabled"
+                                  "|Allow64BitGuests",
                                   "" /* pszValidNodes */, "NEM" /* pszWho */, 0 /* uInstance */);
     if (RT_FAILURE(rc))
@@ -85,4 +86,17 @@
     rc = CFGMR3QueryBoolDef(pCfgNem, "Enabled", &pVM->nem.s.fEnabled, true);
     AssertLogRelRCReturn(rc, rc);
+
+
+#ifdef VBOX_WITH_64_BITS_GUESTS
+    /** @cfgm{/HM/Allow64BitGuests, bool, 32-bit:false, 64-bit:true}
+     * Enables AMD64 CPU features.
+     * On 32-bit hosts this isn't default and require host CPU support. 64-bit hosts
+     * already have the support. */
+    rc = CFGMR3QueryBoolDef(pCfgNem, "Allow64BitGuests", &pVM->nem.s.fAllow64BitGuests, HC_ARCH_BITS == 64);
+    AssertLogRelRCReturn(rc, rc);
+#else
+    pVM->nem.s.fAllow64BitGuests = false;
+#endif
+
 
     return VINF_SUCCESS;
@@ -151,10 +165,35 @@
 {
     int rc = VINF_SUCCESS;
-#ifdef VBOX_WITH_NATIVE_NEM
-    if (pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
+    if (pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
+    {
+        /*
+         * Enable CPU features making general ASSUMPTIONS (there are two similar
+         * blocks of code in HM.cpp), to avoid duplicating this code.  The
+         * native backend can make check capabilities and adjust as needed.
+         */
+        CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);
+        if (CPUMGetGuestCpuVendor(pVM) == CPUMCPUVENDOR_AMD)
+            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);            /* 64 bits only on Intel CPUs */
+        if (pVM->nem.s.fAllow64BitGuests)
+        {
+            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);
+            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
+            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);
+            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
+            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
+        }
+        /* Turn on NXE if PAE has been enabled. */
+        else if (CPUMR3GetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE))
+            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
+
+        /*
+         * Do native after-CPUM init.
+         */
+#ifdef VBOX_WITH_NATIVE_NEM
         rc = nemR3NativeInitAfterCPUM(pVM);
 #else
-    RT_NOREF(pVM);
-#endif
+        RT_NOREF(pVM);
+#endif
+    }
     return rc;
 }
Index: /trunk/src/VBox/VMM/VMMR3/VM.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/VM.cpp	(revision 72342)
+++ /trunk/src/VBox/VMM/VMMR3/VM.cpp	(revision 72343)
@@ -4530,15 +4530,28 @@
 /**
  * Checks if the VM is long-mode (64-bit) capable or not.
- * @returns true if VM can operate in long-mode, false
- *        otherwise.
- *
+ *
+ * @returns true if VM can operate in long-mode, false otherwise.
  * @param   pVM             The cross context VM structure.
  */
 VMMR3_INT_DECL(bool) VMR3IsLongModeAllowed(PVM pVM)
 {
-/** @todo NEM: Fixme log mode allowed stuff. */
-    if (HMIsEnabled(pVM))
-        return HMIsLongModeAllowed(pVM);
-    return false;
+    switch (pVM->bMainExecutionEngine)
+    {
+        case VM_EXEC_ENGINE_HW_VIRT:
+            return HMIsLongModeAllowed(pVM);
+
+        case VM_EXEC_ENGINE_NATIVE_API:
+#ifndef IN_RC
+            return NEMHCIsLongModeAllowed(pVM);
+#else
+            return false;
+#endif
+
+        case VM_EXEC_ENGINE_NOT_SET:
+            AssertFailed();
+            RT_FALL_THRU();
+        default:
+            return false;
+    }
 }
 
Index: /trunk/src/VBox/VMM/include/HMInternal.h
===================================================================
--- /trunk/src/VBox/VMM/include/HMInternal.h	(revision 72342)
+++ /trunk/src/VBox/VMM/include/HMInternal.h	(revision 72343)
@@ -40,5 +40,5 @@
 #endif
 
-#if HC_ARCH_BITS == 64 || defined (VBOX_WITH_64_BITS_GUESTS)
+#if HC_ARCH_BITS == 64 || defined(VBOX_WITH_64_BITS_GUESTS)
 /* Enable 64 bits guest support. */
 # define VBOX_ENABLE_64_BITS_GUESTS
Index: /trunk/src/VBox/VMM/include/NEMInternal.h
===================================================================
--- /trunk/src/VBox/VMM/include/NEMInternal.h	(revision 72342)
+++ /trunk/src/VBox/VMM/include/NEMInternal.h	(revision 72343)
@@ -108,4 +108,6 @@
     /** Set if enabled. */
     bool                        fEnabled;
+    /** Set if long mode guests are allowed. */
+    bool                        fAllow64BitGuests;
 #ifdef RT_OS_WINDOWS
     /** Set if we've created the EMTs. */
