Skip to content

Commit ff54ae7

Browse files
dkaplan2Ingo Molnar
authored andcommitted
x86/bugs: Use IBPB for retbleed if used by SRSO
If spec_rstack_overflow=ibpb then this mitigates retbleed as well. This is relevant for AMD Zen1 and Zen2 CPUs which are vulnerable to both bugs. Signed-off-by: David Kaplan <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Borislav Petkov (AMD) <[email protected]> Cc: H . Peter Anvin <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Pawan Gupta <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1fd5eb0 commit ff54ae7

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,21 @@ static enum retbleed_mitigation retbleed_mitigation __ro_after_init =
11711171

11721172
static int __ro_after_init retbleed_nosmt = false;
11731173

1174+
enum srso_mitigation {
1175+
SRSO_MITIGATION_NONE,
1176+
SRSO_MITIGATION_AUTO,
1177+
SRSO_MITIGATION_UCODE_NEEDED,
1178+
SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED,
1179+
SRSO_MITIGATION_MICROCODE,
1180+
SRSO_MITIGATION_NOSMT,
1181+
SRSO_MITIGATION_SAFE_RET,
1182+
SRSO_MITIGATION_IBPB,
1183+
SRSO_MITIGATION_IBPB_ON_VMEXIT,
1184+
SRSO_MITIGATION_BP_SPEC_REDUCE,
1185+
};
1186+
1187+
static enum srso_mitigation srso_mitigation __ro_after_init = SRSO_MITIGATION_AUTO;
1188+
11741189
static int __init retbleed_parse_cmdline(char *str)
11751190
{
11761191
if (!str)
@@ -1280,6 +1295,10 @@ static void __init retbleed_update_mitigation(void)
12801295
if (its_mitigation == ITS_MITIGATION_RETPOLINE_STUFF)
12811296
retbleed_mitigation = RETBLEED_MITIGATION_STUFF;
12821297

1298+
/* If SRSO is using IBPB, that works for retbleed too */
1299+
if (srso_mitigation == SRSO_MITIGATION_IBPB)
1300+
retbleed_mitigation = RETBLEED_MITIGATION_IBPB;
1301+
12831302
if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF &&
12841303
!cdt_possible(spectre_v2_enabled)) {
12851304
pr_err("WARNING: retbleed=stuff depends on retpoline\n");
@@ -2845,19 +2864,6 @@ early_param("l1tf", l1tf_cmdline);
28452864
#undef pr_fmt
28462865
#define pr_fmt(fmt) "Speculative Return Stack Overflow: " fmt
28472866

2848-
enum srso_mitigation {
2849-
SRSO_MITIGATION_NONE,
2850-
SRSO_MITIGATION_AUTO,
2851-
SRSO_MITIGATION_UCODE_NEEDED,
2852-
SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED,
2853-
SRSO_MITIGATION_MICROCODE,
2854-
SRSO_MITIGATION_NOSMT,
2855-
SRSO_MITIGATION_SAFE_RET,
2856-
SRSO_MITIGATION_IBPB,
2857-
SRSO_MITIGATION_IBPB_ON_VMEXIT,
2858-
SRSO_MITIGATION_BP_SPEC_REDUCE,
2859-
};
2860-
28612867
static const char * const srso_strings[] = {
28622868
[SRSO_MITIGATION_NONE] = "Vulnerable",
28632869
[SRSO_MITIGATION_UCODE_NEEDED] = "Vulnerable: No microcode",
@@ -2870,8 +2876,6 @@ static const char * const srso_strings[] = {
28702876
[SRSO_MITIGATION_BP_SPEC_REDUCE] = "Mitigation: Reduced Speculation"
28712877
};
28722878

2873-
static enum srso_mitigation srso_mitigation __ro_after_init = SRSO_MITIGATION_AUTO;
2874-
28752879
static int __init srso_parse_cmdline(char *str)
28762880
{
28772881
if (!str)

0 commit comments

Comments
 (0)