From: Josh Poimboeuf Date: Tue, 24 Jul 2018 16:17:40 +0000 (+0200) Subject: cpu/hotplug: detect SMT disabled by BIOS X-Git-Tag: v4.1.12-124.31.3~615 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=70730fdf2e6e23a1f43c0425ebd19d7a79117d8d;p=users%2Fjedix%2Flinux-maple.git cpu/hotplug: detect SMT disabled by BIOS If SMT is disabled in BIOS, the CPU code doesn't properly detect it. The /sys/devices/system/cpu/smt/control file shows 'on', and the 'l1tf' vulnerabilities file shows SMT as vulnerable. Fix it by forcing 'cpu_smt_control' to CPU_SMT_NOT_SUPPORTED in such a case. Unfortunately the detection can only be done after bringing all the CPUs online, so we have to overwrite any previous writes to the variable. Reported-by: Joe Mario Tested-by: Jiri Kosina Fixes: f048c399e0f7 ("x86/topology: Provide topology_smt_supported()") Signed-off-by: Josh Poimboeuf Signed-off-by: Peter Zijlstra Orabug: 28220674 CVE: CVE-2018-3620 (cherry picked from commit 73d5e2b472640b1fcdb61ae8be389912ef211bda) Signed-off-by: Mihai Carabas Reviewed-by: Darren Kenny Reviewed-by: Boris Ostrovsky --- diff --git a/kernel/cpu.c b/kernel/cpu.c index 6f267f6dee85..990eea28a286 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -959,6 +959,15 @@ static const struct attribute_group cpuhp_smt_attr_group = { static int __init cpu_smt_state_init(void) { + /* + * If SMT was disabled by BIOS, detect it here, after the CPUs have + * been brought online. This ensures the smt/l1tf sysfs entries are + * consistent with reality. Note this may overwrite cpu_smt_control's + * previous setting. + */ + if (topology_max_smt_threads() == 1) + cpu_smt_control = CPU_SMT_NOT_SUPPORTED; + return sysfs_create_group(&cpu_subsys.dev_root->kobj, &cpuhp_smt_attr_group); }