From: Jiri Kosina Date: Fri, 13 Jul 2018 14:23:23 +0000 (+0200) Subject: cpu/hotplug: Expose SMT control init function X-Git-Tag: v4.1.12-124.31.3~622 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4d366d35c7c13171ca3a508f26efcf1a57093f1d;p=users%2Fjedix%2Flinux-maple.git cpu/hotplug: Expose SMT control init function The L1TF mitigation will gain a commend line parameter which allows to set a combination of hypervisor mitigation and SMT control. Expose cpu_smt_disable() so the command line parser can tweak SMT settings. [ tglx: Split out of larger patch and made it preserve an already existing force off state ] Signed-off-by: Jiri Kosina Signed-off-by: Thomas Gleixner Tested-by: Jiri Kosina Reviewed-by: Greg Kroah-Hartman Reviewed-by: Josh Poimboeuf Link: https://lkml.kernel.org/r/20180713142323.039715135@linutronix.de Orabug: 28220674 CVE: CVE-2018-3620 (cherry picked from commit 8e1b706b6e819bed215c0db16345568864660393) Signed-off-by: Mihai Carabas Reviewed-by: Darren Kenny Reviewed-by: Boris Ostrovsky Conflicts: kernel/cpu.c Contextual: different content --- diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 3c58810123e4..3553419e8627 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -317,8 +317,10 @@ enum cpuhp_smt_control { #if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT) extern enum cpuhp_smt_control cpu_smt_control; +extern void cpu_smt_disable(bool force); #else # define cpu_smt_control (CPU_SMT_ENABLED) +static inline void cpu_smt_disable(bool force) { } #endif #endif /* _LINUX_CPU_H_ */ diff --git a/kernel/cpu.c b/kernel/cpu.c index 66994587ccb9..3e609b4275d5 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -499,13 +499,23 @@ void __cpuinit smpboot_thread_init(void) enum cpuhp_smt_control cpu_smt_control __read_mostly = CPU_SMT_ENABLED; EXPORT_SYMBOL_GPL(cpu_smt_control); -static int __init smt_cmdline_disable(char *str) +void __init cpu_smt_disable(bool force) { - cpu_smt_control = CPU_SMT_DISABLED; - if (str && !strcmp(str, "force")) { + if (cpu_smt_control == CPU_SMT_FORCE_DISABLED || + cpu_smt_control == CPU_SMT_NOT_SUPPORTED) + return; + + if (force) { pr_info("SMT: Force disabled\n"); cpu_smt_control = CPU_SMT_FORCE_DISABLED; + } else { + cpu_smt_control = CPU_SMT_DISABLED; } +} + +static int __init smt_cmdline_disable(char *str) +{ + cpu_smt_disable(str && !strcmp(str, "force")); return 0; } early_param("nosmt", smt_cmdline_disable);