From: Konrad Rzeszutek Wilk Date: Thu, 26 Apr 2018 02:04:23 +0000 (-0400) Subject: x86/bugs: Whitelist allowed SPEC_CTRL MSR values X-Git-Tag: v4.1.12-124.31.3~771 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4775a882b26d36c7c9237f5d8fe9f8f931190de3;p=users%2Fjedix%2Flinux-maple.git x86/bugs: Whitelist allowed SPEC_CTRL MSR values Intel and AMD SPEC_CTRL (0x48) MSR semantics may differ in the future (or in fact use different MSRs for the same functionality). As such a run-time mechanism is required to whitelist the appropriate MSR values. [ tglx: Made the variable __ro_after_init ] OraBug: 28041771 CVE: CVE-2018-3639 Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Thomas Gleixner Reviewed-by: Ingo Molnar (cherry picked from commit 1115a859f33276fe8afb31c60cf9d8e657872558) Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Mihai Carabas Conflicts: arch/x86/kernel/cpu/bugs.c [It is called bugs_64.c] Signed-off-by: Brian Maly --- diff --git a/arch/x86/kernel/cpu/bugs_64.c b/arch/x86/kernel/cpu/bugs_64.c index d29dc9d6964a..2299a4c89dae 100644 --- a/arch/x86/kernel/cpu/bugs_64.c +++ b/arch/x86/kernel/cpu/bugs_64.c @@ -104,6 +104,12 @@ static void __init ssb_select_mitigation(void); u64 x86_spec_ctrl_base; EXPORT_SYMBOL_GPL(x86_spec_ctrl_base); +/* + * The vendor and possibly platform specific bits which can be modified in + * x86_spec_ctrl_base. + */ +static u64 x86_spec_ctrl_mask = ~SPEC_CTRL_IBRS; + /* * Our knob on entering the kernel to enable and disable IBRS. * Inherits value from x86_spec_ctrl_base. @@ -201,7 +207,7 @@ void x86_spec_ctrl_set(u64 val) { u64 host; - if (val & ~(SPEC_CTRL_IBRS | SPEC_CTRL_RDS)) + if (val & x86_spec_ctrl_mask) WARN_ONCE(1, "SPEC_CTRL MSR value 0x%16llx is unknown.\n", val); else { /* @@ -683,6 +689,7 @@ static enum ssb_mitigation_cmd __init __ssb_select_mitigation(void) switch (boot_cpu_data.x86_vendor) { case X86_VENDOR_INTEL: x86_spec_ctrl_base |= SPEC_CTRL_RDS; + x86_spec_ctrl_mask &= ~SPEC_CTRL_RDS; x86_spec_ctrl_set(SPEC_CTRL_RDS); break; case X86_VENDOR_AMD: @@ -705,7 +712,7 @@ static void ssb_select_mitigation() void x86_spec_ctrl_setup_ap(void) { if (boot_cpu_has(X86_FEATURE_IBRS)) - x86_spec_ctrl_set(x86_spec_ctrl_base & (SPEC_CTRL_IBRS | SPEC_CTRL_RDS)); + x86_spec_ctrl_set(x86_spec_ctrl_base & ~x86_spec_ctrl_mask); } #ifdef CONFIG_SYSFS