mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for David Kaplan" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: David Kaplan <david.kaplan@amd.com>,
	"Borislav Petkov (AMD)" <bp@alien8.de>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/bugs] x86/bugs: Restructure SSB mitigation
Date: Fri, 02 May 2025 10:33:20 -0000	[thread overview]
Message-ID: <174618200065.22196.16669598075085540965.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250418161721.1855190-15-david.kaplan@amd.com>

The following commit has been merged into the x86/bugs branch of tip:

Commit-ID:     5ece59a2fca6e1467558467a05cf742b7e52d1b7
Gitweb:        https://git.kernel.org/tip/5ece59a2fca6e1467558467a05cf742b7e52d1b7
Author:        David Kaplan <david.kaplan@amd.com>
AuthorDate:    Fri, 18 Apr 2025 11:17:19 -05:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 29 Apr 2025 18:57:26 +02:00

x86/bugs: Restructure SSB mitigation

Restructure SSB to use select/apply functions to create consistent
vulnerability handling.

Remove __ssb_select_mitigation() and split the functionality between the
select/apply functions.

Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/20250418161721.1855190-15-david.kaplan@amd.com
---
 arch/x86/kernel/cpu/bugs.c | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 93d0743..fbb4f13 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -65,6 +65,7 @@ static void __init spectre_v2_user_select_mitigation(void);
 static void __init spectre_v2_user_update_mitigation(void);
 static void __init spectre_v2_user_apply_mitigation(void);
 static void __init ssb_select_mitigation(void);
+static void __init ssb_apply_mitigation(void);
 static void __init l1tf_select_mitigation(void);
 static void __init mds_select_mitigation(void);
 static void __init mds_update_mitigation(void);
@@ -243,6 +244,7 @@ void __init cpu_select_mitigations(void)
 	spectre_v2_apply_mitigation();
 	retbleed_apply_mitigation();
 	spectre_v2_user_apply_mitigation();
+	ssb_apply_mitigation();
 	mds_apply_mitigation();
 	taa_apply_mitigation();
 	mmio_apply_mitigation();
@@ -2219,19 +2221,18 @@ static enum ssb_mitigation_cmd __init ssb_parse_cmdline(void)
 	return cmd;
 }
 
