File 5b56feb2-x86-XPTI-parsing-on-fixed-Intel-HW.patch of Package xen.10697
# Commit be5e2ff6f54e0245331ed360b8786760f82fd673
# Date 2018-07-24 11:25:54 +0100
# Author Andrew Cooper <andrew.cooper3@citrix.com>
# Committer Andrew Cooper <andrew.cooper3@citrix.com>
x86/spec-ctrl: Fix the parsing of xpti= on fixed Intel hardware
The calls to xpti_init_default() in parse_xpti() are buggy. The CPUID data
hasn't been fetched that early, and boot_cpu_has(X86_FEATURE_ARCH_CAPS) will
always evaluate false.
As a result, the default case won't disable XPTI on Intel hardware which
advertises ARCH_CAPABILITIES_RDCL_NO.
Simplify parse_xpti() to solely the setting of opt_xpti according to the
passed string, and have init_speculation_mitigations() call
xpti_init_default() if appropiate. Drop the force parameter, and pass caps
instead, to avoid redundant re-reading of MSR_ARCH_CAPS.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -211,17 +211,10 @@ static void __init print_details(enum in
#define OPT_XPTI_DEFAULT 0xff
uint8_t __read_mostly opt_xpti = OPT_XPTI_DEFAULT;
-static __init void xpti_init_default(bool_t force)
+static __init void xpti_init_default(uint64_t caps)
{
- uint64_t caps = 0;
-
- if ( !force && (opt_xpti != OPT_XPTI_DEFAULT) )
- return;
-
if ( boot_cpu_data.x86_vendor == X86_VENDOR_AMD )
caps = ARCH_CAPABILITIES_RDCL_NO;
- else if ( boot_cpu_has(X86_FEATURE_ARCH_CAPS) )
- rdmsrl(MSR_ARCH_CAPABILITIES, caps);
if ( caps & ARCH_CAPABILITIES_RDCL_NO )
opt_xpti = 0;
@@ -234,8 +227,6 @@ static __init int parse_xpti(char *s)
char *ss;
int val, rc = 0;
- xpti_init_default(0);
-
do {
ss = strchr(s, ',');
if ( ss )
@@ -253,7 +244,7 @@ static __init int parse_xpti(char *s)
default:
if ( !strcmp(s, "default") )
- xpti_init_default(1);
+ opt_xpti = OPT_XPTI_DEFAULT;
else if ( (val = parse_boolean("dom0", s, ss)) >= 0 )
opt_xpti = (opt_xpti & ~OPT_XPTI_DOM0) |
(val ? OPT_XPTI_DOM0 : 0);
@@ -421,7 +412,8 @@ void __init init_speculation_mitigations
/* (Re)init BSP state now that default_xen_* have been calculated. */
init_shadow_spec_ctrl_state();
- xpti_init_default(0);
+ if ( opt_xpti == OPT_XPTI_DEFAULT )
+ xpti_init_default(caps);
print_details(thunk, caps);