]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
VMX: don't run with CR4.VMXE set when VMX could not be enabled
authorJan Beulich <jbeulich@suse.com>
Tue, 25 Feb 2025 07:44:32 +0000 (08:44 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 25 Feb 2025 07:44:32 +0000 (08:44 +0100)
While generally benign, doing so is still at best misleading.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/hvm/vmx/vmx.c

index eee1d4b47a13722098d26e738d97c0910cda08b6..3728d2cd0d775f07e4f0853b77698210ca6d6ba4 100644 (file)
@@ -2987,14 +2987,18 @@ static bool __init has_if_pschange_mc(void)
 
 const struct hvm_function_table * __init start_vmx(void)
 {
-    set_in_cr4(X86_CR4_VMXE);
+    write_cr4(read_cr4() | X86_CR4_VMXE);
 
     if ( vmx_vmcs_init() )
     {
+        write_cr4(read_cr4() & ~X86_CR4_VMXE);
         printk("VMX: failed to initialise.\n");
         return NULL;
     }
 
+    /* Arrange for APs to have CR4.VMXE set early on. */
+    set_in_cr4(X86_CR4_VMXE);
+
     vmx_function_table.caps.singlestep = cpu_has_monitor_trap_flag;
 
     if ( cpu_has_vmx_dt_exiting )