From: Peter Zijlstra <peterz@infradead.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
David.Kaplan@amd.com, Andrew.Cooper3@citrix.com,
jpoimboe@kernel.org, gregkh@linuxfoundation.org
Subject: [RFC][PATCH 11/17] x86/cpu: Remove all SRSO interface nonsense
Date: Wed, 09 Aug 2023 09:12:29 +0200 [thread overview]
Message-ID: <20230809072201.192502969@infradead.org> (raw)
In-Reply-To: <20230809071218.000335006@infradead.org>
Now that retbleed can do all that the srso knob did, and without the
dubious interactions with retbleed selections, remove it.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/kernel/cpu/bugs.c | 188 ++-------------------------------------------
drivers/base/cpu.c | 8 -
include/linux/cpu.h | 2
3 files changed, 10 insertions(+), 188 deletions(-)
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -47,7 +47,6 @@ static void __init taa_select_mitigation
static void __init mmio_select_mitigation(void);
static void __init srbds_select_mitigation(void);
static void __init l1d_flush_select_mitigation(void);
-static void __init srso_select_mitigation(void);
/* The base value of the SPEC_CTRL MSR without task-specific bits set */
u64 x86_spec_ctrl_base;
@@ -164,7 +163,6 @@ void __init cpu_select_mitigations(void)
md_clear_select_mitigation();
srbds_select_mitigation();
l1d_flush_select_mitigation();
- srso_select_mitigation();
}
/*
@@ -2267,164 +2265,6 @@ static int __init l1tf_cmdline(char *str
early_param("l1tf", l1tf_cmdline);
#undef pr_fmt
-#define pr_fmt(fmt) "Speculative Return Stack Overflow: " fmt
-
-enum srso_mitigation {
- SRSO_MITIGATION_NONE,
- SRSO_MITIGATION_MICROCODE,
- SRSO_MITIGATION_SAFE_RET,
- SRSO_MITIGATION_IBPB,
- SRSO_MITIGATION_IBPB_ON_VMEXIT,
-};
-
-enum srso_mitigation_cmd {
- SRSO_CMD_OFF,
- SRSO_CMD_MICROCODE,
- SRSO_CMD_SAFE_RET,
- SRSO_CMD_IBPB,
- SRSO_CMD_IBPB_ON_VMEXIT,
-};
-
-static const char * const srso_strings[] = {
- [SRSO_MITIGATION_NONE] = "Vulnerable",
- [SRSO_MITIGATION_MICROCODE] = "Mitigation: microcode",
- [SRSO_MITIGATION_SAFE_RET] = "Mitigation: safe RET",
- [SRSO_MITIGATION_IBPB] = "Mitigation: IBPB",
- [SRSO_MITIGATION_IBPB_ON_VMEXIT] = "Mitigation: IBPB on VMEXIT only"
-};
-
-static enum srso_mitigation srso_mitigation __ro_after_init = SRSO_MITIGATION_NONE;
-static enum srso_mitigation_cmd srso_cmd __ro_after_init = SRSO_CMD_SAFE_RET;
-
-static int __init srso_parse_cmdline(char *str)
-{
- if (!str)
- return -EINVAL;
-
- if (!strcmp(str, "off"))
- srso_cmd = SRSO_CMD_OFF;
- else if (!strcmp(str, "microcode"))
- srso_cmd = SRSO_CMD_MICROCODE;
- else if (!strcmp(str, "safe-ret"))
- srso_cmd = SRSO_CMD_SAFE_RET;
- else if (!strcmp(str, "ibpb"))
- srso_cmd = SRSO_CMD_IBPB;
- else if (!strcmp(str, "ibpb-vmexit"))
- srso_cmd = SRSO_CMD_IBPB_ON_VMEXIT;
- else
- pr_err("Ignoring unknown SRSO option (%s).", str);
-
- return 0;
-}
-early_param("spec_rstack_overflow", srso_parse_cmdline);
-
-#define SRSO_NOTICE "WARNING: See https://kernel.org/doc/html/latest/admin-guide/hw-vuln/srso.html for mitigation options."
-
-static void __init srso_select_mitigation(void)
-{
- bool has_microcode;
-
- if (!boot_cpu_has_bug(X86_BUG_SRSO) || cpu_mitigations_off())
- goto pred_cmd;
-
- /*
- * The first check is for the kernel running as a guest in order
- * for guests to verify whether IBPB is a viable mitigation.
- */
- has_microcode = boot_cpu_has(X86_FEATURE_IBPB_BRTYPE) || cpu_has_ibpb_brtype_microcode();
- if (!has_microcode) {
- pr_warn("IBPB-extending microcode not applied!\n");
- pr_warn(SRSO_NOTICE);
- } else {
- /*
- * Enable the synthetic (even if in a real CPUID leaf)
- * flags for guests.
- */
- setup_force_cpu_cap(X86_FEATURE_IBPB_BRTYPE);
- setup_force_cpu_cap(X86_FEATURE_SBPB);
-
- /*
- * Zen1/2 with SMT off aren't vulnerable after the right
- * IBPB microcode has been applied.
- */
- if ((boot_cpu_data.x86 < 0x19) &&
- (cpu_smt_control == CPU_SMT_DISABLED))
- setup_force_cpu_cap(X86_FEATURE_SRSO_NO);
- }
-
- if (retbleed_mitigation == RETBLEED_MITIGATION_IBPB) {
- if (has_microcode) {
- pr_err("Retbleed IBPB mitigation enabled, using same for SRSO\n");
- srso_mitigation = SRSO_MITIGATION_IBPB;
- goto pred_cmd;
- }
- }
-
- switch (srso_cmd) {
- case SRSO_CMD_OFF:
- return;
-
- case SRSO_CMD_MICROCODE:
- if (has_microcode) {
- srso_mitigation = SRSO_MITIGATION_MICROCODE;
- pr_warn(SRSO_NOTICE);
- }
- break;
-
- case SRSO_CMD_SAFE_RET:
- if (IS_ENABLED(CONFIG_CPU_SRSO)) {
- /*
- * Enable the return thunk for generated code
- * like ftrace, static_call, etc.
- */
- setup_force_cpu_cap(X86_FEATURE_RETHUNK);
-
- if (boot_cpu_data.x86 == 0x19) {
- setup_force_cpu_cap(X86_FEATURE_SRSO_ALIAS);
- x86_return_thunk = srso_alias_return_thunk;
- } else {
- setup_force_cpu_cap(X86_FEATURE_SRSO);
- x86_return_thunk = srso_return_thunk;
- }
- srso_mitigation = SRSO_MITIGATION_SAFE_RET;
- } else {
- pr_err("WARNING: kernel not compiled with CPU_SRSO.\n");
- goto pred_cmd;
- }
- break;
-
- case SRSO_CMD_IBPB:
- if (has_microcode) {
- setup_force_cpu_cap(X86_FEATURE_ENTRY_IBPB);
- srso_mitigation = SRSO_MITIGATION_IBPB;
- }
- break;
-
- case SRSO_CMD_IBPB_ON_VMEXIT:
- if (IS_ENABLED(CONFIG_CPU_SRSO)) {
- if (!boot_cpu_has(X86_FEATURE_ENTRY_IBPB) && has_microcode) {
- setup_force_cpu_cap(X86_FEATURE_IBPB_ON_VMEXIT);
- srso_mitigation = SRSO_MITIGATION_IBPB_ON_VMEXIT;
- }
- } else {
- pr_err("WARNING: kernel not compiled with CPU_SRSO.\n");
- goto pred_cmd;
- }
- break;
-
- default:
- break;
- }
-
- pr_info("%s%s\n", srso_strings[srso_mitigation], (has_microcode ? "" : ", no microcode"));
-
-pred_cmd:
- if (boot_cpu_has(X86_FEATURE_SRSO_NO) ||
- srso_cmd == SRSO_CMD_OFF)
- x86_pred_cmd = PRED_CMD_SBPB;
-}
-
-#undef pr_fmt
#define pr_fmt(fmt) fmt
#ifdef CONFIG_SYSFS
@@ -2607,26 +2447,26 @@ static ssize_t srbds_show_state(char *bu
static ssize_t retbleed_show_state(char *buf)
{
if (retbleed_mitigation == RETBLEED_MITIGATION_UNRET ||
+ retbleed_mitigation == RETBLEED_MITIGATION_UNRET_SRSO ||
+ retbleed_mitigation == RETBLEED_MITIGATION_UNRET_SRSO_ALIAS ||
retbleed_mitigation == RETBLEED_MITIGATION_IBPB) {
+
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD &&
boot_cpu_data.x86_vendor != X86_VENDOR_HYGON)
return sysfs_emit(buf, "Vulnerable: untrained return thunk / IBPB on non-AMD based uarch\n");
- return sysfs_emit(buf, "%s; SMT %s\n", retbleed_strings[retbleed_mitigation],
+ return sysfs_emit(buf, "%s; SMT %s%s\n", retbleed_strings[retbleed_mitigation],
!sched_smt_active() ? "disabled" :
spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||
spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED ?
- "enabled with STIBP protection" : "vulnerable");
- }
+ "enabled with STIBP protection" : "vulnerable",
+ cpu_has_ibpb_brtype_microcode() ? "" : ", no SRSO microcode");
- return sysfs_emit(buf, "%s\n", retbleed_strings[retbleed_mitigation]);
-}
+ }
-static ssize_t srso_show_state(char *buf)
-{
- return sysfs_emit(buf, "%s%s\n",
- srso_strings[srso_mitigation],
- (cpu_has_ibpb_brtype_microcode() ? "" : ", no microcode"));
+ return sysfs_emit(buf, "%s%s\n", retbleed_strings[retbleed_mitigation],
+ (boot_cpu_data.x86_vendor != X86_VENDOR_AMD ||
+ cpu_has_ibpb_brtype_microcode()) ? "" : ", no SRSO microcode");
}
static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr,
@@ -2678,9 +2518,6 @@ static ssize_t cpu_show_common(struct de
case X86_BUG_RETBLEED:
return retbleed_show_state(buf);
- case X86_BUG_SRSO:
- return srso_show_state(buf);
-
default:
break;
}
@@ -2745,9 +2582,4 @@ ssize_t cpu_show_retbleed(struct device
{
return cpu_show_common(dev, attr, buf, X86_BUG_RETBLEED);
}
-
-ssize_t cpu_show_spec_rstack_overflow(struct device *dev, struct device_attribute *attr, char *buf)
-{
- return cpu_show_common(dev, attr, buf, X86_BUG_SRSO);
-}
#endif
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -577,12 +577,6 @@ ssize_t __weak cpu_show_retbleed(struct
return sysfs_emit(buf, "Not affected\n");
}
-ssize_t __weak cpu_show_spec_rstack_overflow(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "Not affected\n");
-}
-
static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL);
static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL);
static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL);
@@ -594,7 +588,6 @@ static DEVICE_ATTR(itlb_multihit, 0444,
static DEVICE_ATTR(srbds, 0444, cpu_show_srbds, NULL);
static DEVICE_ATTR(mmio_stale_data, 0444, cpu_show_mmio_stale_data, NULL);
static DEVICE_ATTR(retbleed, 0444, cpu_show_retbleed, NULL);
-static DEVICE_ATTR(spec_rstack_overflow, 0444, cpu_show_spec_rstack_overflow, NULL);
static struct attribute *cpu_root_vulnerabilities_attrs[] = {
&dev_attr_meltdown.attr,
@@ -608,7 +601,6 @@ static struct attribute *cpu_root_vulner
&dev_attr_srbds.attr,
&dev_attr_mmio_stale_data.attr,
&dev_attr_retbleed.attr,
- &dev_attr_spec_rstack_overflow.attr,
NULL
};
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -70,8 +70,6 @@ extern ssize_t cpu_show_mmio_stale_data(
char *buf);
extern ssize_t cpu_show_retbleed(struct device *dev,
struct device_attribute *attr, char *buf);
-extern ssize_t cpu_show_spec_rstack_overflow(struct device *dev,
- struct device_attribute *attr, char *buf);
extern __printf(4, 5)
struct device *cpu_device_create(struct device *parent, void *drvdata,
next prev parent reply other threads:[~2023-08-09 7:27 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 7:12 [RFC][PATCH 00/17] Fix up the recent SRSO patches Peter Zijlstra
2023-08-09 7:12 ` [RFC][PATCH 01/17] x86/alternative: Unconditional custom return thunk Peter Zijlstra
2023-08-09 9:31 ` Nikolay Borisov
2023-08-10 11:37 ` Borislav Petkov
2023-08-09 7:12 ` [RFC][PATCH 02/17] x86/cpu: Clean up SRSO return thunk mess Peter Zijlstra
2023-08-09 15:45 ` Nikolay Borisov
2023-08-10 11:51 ` Borislav Petkov
2023-08-10 12:37 ` Peter Zijlstra
2023-08-10 12:56 ` Borislav Petkov
2023-08-10 13:22 ` Peter Zijlstra
2023-08-11 7:01 ` Peter Zijlstra
2023-08-11 17:00 ` Nick Desaulniers
2023-08-12 11:20 ` Peter Zijlstra
2023-08-09 7:12 ` [RFC][PATCH 03/17] x86/cpu: Make srso_untrain_ret consistent Peter Zijlstra
2023-08-10 12:00 ` Borislav Petkov
2023-08-09 7:12 ` [RFC][PATCH 04/17] objtool/x86: Fix SRSO mess Peter Zijlstra
2023-08-10 12:06 ` Borislav Petkov
2023-08-10 12:48 ` Peter Zijlstra
2023-08-10 12:50 ` Peter Zijlstra
2023-08-10 15:02 ` Borislav Petkov
2023-08-10 15:22 ` Peter Zijlstra
2023-08-09 7:12 ` [RFC][PATCH 05/17] x86/cpu: Cleanup the untrain mess Peter Zijlstra
2023-08-09 12:51 ` Josh Poimboeuf
2023-08-09 13:12 ` Peter Zijlstra
2023-08-09 13:26 ` Peter Zijlstra
2023-08-12 18:30 ` Borislav Petkov
2023-08-09 7:12 ` [RFC][PATCH 06/17] x86/cpu: Add SRSO untrain to retbleed= Peter Zijlstra
2023-08-09 13:42 ` Josh Poimboeuf
2023-08-09 14:06 ` Peter Zijlstra
2023-08-09 14:28 ` Josh Poimboeuf
2023-08-09 15:08 ` Peter Zijlstra
2023-08-09 15:43 ` Josh Poimboeuf
2023-08-09 14:31 ` Andrew.Cooper3
2023-08-09 14:39 ` Josh Poimboeuf
2023-08-10 15:44 ` Borislav Petkov
2023-08-10 16:10 ` Josh Poimboeuf
2023-08-11 10:27 ` Borislav Petkov
2023-08-12 11:32 ` Peter Zijlstra
2023-08-12 12:12 ` Borislav Petkov
2023-08-14 15:45 ` David Laight
2023-08-12 11:24 ` Peter Zijlstra
2023-08-12 12:10 ` Borislav Petkov
2023-08-14 10:56 ` Peter Zijlstra
2023-08-09 7:12 ` [RFC][PATCH 07/17] x86/cpu/kvm: Provide UNTRAIN_RET_VM Peter Zijlstra
2023-08-09 13:50 ` Josh Poimboeuf
2023-08-09 14:06 ` Peter Zijlstra
2023-08-09 14:30 ` Josh Poimboeuf
2023-08-09 15:10 ` Peter Zijlstra
2023-08-13 10:36 ` Borislav Petkov
2023-08-14 10:35 ` Peter Zijlstra
2023-08-09 7:12 ` [RFC][PATCH 08/17] x86/cpu: Add IBPB on VMEXIT to retbleed= Peter Zijlstra
2023-08-09 7:12 ` [RFC][PATCH 09/17] x86: Remove CONFIG_CPU_SRSO Peter Zijlstra
2023-08-09 13:57 ` Josh Poimboeuf
2023-08-09 7:12 ` [RFC][PATCH 10/17] x86: Remove CPU_IBPB_ENTRY Peter Zijlstra
2023-08-09 7:12 ` Peter Zijlstra [this message]
2023-08-09 13:10 ` [RFC][PATCH 11/17] x86/cpu: Remove all SRSO interface nonsense Andrew.Cooper3
2023-08-09 13:36 ` Peter Zijlstra
2023-08-09 14:05 ` Josh Poimboeuf
2023-08-09 14:43 ` Peter Zijlstra
2023-08-09 14:51 ` Josh Poimboeuf
2023-08-09 15:34 ` Josh Poimboeuf
2023-08-09 7:12 ` [RFC][PATCH 12/17] x86/cpu: Rename original retbleed return thunk Peter Zijlstra
2023-08-09 14:20 ` Josh Poimboeuf
2023-08-09 14:22 ` Peter Zijlstra
2023-08-10 11:06 ` Andrew.Cooper3
2023-08-10 13:02 ` Peter Zijlstra
2023-08-13 15:23 ` Andrew.Cooper3
2023-08-14 10:34 ` Peter Zijlstra
2023-08-14 11:31 ` Andrew.Cooper3
2023-08-14 12:06 ` Peter Zijlstra
2023-08-09 7:12 ` [RFC][PATCH 13/17] objtool/x86: Add arch_is_offset_insn() Peter Zijlstra
2023-08-09 9:56 ` Nikolay Borisov
2023-08-09 14:34 ` Josh Poimboeuf
2023-08-09 7:12 ` [RFC][PATCH 14/17] objtool: Add comments to the arch_is_$foo() magic symbols Peter Zijlstra
2023-08-09 7:12 ` [RFC][PATCH 15/17] x86/cpu: Rename srso_(.*)_alias to srso_alias_\1 Peter Zijlstra
2023-08-09 7:12 ` [RFC][PATCH 16/17] x86/alternatives: Simplify ALTERNATIVE_n() Peter Zijlstra
2023-08-09 7:12 ` [RFC][PATCH 17/17] x86/cpu: Use fancy alternatives to get rid of entry_untrain_ret() Peter Zijlstra
2023-08-09 9:04 ` [RFC][PATCH 00/17] Fix up the recent SRSO patches Nikolay Borisov
2023-08-09 10:04 ` Andrew.Cooper3
2023-08-09 11:58 ` Peter Zijlstra
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=20230809072201.192502969@infradead.org \
--to=peterz@infradead.org \
--cc=Andrew.Cooper3@citrix.com \
--cc=David.Kaplan@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@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
Powered by JetHome