Index: trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp	(revision 8549)
+++ trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp	(revision 8550)
@@ -165,4 +165,60 @@
 
                 HWACCMR0Globals.vmx.msr.feature_ctrl = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
+                HWACCMR0Globals.vmx.hostCR4          = ASMGetCR4();
+
+#if HC_ARCH_BITS == 64
+                RTR0MEMOBJ pScatchMemObj;
+                void      *pvScatchPage;
+                RTHCPHYS   pScatchPagePhys;
+
+                rc = RTR0MemObjAllocCont(&pScatchMemObj, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
+                if (RT_FAILURE(rc))
+                    return rc;
+
+                pvScatchPage    = RTR0MemObjAddress(pScatchMemObj);
+                pScatchPagePhys = RTR0MemObjGetPagePhysAddr(pScatchMemObj, 0);
+                memset(pvScatchPage, 0, PAGE_SIZE);
+
+                /* Set revision dword at the beginning of the structure. */
+                *(uint32_t *)pvScatchPage = MSR_IA32_VMX_BASIC_INFO_VMCS_ID(HWACCMR0Globals.vmx.msr.vmx_basic_info);
+
+                /* Make sure we don't get rescheduled to another cpu during this probe. */
+                RTCCUINTREG fFlags = ASMIntDisableFlags();
+
+                /*
+                 * Check CR4.VMXE
+                 */
+                if (!(HWACCMR0Globals.vmx.hostCR4 & X86_CR4_VMXE))
+                {
+                    /* In theory this bit could be cleared behind our back. Which would cause #UD faults when we
+                     * try to execute the VMX instructions...
+                     */
+                    ASMSetCR4(HWACCMR0Globals.vmx.hostCR4 | X86_CR4_VMXE);
+                }
+
+                /* Enter VMX Root Mode */
+                rc = VMXEnable(pScatchPagePhys);
+                if (VBOX_FAILURE(rc))
+                {
+                    /* KVM leaves the CPU in VMX root mode. Not only is this not allowed, it will crash the host when we enter raw mode, because
+                     * (a) clearing X86_CR4_VMXE in CR4 causes a #GP    (we no longer modify this bit)
+                     * (b) turning off paging causes a #GP              (unavoidable when switching from long to 32 bits mode)
+                     *
+                     * They should fix their code, but until they do we simply refuse to run.
+                     */
+                    HWACCMR0Globals.lLastError = VERR_VMX_IN_VMX_ROOT_MODE;
+                    HWACCMR0Globals.vmx.fSupported = false;
+                }
+                else
+                    VMXDisable();
+
+                /* Restore CR4 again; don't leave the X86_CR4_VMXE flag set if it wasn't so before (some software could incorrectly think it's in VMX mode) */
+                ASMSetCR4(HWACCMR0Globals.vmx.hostCR4);
+                ASMSetFlags(fFlags);
+
+                RTR0MemObjFree(pScatchMemObj, false);
+                if (VBOX_FAILURE(HWACCMR0Globals.lLastError))
+                    return HWACCMR0Globals.lLastError ;
+#endif
 
                 /* We need to check if VT-x has been properly initialized on all CPUs. Some BIOSes do a lousy job. */
@@ -194,58 +250,4 @@
                         HWACCMR0Globals.vmx.msr.vmx_cr4_fixed1  = ASMRdMsr(MSR_IA32_VMX_CR4_FIXED1);
                         HWACCMR0Globals.vmx.msr.vmx_vmcs_enum   = ASMRdMsr(MSR_IA32_VMX_VMCS_ENUM);
-                        HWACCMR0Globals.vmx.hostCR4             = ASMGetCR4();
-
-#if HC_ARCH_BITS == 64
-                        RTR0MEMOBJ pScatchMemObj;
-                        void      *pvScatchPage;
-                        RTHCPHYS   pScatchPagePhys;
-
-                        rc = RTR0MemObjAllocCont(&pScatchMemObj, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
-                        if (RT_FAILURE(rc))
-                            return rc;
-
-                        pvScatchPage    = RTR0MemObjAddress(pScatchMemObj);
-                        pScatchPagePhys = RTR0MemObjGetPagePhysAddr(pScatchMemObj, 0);
-                        memset(pvScatchPage, 0, PAGE_SIZE);
-
-                        /* Set revision dword at the beginning of the structure. */
-                        *(uint32_t *)pvScatchPage = MSR_IA32_VMX_BASIC_INFO_VMCS_ID(HWACCMR0Globals.vmx.msr.vmx_basic_info);
-
-                        /* Make sure we don't get rescheduled to another cpu during this probe. */
-                        RTCCUINTREG fFlags = ASMIntDisableFlags();
-
-                        /*
-                         * Check CR4.VMXE
-                         */
-                        if (!(HWACCMR0Globals.vmx.hostCR4 & X86_CR4_VMXE))
-                        {
-                            /* In theory this bit could be cleared behind our back. Which would cause #UD faults when we
-                             * try to execute the VMX instructions...
-                             */
-                            ASMSetCR4(HWACCMR0Globals.vmx.hostCR4 | X86_CR4_VMXE);
-                        }
-
-                        /* Enter VMX Root Mode */
-                        rc = VMXEnable(pScatchPagePhys);
-                        if (VBOX_FAILURE(rc))
-                        {
-                            /* KVM leaves the CPU in VMX root mode. Not only is this not allowed, it will crash the host when we enter raw mode, because
-                             * (a) clearing X86_CR4_VMXE in CR4 causes a #GP    (we no longer modify this bit)
-                             * (b) turning off paging causes a #GP              (unavoidable when switching from long to 32 bits mode)
-                             *
-                             * They should fix their code, but until they do we simply refuse to run.
-                             */
-                            HWACCMR0Globals.lLastError = VERR_VMX_IN_VMX_ROOT_MODE;
-                            HWACCMR0Globals.vmx.fSupported = false;
-                        }
-                        else
-                            VMXDisable();
-
-                        /* Restore CR4 again; don't leave the X86_CR4_VMXE flag set if it wasn't so before (some software could incorrectly think it's in VMX mode) */
-                        ASMSetCR4(HWACCMR0Globals.vmx.hostCR4);
-                        ASMSetFlags(fFlags);
-
-                        RTR0MemObjFree(pScatchMemObj, false);
-#endif
                     }
                     else
