|
@@ -117,7 +117,7 @@ static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE;
|
|
|
|
|
|
void x86_spec_ctrl_set(u64 val)
|
|
|
{
|
|
|
- if (val & ~SPEC_CTRL_IBRS)
|
|
|
+ if (val & ~(SPEC_CTRL_IBRS | SPEC_CTRL_RDS))
|
|
|
WARN_ONCE(1, "SPEC_CTRL MSR value 0x%16llx is unknown.\n", val);
|
|
|
else
|
|
|
wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base | val);
|
|
@@ -444,8 +444,28 @@ static enum ssb_mitigation_cmd __init __ssb_select_mitigation(void)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (mode != SPEC_STORE_BYPASS_NONE)
|
|
|
+ /*
|
|
|
+ * We have three CPU feature flags that are in play here:
|
|
|
+ * - X86_BUG_SPEC_STORE_BYPASS - CPU is susceptible.
|
|
|
+ * - X86_FEATURE_RDS - CPU is able to turn off speculative store bypass
|
|
|
+ * - X86_FEATURE_SPEC_STORE_BYPASS_DISABLE - engage the mitigation
|
|
|
+ */
|
|
|
+ if (mode != SPEC_STORE_BYPASS_NONE) {
|
|
|
setup_force_cpu_cap(X86_FEATURE_SPEC_STORE_BYPASS_DISABLE);
|
|
|
+ /*
|
|
|
+ * Intel uses the SPEC CTRL MSR Bit(2) for this, while AMD uses
|
|
|
+ * a completely different MSR and bit dependent on family.
|
|
|
+ */
|
|
|
+ switch (boot_cpu_data.x86_vendor) {
|
|
|
+ case X86_VENDOR_INTEL:
|
|
|
+ x86_spec_ctrl_base |= SPEC_CTRL_RDS;
|
|
|
+ x86_spec_ctrl_set(SPEC_CTRL_RDS);
|
|
|
+ break;
|
|
|
+ case X86_VENDOR_AMD:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return mode;
|
|
|
}
|
|
|
|
|
@@ -459,6 +479,12 @@ static void ssb_select_mitigation()
|
|
|
|
|
|
#undef pr_fmt
|
|
|
|
|
|
+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));
|
|
|
+}
|
|
|
+
|
|
|
#ifdef CONFIG_SYSFS
|
|
|
|
|
|
ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr,
|