Skip to content

Commit 07e5877

Browse files
committed
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 ] Signed-off-by: Konrad Rzeszutek Wilk <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> (cherry picked from commit 1115a85) Orabug: 28034177 CVE: CVE-2018-3639 Signed-off-by: Konrad Rzeszutek Wilk <[email protected]> Tested-by: Mihai Carabas <[email protected]> Reviewed-by: Mihai Carabas <[email protected]> Reviewed-by: John Haxby <[email protected]> Conflicts: arch/x86/kernel/cpu/bugs.c [As we have u64 host in the function] --- v2: Ripped out the new extra newline.
1 parent 54fd120 commit 07e5877

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ EXPORT_SYMBOL_GPL(x86_spec_ctrl_base);
100100
u64 x86_spec_ctrl_priv;
101101
EXPORT_SYMBOL_GPL(x86_spec_ctrl_priv);
102102

103+
/*
104+
* The vendor and possibly platform specific bits which can be modified in
105+
* x86_spec_ctrl_base.
106+
*/
107+
static u64 __ro_after_init x86_spec_ctrl_mask = ~SPEC_CTRL_IBRS;
108+
103109
void __init check_bugs(void)
104110
{
105111
identify_boot_cpu();
@@ -191,7 +197,7 @@ void x86_spec_ctrl_set(u64 val)
191197
{
192198
u64 host;
193199

194-
if (val & ~(SPEC_CTRL_IBRS | SPEC_CTRL_RDS))
200+
if (val & x86_spec_ctrl_mask)
195201
WARN_ONCE(1, "SPEC_CTRL MSR value 0x%16llx is unknown.\n", val);
196202
else {
197203
/*
@@ -692,6 +698,7 @@ static enum ssb_mitigation_cmd __init __ssb_select_mitigation(void)
692698
switch (boot_cpu_data.x86_vendor) {
693699
case X86_VENDOR_INTEL:
694700
x86_spec_ctrl_base |= SPEC_CTRL_RDS;
701+
x86_spec_ctrl_mask &= ~SPEC_CTRL_RDS;
695702
x86_spec_ctrl_set(SPEC_CTRL_RDS);
696703
break;
697704
case X86_VENDOR_AMD:
@@ -715,7 +722,7 @@ static void ssb_select_mitigation()
715722
void x86_spec_ctrl_setup_ap(void)
716723
{
717724
if (boot_cpu_has(X86_FEATURE_IBRS))
718-
x86_spec_ctrl_set(x86_spec_ctrl_base & (SPEC_CTRL_IBRS | SPEC_CTRL_RDS));
725+
x86_spec_ctrl_set(x86_spec_ctrl_base & ~x86_spec_ctrl_mask);
719726
}
720727

721728
#ifdef CONFIG_SYSFS

0 commit comments

Comments
 (0)