Skip to content

Commit fdf9922

Browse files
dkaplan2bp3tk0v
authored andcommitted
x86/bugs: Add attack vector controls for spectre_v2
Use attack vector controls to determine if spectre_v2 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 ddcd4d3 commit fdf9922

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,8 +2013,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
20132013
int ret, i;
20142014

20152015
cmd = IS_ENABLED(CONFIG_MITIGATION_SPECTRE_V2) ? SPECTRE_V2_CMD_AUTO : SPECTRE_V2_CMD_NONE;
2016-
if (cmdline_find_option_bool(boot_command_line, "nospectre_v2") ||
2017-
cpu_mitigations_off())
2016+
if (cmdline_find_option_bool(boot_command_line, "nospectre_v2"))
20182017
return SPECTRE_V2_CMD_NONE;
20192018

20202019
ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, sizeof(arg));
@@ -2286,8 +2285,11 @@ static void __init spectre_v2_select_mitigation(void)
22862285
case SPECTRE_V2_CMD_NONE:
22872286
return;
22882287

2289-
case SPECTRE_V2_CMD_FORCE:
22902288
case SPECTRE_V2_CMD_AUTO:
2289+
if (!should_mitigate_vuln(X86_BUG_SPECTRE_V2))
2290+
break;
2291+
fallthrough;
2292+
case SPECTRE_V2_CMD_FORCE:
22912293
if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) {
22922294
spectre_v2_enabled = SPECTRE_V2_EIBRS;
22932295
break;
@@ -2341,7 +2343,7 @@ static void __init spectre_v2_update_mitigation(void)
23412343
}
23422344
}
23432345

2344-
if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2) && !cpu_mitigations_off())
2346+
if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
23452347
pr_info("%s\n", spectre_v2_strings[spectre_v2_enabled]);
23462348
}
23472349

0 commit comments

Comments
 (0)