File xsa407-0f.patch of Package xen.26348
From: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: x86/spec-ctrl: Drop use_spec_ctrl boolean
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@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
(cherry picked from commit ec083bf552c35e10347449e21809f4780f8155d2)
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -929,7 +929,7 @@ void spec_ctrl_init_domain(struct domain
void __init init_speculation_mitigations(void)
{
enum ind_thunk thunk = THUNK_DEFAULT;
- bool_t use_spec_ctrl = 0, ibrs = 0, hw_smt_enabled;
+ bool_t ibrs = 0, hw_smt_enabled;
bool_t cpu_has_bug_taa;
uint64_t caps = 0;
@@ -1004,19 +1004,21 @@ void __init init_speculation_mitigations
{
if ( opt_msr_sc_pv )
{
- use_spec_ctrl = 1;
+ default_spec_ctrl_flags |= SCF_ist_wrmsr;
__set_bit(X86_FEATURE_SC_MSR_PV, boot_cpu_data.x86_capability);
}
if ( opt_msr_sc_hvm )
{
- use_spec_ctrl = 1;
+ /*
+ * 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;
__set_bit(X86_FEATURE_SC_MSR_HVM, boot_cpu_data.x86_capability);
}
- if ( use_spec_ctrl )
- default_spec_ctrl_flags |= SCF_ist_wrmsr;
-
if ( ibrs )
default_xen_spec_ctrl |= SPEC_CTRL_IBRS;
}