-static enum ssb_mitigation __init __ssb_select_mitigation(void)
+static void __init ssb_select_mitigation(void)
 {
-	enum ssb_mitigation mode = SPEC_STORE_BYPASS_NONE;
 	enum ssb_mitigation_cmd cmd;
 
 	if (!boot_cpu_has(X86_FEATURE_SSBD))
-		return mode;
+		goto out;
 
 	cmd = ssb_parse_cmdline();
 	if (!boot_cpu_has_bug(X86_BUG_SPEC_STORE_BYPASS) &&
 	    (cmd == SPEC_STORE_BYPASS_CMD_NONE ||
 	     cmd == SPEC_STORE_BYPASS_CMD_AUTO))
-		return mode;
+		return;
 
 	switch (cmd) {
 	case SPEC_STORE_BYPASS_CMD_SECCOMP:
@@ -2240,28 +2241,35 @@ static enum ssb_mitigation __init __ssb_select_mitigation(void)
 		 * enabled.
 		 */
 		if (IS_ENABLED(CONFIG_SECCOMP))
-			mode = SPEC_STORE_BYPASS_SECCOMP;
+			ssb_mode = SPEC_STORE_BYPASS_SECCOMP;
 		else
-			mode = SPEC_STORE_BYPASS_PRCTL;
+			ssb_mode = SPEC_STORE_BYPASS_PRCTL;
 		break;
 	case SPEC_STORE_BYPASS_CMD_ON:
-		mode = SPEC_STORE_BYPASS_DISABLE;
+		ssb_mode = SPEC_STORE_BYPASS_DISABLE;
 		break;
 	case SPEC_STORE_BYPASS_CMD_AUTO:
 	case SPEC_STORE_BYPASS_CMD_PRCTL:
-		mode = SPEC_STORE_BYPASS_PRCTL;
+		ssb_mode = SPEC_STORE_BYPASS_PRCTL;
 		break;
 	case SPEC_STORE_BYPASS_CMD_NONE:
 		break;
 	}
 
+out:
+	if (boot_cpu_has_bug(X86_BUG_SPEC_STORE_BYPASS))
+		pr_info("%s\n", ssb_strings[ssb_mode]);
+}
+
+static void __init ssb_apply_mitigation(void)
+{
 	/*
 	 * We have three CPU feature flags that are in play here:
 	 *  - X86_BUG_SPEC_STORE_BYPASS - CPU is susceptible.
 	 *  - X86_FEATURE_SSBD - CPU is able to turn off speculative store bypass
 	 *  - X86_FEATURE_SPEC_STORE_BYPASS_DISABLE - engage the mitigation
 	 */
-	if (mode == SPEC_STORE_BYPASS_DISABLE) {
+	if (ssb_mode == SPEC_STORE_BYPASS_DISABLE) {
 		setup_force_cpu_cap(X86_FEATURE_SPEC_STORE_BYPASS_DISABLE);
 		/*
 		 * Intel uses the SPEC CTRL MSR Bit(2) for this, while AMD may
@@ -2275,16 +2283,6 @@ static enum ssb_mitigation __init __ssb_select_mitigation(void)
 			update_spec_ctrl(x86_spec_ctrl_base);
 		}
 	}
-
-	return mode;
-}
-
-static void ssb_select_mitigation(void)
-{
-	ssb_mode = __ssb_select_mitigation();
-
-	if (boot_cpu_has_bug(X86_BUG_SPEC_STORE_BYPASS))
-		pr_info("%s\n", ssb_strings[ssb_mode]);
 }
 
 #undef pr_fmt

  parent reply	other threads:[~2025-05-02 10:33 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-18 16:17 [PATCH v5 00/16] Attack vector controls (part 1) David Kaplan
2025-04-18 16:17 ` [PATCH v5 01/16] x86/bugs: Restructure MDS mitigation David Kaplan
2025-04-18 20:42   ` Borislav Petkov
2025-04-20 21:00     ` Kaplan, David
2025-04-22  8:19       ` Borislav Petkov
2025-04-22 14:32         ` Kaplan, David
2025-04-22 17:25           ` Borislav Petkov
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 02/16] x86/bugs: Restructure TAA mitigation David Kaplan
2025-04-19 12:36   ` Borislav Petkov
2025-04-20 21:03     ` Kaplan, David
2025-04-22  8:56       ` Borislav Petkov
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 03/16] x86/bugs: Restructure MMIO mitigation David Kaplan
2025-04-24 20:19   ` Borislav Petkov
2025-04-24 20:31     ` Kaplan, David
2025-04-25  8:09       ` Borislav Petkov
2025-04-25 13:28         ` Kaplan, David
2025-04-26 11:22           ` Borislav Petkov
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 04/16] x86/bugs: Restructure RFDS mitigation David Kaplan
2025-04-27 15:09   ` Borislav Petkov
2025-04-28 13:42     ` Kaplan, David
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 05/16] x86/bugs: Remove md_clear_*_mitigation() David Kaplan
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 06/16] x86/bugs: Restructure SRBDS mitigation David Kaplan
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 07/16] x86/bugs: Restructure GDS mitigation David Kaplan
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 08/16] x86/bugs: Restructure spectre_v1 mitigation David Kaplan
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 09/16] x86/bugs: Allow retbleed=stuff only on Intel David Kaplan
2025-04-27 15:38   ` Borislav Petkov
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 10/16] x86/bugs: Restructure retbleed mitigation David Kaplan
2025-04-28 18:59   ` Borislav Petkov
2025-04-28 20:55     ` Kaplan, David
2025-04-29  8:21       ` Borislav Petkov
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 11/16] x86/bugs: Restructure spectre_v2_user mitigation David Kaplan
2025-04-29  8:47   ` Borislav Petkov
2025-04-29 14:11     ` Kaplan, David
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 12/16] x86/bugs: Restructure BHI mitigation David Kaplan
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 13/16] x86/bugs: Restructure spectre_v2 mitigation David Kaplan
2025-04-29 10:46   ` Borislav Petkov
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 14/16] x86/bugs: Restructure SSB mitigation David Kaplan
2025-04-29 12:54   ` Borislav Petkov
2025-04-29 14:09     ` Kaplan, David
2025-05-02 10:33   ` tip-bot2 for David Kaplan [this message]
2025-04-18 16:17 ` [PATCH v5 15/16] x86/bugs: Restructure L1TF mitigation David Kaplan
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 16:17 ` [PATCH v5 16/16] x86/bugs: Restructure SRSO mitigation David Kaplan
2025-04-29 16:50   ` Borislav Petkov
2025-04-29 17:18     ` Kaplan, David
2025-04-30  8:25       ` Borislav Petkov
2025-05-02 10:33   ` [tip: x86/bugs] " tip-bot2 for David Kaplan
2025-04-18 20:03 ` [PATCH v5 00/16] Attack vector controls (part 1) Ingo Molnar
2025-04-18 21:33   ` Borislav Petkov
2025-04-22  9:46     ` Ingo Molnar
2025-04-22 13:59       ` Borislav Petkov
2025-04-22  5:22 ` Josh Poimboeuf

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=174618200065.22196.16669598075085540965.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bp@alien8.de \
    --cc=david.kaplan@amd.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --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®