Skip to content

Commit 6b18878

Browse files
committed
Revert "x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation"
This reverts commit 233b9d7 which is commit 53c613f upstream. It's not ready for the stable trees as there are major slowdowns involved with this patch. Reported-by: Jiri Kosina <jkosina@suse.cz> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: "WoodhouseDavid" <dwmw@amazon.co.uk> Cc: Andi Kleen <ak@linux.intel.com> Cc: Tim Chen <tim.c.chen@linux.intel.com> Cc: "SchauflerCasey" <casey.schaufler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 520d564 commit 6b18878

2 files changed

Lines changed: 7 additions & 61 deletions

File tree

‎arch/x86/kernel/cpu/bugs.c‎

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ static void __init spectre_v2_select_mitigation(void);
3535
static void __init ssb_select_mitigation(void);
3636
static void __init l1tf_select_mitigation(void);
3737

38-
/* The base value of the SPEC_CTRL MSR that always has to be preserved. */
39-
u64 x86_spec_ctrl_base;
38+
/*
39+
* Our boot-time value of the SPEC_CTRL MSR. We read it once so that any
40+
* writes to SPEC_CTRL contain whatever reserved bits have been set.
41+
*/
42+
u64 __ro_after_init x86_spec_ctrl_base;
4043
EXPORT_SYMBOL_GPL(x86_spec_ctrl_base);
41-
static DEFINE_MUTEX(spec_ctrl_mutex);
4244

4345
/*
4446
* The vendor and possibly platform specific bits which can be modified in
@@ -323,46 +325,6 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
323325
return cmd;
324326
}
325327

326-
static bool stibp_needed(void)
327-
{
328-
if (spectre_v2_enabled == SPECTRE_V2_NONE)
329-
return false;
330-
331-
if (!boot_cpu_has(X86_FEATURE_STIBP))
332-
return false;
333-
334-
return true;
335-
}
336-
337-
static void update_stibp_msr(void *info)
338-
{
339-
wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base);
340-
}
341-
342-
void arch_smt_update(void)
343-
{
344-
u64 mask;
345-
346-
if (!stibp_needed())
347-
return;
348-
349-
mutex_lock(&spec_ctrl_mutex);
350-
mask = x86_spec_ctrl_base;
351-
if (cpu_smt_control == CPU_SMT_ENABLED)
352-
mask |= SPEC_CTRL_STIBP;
353-
else
354-
mask &= ~SPEC_CTRL_STIBP;
355-
356-
if (mask != x86_spec_ctrl_base) {
357-
pr_info("Spectre v2 cross-process SMT mitigation: %s STIBP\n",
358-
cpu_smt_control == CPU_SMT_ENABLED ?
359-
"Enabling" : "Disabling");
360-
x86_spec_ctrl_base = mask;
361-
on_each_cpu(update_stibp_msr, NULL, 1);
362-
}
363-
mutex_unlock(&spec_ctrl_mutex);
364-
}
365-
366328
static void __init spectre_v2_select_mitigation(void)
367329
{
368330
enum spectre_v2_mitigation_cmd cmd = spectre_v2_parse_cmdline();
@@ -462,9 +424,6 @@ static void __init spectre_v2_select_mitigation(void)
462424
setup_force_cpu_cap(X86_FEATURE_USE_IBRS_FW);
463425
pr_info("Enabling Restricted Speculation for firmware calls\n");
464426
}
465-
466-
/* Enable STIBP if appropriate */
467-
arch_smt_update();
468427
}
469428

470429
#undef pr_fmt
@@ -855,8 +814,6 @@ static ssize_t l1tf_show_state(char *buf)
855814
static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr,
856815
char *buf, unsigned int bug)
857816
{
858-
int ret;
859-
860817
if (!boot_cpu_has_bug(bug))
861818
return sprintf(buf, "Not affected\n");
862819

@@ -874,12 +831,10 @@ static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr
874831
return sprintf(buf, "Mitigation: __user pointer sanitization\n");
875832

876833
case X86_BUG_SPECTRE_V2:
877-
ret = sprintf(buf, "%s%s%s%s%s\n", spectre_v2_strings[spectre_v2_enabled],
834+
return sprintf(buf, "%s%s%s%s\n", spectre_v2_strings[spectre_v2_enabled],
878835
boot_cpu_has(X86_FEATURE_USE_IBPB) ? ", IBPB" : "",
879836
boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? ", IBRS_FW" : "",
880-
(x86_spec_ctrl_base & SPEC_CTRL_STIBP) ? ", STIBP" : "",
881837
spectre_v2_module_string());
882-
return ret;
883838

884839
case X86_BUG_SPEC_STORE_BYPASS:
885840
return sprintf(buf, "%s\n", ssb_strings[ssb_mode]);

‎kernel/cpu.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,12 +2026,6 @@ static void cpuhp_online_cpu_device(unsigned int cpu)
20262026
kobject_uevent(&dev->kobj, KOBJ_ONLINE);
20272027
}
20282028

2029-
/*
2030-
* Architectures that need SMT-specific errata handling during SMT hotplug
2031-
* should override this.
2032-
*/
2033-
void __weak arch_smt_update(void) { };
2034-
20352029
static int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
20362030
{
20372031
int cpu, ret = 0;
@@ -2058,10 +2052,8 @@ static int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
20582052
*/
20592053
cpuhp_offline_cpu_device(cpu);
20602054
}
2061-
if (!ret) {
2055+
if (!ret)
20622056
cpu_smt_control = ctrlval;
2063-
arch_smt_update();
2064-
}
20652057
cpu_maps_update_done();
20662058
return ret;
20672059
}
@@ -2072,7 +2064,6 @@ static int cpuhp_smt_enable(void)
20722064

20732065
cpu_maps_update_begin();
20742066
cpu_smt_control = CPU_SMT_ENABLED;
2075-
arch_smt_update();
20762067
for_each_present_cpu(cpu) {
20772068
/* Skip online CPUs and CPUs on offline nodes */
20782069
if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))

0 commit comments

Comments
 (0)