Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 12 Jul 2018 14:41:06 -0000 Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1fdcfw-0006vs-FE for speck@linutronix.de; Thu, 12 Jul 2018 16:34:32 +0200 Message-ID: <20180712142957.626429955@linutronix.de> Date: Thu, 12 Jul 2018 16:19:10 +0200 From: Thomas Gleixner References: <20180712141902.576562442@linutronix.de> Subject: [patch V10 08/10] Control knobs and Documentation 8 Mime-Version: 1 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: Subject: [patch V10 08/10] cpu/hotplug: Expose SMT control init function From: Jiri Kosina 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 --- include/linux/cpu.h | 2 ++ kernel/cpu.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -177,8 +177,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_ */ --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -347,13 +347,21 @@ EXPORT_SYMBOL_GPL(cpu_hotplug_enable); 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) { + if (cpu_smt_control == CPU_SMT_FORCE_DISABLED) + return; + cpu_smt_control = CPU_SMT_DISABLED; - if (str && !strcmp(str, "force")) { + if (force) { pr_info("SMT: Force disabled\n"); cpu_smt_control = CPU_SMT_FORCE_DISABLED; } +} + +static int __init smt_cmdline_disable(char *str) +{ + cpu_smt_disable(str && !strcmp(str, "force")); return 0; } early_param("nosmt", smt_cmdline_disable);