Return-Path: Received: from mail.linutronix.de (193.142.43.55:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 05 Oct 2019 06:39:16 -0000 Received: from mga02.intel.com ([134.134.136.20]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iGdik-0007sP-N4 for speck@linutronix.de; Sat, 05 Oct 2019 08:39:15 +0200 Date: Fri, 4 Oct 2019 23:33:31 -0700 From: Pawan Gupta Subject: [MODERATED] [PATCH v5 08/11] TAAv5 8 Message-ID: =?utf-8?q?=3Cfe5ff90a8b62d19d7c37b5b5f4259a085804203c=2E157025?= =?utf-8?q?5065=2Egit=2Epawan=2Ekumar=2Egupta=40linux=2Eintel=2Ecom=3E?= References: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: Platforms which are not affected by X86_BUG_TAA may want the TSX feature enabled. Add "auto" option to the TSX cmdline parameter. When tsx=auto, disable TSX when X86_BUG_TAA is present, otherwise enable TSX. More details on X86_BUG_TAA can be found here: https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/tsx_async_abort.html Signed-off-by: Pawan Gupta Reviewed-by: Tony Luck Tested-by: Neelima Krishnan --- Documentation/admin-guide/kernel-parameters.txt | 5 +++++ arch/x86/kernel/cpu/tsx.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 832537d59562..d7b48c38c6e5 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4821,6 +4821,11 @@ on - Enable TSX on the system. off - Disable TSX on the system. + auto - Disable TSX if X86_BUG_TAA is present, + otherwise enable TSX on the system. + + More details on X86_BUG_TAA are here: + Documentation/admin-guide/hw-vuln/tsx_async_abort.rst Not specifying this option is equivalent to tsx=off. diff --git a/arch/x86/kernel/cpu/tsx.c b/arch/x86/kernel/cpu/tsx.c index 1c0cee7a7d46..73a0e5af3720 100644 --- a/arch/x86/kernel/cpu/tsx.c +++ b/arch/x86/kernel/cpu/tsx.c @@ -23,6 +23,7 @@ static enum tsx_user_cmds { TSX_USER_CMD_NONE, TSX_USER_CMD_ON, TSX_USER_CMD_OFF, + TSX_USER_CMD_AUTO, } tsx_user_cmd = TSX_USER_CMD_NONE; static int __init tsx_cmdline(char *str) @@ -38,6 +39,8 @@ static int __init tsx_cmdline(char *str) tsx_user_cmd = TSX_USER_CMD_ON; else if (!strcmp(str, "off")) tsx_user_cmd = TSX_USER_CMD_OFF; + else if (!strcmp(str, "auto")) + tsx_user_cmd = TSX_USER_CMD_AUTO; return 0; } @@ -104,6 +107,12 @@ void tsx_init(struct cpuinfo_x86 *c) case TSX_USER_CMD_OFF: tsx_ctrl_state = TSX_CTRL_DISABLE; break; + case TSX_USER_CMD_AUTO: + if (boot_cpu_has_bug(X86_BUG_TAA)) + tsx_ctrl_state = TSX_CTRL_DISABLE; + else + tsx_ctrl_state = TSX_CTRL_ENABLE; + break; case TSX_USER_CMD_NONE: default: /* -- 2.20.1