Skip to contentSkip to conversation

Linux Patch #8

PATCH Superseded [email protected] 2 participants 2 messages Apr 26, 2018

Subsystems (2)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 8/10 Linux Patch #8

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 we need a run-time way to whitelist the appropiate MSR values.

---
v5: New patch

---
 arch/x86/kernel/cpu/bugs.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/bugs.c +10 -2
index 99cdd44c20bc..7c704bc36968 100644
@@ -35,6 +35,12 @@ static void __init ssb_select_mitigation(void);
  */
 u64 __read_mostly x86_spec_ctrl_base;
 
+/*
+ * Sane bits that can written in x86_spec_ctrl_base. They may differ
+ * on different platforms.
+ */
+u64 __read_mostly x86_spec_ctrl_mask = ~(SPEC_CTRL_IBRS);
+
 void __init check_bugs(void)
 {
 	/*
@@ -122,7 +128,7 @@ static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE;
 
 void x86_set_spec_ctrl(u64 val)
 {
-	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
 		wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base | val);
@@ -469,8 +475,10 @@ static void __init ssb_select_mitigation(void)
 		/*
 		 * Intel uses the SPEC CTRL MSR Bit(2) for this.
 		 */
-		if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
+		if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
 			x86_spec_ctrl_base |= SPEC_CTRL_RDS;
+			x86_spec_ctrl_mask &= ~(SPEC_CTRL_RDS);
+		}
 
 	}
 }
Signature · 1 line
2.14.3
#1 lore raw
Quoted 6 lines · speck for konrad.wilk_at_oracle.com

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 we need a run-time way to whitelist the appropiate

WARNING: 'appropiate' may be misspelled - perhaps 'appropriate'?

Quoted 14 lines

MSR values.

---
v5: New patch

---
 arch/x86/kernel/cpu/bugs.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/bugs.c +0 -0
index 99cdd44c20bc..7c704bc36968 100644

arch/x86/kernel/cpu/bugs.c static void __init ssb_select_mitigation(void); · line 39

Quoted 5 lines
arch/x86/kernel/cpu/bugs.c +2 -0
@@ -35,6 +35,12 @@ static void __init ssb_select_mitigation(void);
  */
 u64 __read_mostly x86_spec_ctrl_base;
 
+/*
+ * Sane bits that can written in x86_spec_ctrl_base. They may differ

"Allowed per-vendor SPEC_CTRL MSR bits."

arch/x86/kernel/cpu/bugs.c static void __init ssb_select_mitigation(void); · line 42

Quoted 3 lines
arch/x86/kernel/cpu/bugs.c +3 -0
+ * on different platforms.
+ */
+u64 __read_mostly x86_spec_ctrl_mask = ~(SPEC_CTRL_IBRS);

static!

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--