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 2/2] VMX/cpu-policy: disable RDTSCP and INVPCID insns as needed
Date: Wed, 26 Apr 2023 14:58:23 +0200 [thread overview]
Message-ID: <fa9e9ece-df60-e249-7cc2-ad3af50d26bb@suse.com> (raw)
In-Reply-To: <ea294e55-f543-640e-7b12-777941ac4500@suse.com>
When either feature is available in hardware, but disabled for a guest,
the respective insn would better cause #UD if attempted to be used.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -785,6 +785,30 @@ static void cf_check vmx_cpuid_policy_ch
vmx_vmcs_enter(v);
vmx_update_exception_bitmap(v);
+ if ( cp->extd.rdtscp )
+ {
+ v->arch.hvm.vmx.secondary_exec_control |= SECONDARY_EXEC_ENABLE_RDTSCP;
+ vmx_update_secondary_exec_control(v);
+ }
+ else if ( v->arch.hvm.vmx.secondary_exec_control &
+ SECONDARY_EXEC_ENABLE_RDTSCP )
+ {
+ v->arch.hvm.vmx.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_RDTSCP;
+ vmx_update_secondary_exec_control(v);
+ }
+
+ if ( cp->feat.invpcid )
+ {
+ v->arch.hvm.vmx.secondary_exec_control |= SECONDARY_EXEC_ENABLE_INVPCID;
+ vmx_update_secondary_exec_control(v);
+ }
+ else if ( v->arch.hvm.vmx.secondary_exec_control &
+ SECONDARY_EXEC_ENABLE_INVPCID )
+ {
+ v->arch.hvm.vmx.secondary_exec_control &= ~SECONDARY_EXEC_ENABLE_INVPCID;
+ vmx_update_secondary_exec_control(v);
+ }
+
/*
* We can safely pass MSR_SPEC_CTRL through to the guest, even if STIBP
* isn't enumerated in hardware, as SPEC_CTRL_STIBP is ignored.
next prev parent reply other threads:[~2023-04-26 12:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 12:56 [PATCH 0/2] VMX/cpu-policy: RDTSCP and INVPCID handling Jan Beulich
2023-04-26 12:57 ` [PATCH 1/2] VMX/cpu-policy: check availability of RDTSCP and INVPCID Jan Beulich
2023-05-26 4:53 ` Tian, Kevin
2023-04-26 12:58 ` Jan Beulich [this message]
2023-05-26 4:54 ` [PATCH 2/2] VMX/cpu-policy: disable RDTSCP and INVPCID insns as needed Tian, Kevin
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=fa9e9ece-df60-e249-7cc2-ad3af50d26bb@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.