[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/9] x86/spec-ctrl: Drop use_spec_ctrl boolean
- To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Fri, 28 Jan 2022 13:29:20 +0000
- Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Fri, 28 Jan 2022 13:30:03 +0000
- Ironport-data: A9a23:Y0ZiWanVl3PN+mBmO7h1XTPo5gxVIURdPkR7XQ2eYbSJt1+Wr1Gzt xIZXWzTb/fcNDb1ftwna9/npElTvZOBy4cwQQNspX0xFSMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA180IMsdoUg7wbRh29Q42YTR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 NdRm5qBVjszBbHzx98CCgUFThFHOaITrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBODtMJkSpTdLyjbBAOx9aZvCX7/L9ZlT2zJYasVmQ6yPN 5NHMGMHgBLoXhpGKgpMDK8EwdiovSnDcQREi1KFnP9ii4TU5FMoi+W8WDbPQfSVQe1Fk0Deo XjJl0zbKBwHMN2UyRKe72mhwOTImEvTSI8UUbG16PNuqFmS3XAITg0bU0Ohpvu0gVL4XMhQQ 3H44QJ38/J0rhbyCICgAVvo+xZooyLwRfJSD8M82R6x0JHI3Fmi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vm5rY4Ns2uk0dKj2CHJsQizuRZDzrcHFedU1jP94UBZ Cc7s1Iq36LYnIMdPm2AXEDQqzqu8DLvIiOW29IOzcXrC21yR+44r/zFBaVmj0EVSlU/Lsk+W /Z1yTk+6SYte2hwBO07R6c030Woqqh9jJwPr3OtiEnEESvtu9uXvUlZ1S2hkF0nAho0idvrD CDmWZmAy050QKsQoj8m2qT5+Cn6kdj11bSjWaCh33tuMr4Qy9/JfZgqOtiA13kwntlhcp71q 1T2WKfqt5wNjPv2ArAx/WgbWAyqqKTyUBSytL7S0YvCbc2eftfq5cS81hSF4pFFCXm6Jo/GO 0rF83E4u1KGGnqJkwxk1Mft+BEZE5DaCtug3JyyfC9wnxThjR03kEYzMsQkjMJ8488UYBN46 DBPr5znL9DQ8cKZeYlbd1xCvefGyjIW1bBIWiSKVPoGOUOPG/MsYf+5PEw6PuxcJIFwZMukN DKUU9et2Q1Z0XyYPf+lKFj41TIWiGwTD7twsZR69xwvaD9XqPiNWmZRFUng6Kb0oEi6w3gKo OO0b5tco7exFrVaPR0NlfFKudvwFElIb0ohuo=
- Ironport-sdr: xFsr5l5z5y/D9EoB3ZQVgrJPfyV9kXFMZpXxUAhrWB7N5x7vh8FwwNpBa1LR4L88Nva269NoTD gRadX/pU4CRSM1iTbxfzQP2LE9mcAvdHsKT+pGGC5hRdzuncfdDJ9f9uXnS1BbHHMKA0hcvGEi r7T8RHAw3C6thv/y2wEhbtwKB4lPeaelCcN+pvqfR5XFtnpTJhkAPaX7AnLTdecl1Q5eGTNSjG crgeRLOqsBGzKFnwjv7QxzUh3pi7Idc4EvTQrYc24Jt87DJ/bI+roNhhknP9fhWJO3Lgt68TtK lvkODKRs07CBOEJgOS6aVOrt
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Several bugfixes have reduced the utility of this variable from it's original
purpose, and now all it does is aid in the setup of SCF_ist_wrmsr.
Simplify the logic by drop the variable, and doubling up the setting of
SCF_ist_wrmsr for the PV and HVM blocks, which will make the AMD SPEC_CTRL
support easier to follow. Leave a comment explaining why SCF_ist_wrmsr is
still necessary for the VMExit case.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
---
xen/arch/x86/spec_ctrl.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index c18cc8aa493a..8a550d0a0902 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -927,7 +927,7 @@ static __init void mds_calculations(uint64_t caps)
void __init init_speculation_mitigations(void)
{
enum ind_thunk thunk = THUNK_DEFAULT;
- bool use_spec_ctrl = false, ibrs = false, hw_smt_enabled;
+ bool ibrs = false, hw_smt_enabled;
bool cpu_has_bug_taa;
uint64_t caps = 0;
@@ -1016,19 +1016,21 @@ void __init init_speculation_mitigations(void)
{
if ( opt_msr_sc_pv )
{
- use_spec_ctrl = true;
+ default_spec_ctrl_flags |= SCF_ist_wrmsr;
setup_force_cpu_cap(X86_FEATURE_SC_MSR_PV);
}
if ( opt_msr_sc_hvm )
{
- use_spec_ctrl = true;
+ /*
+ * While the guest MSR_SPEC_CTRL value is loaded/saved atomically,
+ * Xen's value is not restored atomically. An early NMI hitting
+ * the VMExit path needs to restore Xen's value for safety.
+ */
+ default_spec_ctrl_flags |= SCF_ist_wrmsr;
setup_force_cpu_cap(X86_FEATURE_SC_MSR_HVM);
}
- if ( use_spec_ctrl )
- default_spec_ctrl_flags |= SCF_ist_wrmsr;
-
if ( ibrs )
default_xen_spec_ctrl |= SPEC_CTRL_IBRS;
}
--
2.11.0
|