All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>,
	"Kevin Tian" <kevin.tian@intel.com>,
	"Jun Nakajima" <jun.nakajima@intel.com>
Subject: [PATCH v3 01/12] VMX: don't run with CR4.VMXE set when VMX could not be enabled
Date: Mon, 26 Feb 2024 17:42:02 +0100	[thread overview]
Message-ID: <21e6cbec-dc29-452f-b6a2-6926245a8beb@suse.com> (raw)
In-Reply-To: <293e5aef-8843-461c-bc96-709a605b2680@suse.com>

While generally benign, doing so is still at best misleading.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Using set_in_cr4() seems favorable over updating mmu_cr4_features
despite the resulting redundant CR4 update. But I certainly could be
talked into going the alternative route.
---
v2: Actually clear CR4.VMXE for the BSP on the error path.

--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2961,14 +2961,18 @@ static bool __init has_if_pschange_mc(vo
 
 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.singlestep_supported = cpu_has_monitor_trap_flag;
 
     if ( cpu_has_vmx_dt_exiting )



  reply	other threads:[~2024-02-26 16:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 16:40 [PATCH v3 00/12] x86/HVM: misc tidying Jan Beulich
2024-02-26 16:42 ` Jan Beulich [this message]
2024-02-26 16:42 ` [PATCH v3 02/12] x86/HVM: improve CET-IBT pruning of ENDBR Jan Beulich
2024-02-26 16:42 ` [PATCH v3 03/12] VMX: drop vmcs_revision_id Jan Beulich
2024-02-26 16:43 ` [PATCH v3 04/12] VMX: convert vmx_basic_msr Jan Beulich
2024-02-26 16:43 ` [PATCH v3 05/12] VMX: convert vmx_pin_based_exec_control Jan Beulich
2024-02-26 16:43 ` [PATCH v3 06/12] VMX: convert vmx_cpu_based_exec_control Jan Beulich
2024-02-26 16:44 ` [PATCH v3 07/12] VMX: convert vmx_secondary_exec_control Jan Beulich
2024-02-26 16:44 ` [PATCH v3 08/12] VMX: convert vmx_tertiary_exec_control Jan Beulich
2024-02-26 16:45 ` [PATCH v3 09/12] VMX: convert vmx_vmexit_control Jan Beulich
2024-02-26 16:45 ` [PATCH v3 10/12] VMX: convert vmx_vmentry_control Jan Beulich
2024-02-26 16:45 ` [PATCH v3 11/12] VMX: convert vmx_ept_vpid_cap Jan Beulich
2024-02-26 16:46 ` [PATCH v3 12/12] VMX: convert vmx_vmfunc Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21e6cbec-dc29-452f-b6a2-6926245a8beb@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.