From: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
To: Petr Tesarik <ptesarik@suse.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>,
"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] x86/tsx: Get the tsx= command line parameter with early_param()
Date: Thu, 9 Oct 2025 11:51:34 -0700 [thread overview]
Message-ID: <20251009185134.fb4evjrk76rwxv37@desk> (raw)
In-Reply-To: <63118e583443490a285fd194baeae874d65eff87.1758906115.git.ptesarik@suse.com>
On Fri, Sep 26, 2025 at 08:01:02PM +0200, Petr Tesarik wrote:
> Use early_param() to get the value of the tsx= command line parameter.
> Although cmdline_find_option() works fine, the option is later reported
> as unknown and passed to user space. The latter is not a real issue, but
> the former is confusing and makes people wonder if the tsx= parameter had
> any effect and double-check for typos unnecessarily.
>
> The behavior changes slightly if "tsx" is given without any argument (which
> is invalid syntax). Prior to this patch, the kernel logged an error message
> and disabled TSX. With this patch, the parameter is ignored. The new
> behavior is consistent with other parameters, e.g. "tsx_async_abort".
>
> Signed-off-by: Petr Tesarik <ptesarik@suse.com>
> ---
> arch/x86/kernel/cpu/tsx.c | 41 ++++++++++++++++++++++-----------------
> 1 file changed, 23 insertions(+), 18 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/tsx.c b/arch/x86/kernel/cpu/tsx.c
> index 167dfd38b87a2..bb407331f64b5 100644
> --- a/arch/x86/kernel/cpu/tsx.c
> +++ b/arch/x86/kernel/cpu/tsx.c
> @@ -20,14 +20,14 @@
> #define pr_fmt(fmt) "tsx: " fmt
>
> enum tsx_ctrl_states {
> + TSC_CTRL_UNSPECIFIED,
s/TSC/TSX/
> TSX_CTRL_ENABLE,
> TSX_CTRL_DISABLE,
> TSX_CTRL_RTM_ALWAYS_ABORT,
> TSX_CTRL_NOT_SUPPORTED,
> };
>
> -static enum tsx_ctrl_states tsx_ctrl_state __ro_after_init =
> - TSX_CTRL_NOT_SUPPORTED;
> +static enum tsx_ctrl_states tsx_ctrl_state __ro_after_init;
>
> static void tsx_disable(void)
> {
> @@ -164,11 +164,28 @@ static void tsx_dev_mode_disable(void)
> }
> }
>
> -void __init tsx_init(void)
> +static int __init tsx_parse_cmdline(char *str)
> {
> - char arg[5] = {};
> - int ret;
> + if (!str)
> + return -EINVAL;
> +
> + if (!strcmp(str, "on")) {
> + tsx_ctrl_state = TSX_CTRL_ENABLE;
> + } else if (!strcmp(str, "off")) {
> + tsx_ctrl_state = TSX_CTRL_DISABLE;
> + } else if (!strcmp(str, "auto")) {
> + tsx_ctrl_state = x86_get_tsx_auto_mode();
NACK, this introduces a subtle bug. With this change x86_get_tsx_auto_mode()
would return TSX_CTRL_ENABLE always, irrespective of whether the CPU has
X86_BUG_TAA or not. This is because early_param() is executed before
cpu_set_bug_bits().
> + } else {
> + tsx_ctrl_state = TSX_CTRL_DISABLE;
> + pr_err("invalid option, defaulting to off\n");
> + }
>
> + return 0;
> +}
> +early_param("tsx", tsx_parse_cmdline);
Rather, a patch to add a comment would be better.
---
diff --git a/arch/x86/kernel/cpu/tsx.c b/arch/x86/kernel/cpu/tsx.c
index 49782724a943..8fd1c16a38ec 100644
--- a/arch/x86/kernel/cpu/tsx.c
+++ b/arch/x86/kernel/cpu/tsx.c
@@ -194,6 +194,11 @@ void __init tsx_init(void)
return;
}
+ /*
+ * Cmdline is not processed via early_param() to ensure
+ * cpu_set_bug_bits() is executed already. And x86_get_tsx_auto_mode()
+ * returns the appropriate default based on X86_BUG_TAA.
+ */
ret = cmdline_find_option(boot_command_line, "tsx", arg, sizeof(arg));
if (ret >= 0) {
if (!strcmp(arg, "on")) {
next prev parent reply other threads:[~2025-10-09 18:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 18:01 [PATCH v2 0/2] x86/tsx: Improve handling of the tsx= kernel parameter Petr Tesarik
2025-09-26 18:01 ` [PATCH v2 1/2] x86/tsx: Make tsx_ctrl_state static Petr Tesarik
2025-10-07 12:40 ` Nikolay Borisov
2025-10-09 17:58 ` Pawan Gupta
2025-09-26 18:01 ` [PATCH v2 2/2] x86/tsx: Get the tsx= command line parameter with early_param() Petr Tesarik
2025-10-07 12:50 ` Nikolay Borisov
2025-10-08 14:03 ` Petr Tesarik
2025-10-22 16:31 ` Petr Tesarik
2025-10-09 18:51 ` Pawan Gupta [this message]
2025-10-10 0:33 ` Pawan Gupta
2025-10-10 7:45 ` Petr Tesarik
2025-10-10 17:52 ` Pawan Gupta
2025-10-10 7:40 ` Petr Tesarik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251009185134.fb4evjrk76rwxv37@desk \
--to=pawan.kumar.gupta@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=ptesarik@suse.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®