Skip to content

Commit 07a659e

Browse files
dkaplan2bp3tk0v
authored andcommitted
x86/bugs: Add attack vector controls for spectre_v2_user
Use attack vector controls to determine if spectre_v2_user mitigation is required. Signed-off-by: David Kaplan <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/[email protected]
1 parent 9687eb2 commit 07a659e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ static enum spectre_v2_user_cmd __init spectre_v2_parse_user_cmdline(void)
18171817
char arg[20];
18181818
int ret, i;
18191819

1820-
if (cpu_mitigations_off() || !IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V2))
1820+
if (!IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V2))
18211821
return SPECTRE_V2_USER_CMD_NONE;
18221822

18231823
ret = cmdline_find_option(boot_command_line, "spectre_v2_user",
@@ -1855,6 +1855,13 @@ static void __init spectre_v2_user_select_mitigation(void)
18551855
spectre_v2_user_stibp = SPECTRE_V2_USER_STRICT;
18561856
break;
18571857
case SPECTRE_V2_USER_CMD_AUTO:
1858+
if (!should_mitigate_vuln(X86_BUG_SPECTRE_V2_USER))
1859+
break;
1860+
spectre_v2_user_ibpb = SPECTRE_V2_USER_PRCTL;
1861+
if (smt_mitigations == SMT_MITIGATIONS_OFF)
1862+
break;
1863+
spectre_v2_user_stibp = SPECTRE_V2_USER_PRCTL;
1864+
break;
18581865
case SPECTRE_V2_USER_CMD_PRCTL:
18591866
spectre_v2_user_ibpb = SPECTRE_V2_USER_PRCTL;
18601867
spectre_v2_user_stibp = SPECTRE_V2_USER_PRCTL;

0 commit comments

Comments
 (0)