Index: trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp	(revision 95178)
+++ trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp	(revision 95179)
@@ -3262,4 +3262,27 @@
     PCPUMMSRRANGE  pMsrRange;
 
+#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
+# define CHECK_X86_HOST_FEATURE_RET(a_fFeature, a_szFeature) \
+    if (!pVM->cpum.s.HostFeatures. a_fFeature) \
+    { \
+        LogRel(("CPUM: WARNING! Can't turn on " a_szFeature " when the host doesn't support it!\n")); \
+        return; \
+    } else do { } while (0)
+#else
+# define CHECK_X86_HOST_FEATURE_RET(a_fFeature, a_szFeature) do { } while (0)
+#endif
+
+#define GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(a_fFeature, a_szFeature) \
+    do \
+    { \
+        pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); \
+        if (!pLeaf) \
+        { \
+            LogRel(("CPUM: WARNING! Can't turn on " a_szFeature " when no 0x80000001 CPUID leaf!\n")); \
+            return; \
+        } \
+        CHECK_X86_HOST_FEATURE_RET(a_fFeature,a_szFeature); \
+    } while (0)
+
     switch (enmFeature)
     {
@@ -3322,10 +3345,5 @@
          */
         case CPUMCPUIDFEATURE_SEP:
-            if (!pVM->cpum.s.HostFeatures.fSysEnter)
-            {
-                AssertMsgFailed(("ERROR: Can't turn on SEP when the host doesn't support it!!\n"));
-                return;
-            }
-
+            CHECK_X86_HOST_FEATURE_RET(fSysEnter, "SEP");
             pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001));
             if (pLeaf)
@@ -3340,11 +3358,5 @@
          */
         case CPUMCPUIDFEATURE_SYSCALL:
-            pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
-            if (   !pLeaf
-                || !pVM->cpum.s.HostFeatures.fSysCall)
-            {
-                LogRel(("CPUM: WARNING! Can't turn on SYSCALL/SYSRET when the host doesn't support it!\n"));
-                return;
-            }
+            GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(fSysCall, "SYSCALL/SYSRET");
 
             /* Valid for both Intel and AMD CPUs, although only in 64 bits mode for Intel. */
@@ -3359,10 +3371,4 @@
          */
         case CPUMCPUIDFEATURE_PAE:
-            if (!pVM->cpum.s.HostFeatures.fPae)
-            {
-                LogRel(("CPUM: WARNING! Can't turn on PAE when the host doesn't support it!\n"));
-                return;
-            }
-
             pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001));
             if (pLeaf)
@@ -3384,11 +3390,5 @@
          */
         case CPUMCPUIDFEATURE_LONG_MODE:
-            pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
-            if (   !pLeaf
-                || !pVM->cpum.s.HostFeatures.fLongMode)
-            {
-                LogRel(("CPUM: WARNING! Can't turn on LONG MODE when the host doesn't support it!\n"));
-                return;
-            }
+            GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(fLongMode, "LONG MODE");
 
             /* Valid for both Intel and AMD. */
@@ -3410,11 +3410,5 @@
          */
         case CPUMCPUIDFEATURE_NX:
-            pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
-            if (   !pLeaf
-                || !pVM->cpum.s.HostFeatures.fNoExecute)
-            {
-                LogRel(("CPUM: WARNING! Can't turn on NX/XD when the host doesn't support it!\n"));
-                return;
-            }
+            GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(fNoExecute, "NX/XD");
 
             /* Valid for both Intel and AMD. */
@@ -3430,11 +3424,5 @@
          */
         case CPUMCPUIDFEATURE_LAHF:
-            pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
-            if (   !pLeaf
-                || !pVM->cpum.s.HostFeatures.fLahfSahf)
-            {
-                LogRel(("CPUM: WARNING! Can't turn on LAHF/SAHF when the host doesn't support it!\n"));
-                return;
-            }
+            GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(fLahfSahf, "LAHF/SAHF");
 
             /* Valid for both Intel and AMD. */
@@ -3449,13 +3437,8 @@
          */
         case CPUMCPUIDFEATURE_RDTSCP:
+            if (pVM->cpum.s.u8PortableCpuIdLevel > 0)
+                return;
+            GET_8000_0001_CHECK_X86_HOST_FEATURE_RET(fRdTscP, "RDTSCP");
             pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001));
-            if (   !pLeaf
-                || !pVM->cpum.s.HostFeatures.fRdTscP
-                || pVM->cpum.s.u8PortableCpuIdLevel > 0)
-            {
-                if (!pVM->cpum.s.u8PortableCpuIdLevel)
-                    LogRel(("CPUM: WARNING! Can't turn on RDTSCP when the host doesn't support it!\n"));
-                return;
-            }
 
             /* Valid for both Intel and AMD. */
@@ -3580,4 +3563,7 @@
         pVCpu->cpum.s.fChanged |= CPUM_CHANGED_CPUID;
     }
+
+#undef GET_8000_0001_CHECK_X86_HOST_FEATURE_RET
+#undef CHECK_X86_HOST_FEATURE_RET
 }
 
