Skip to content

Commit 55ca901

Browse files
jpoimboebp3tk0v
authored andcommitted
x86/srso: Remove 'pred_cmd' label
SBPB is only enabled in two distinct cases: 1) when SRSO has been disabled with srso=off 2) when SRSO has been fixed (in future HW) Simplify the control flow by getting rid of the 'pred_cmd' label and moving the SBPB enablement check to the two corresponding code sites. This makes it more clear when exactly SBPB gets enabled. Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/bb20e8569cfa144def5e6f25e610804bc4974de2.1693889988.git.jpoimboe@kernel.org
1 parent eb54be2 commit 55ca901

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

arch/x86/kernel/cpu/bugs.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,13 +2410,21 @@ static void __init srso_select_mitigation(void)
24102410
{
24112411
bool has_microcode = boot_cpu_has(X86_FEATURE_IBPB_BRTYPE);
24122412

2413-
if (!boot_cpu_has_bug(X86_BUG_SRSO) || cpu_mitigations_off())
2414-
goto pred_cmd;
2413+
if (cpu_mitigations_off())
2414+
return;
2415+
2416+
if (!boot_cpu_has_bug(X86_BUG_SRSO)) {
2417+
if (boot_cpu_has(X86_FEATURE_SBPB))
2418+
x86_pred_cmd = PRED_CMD_SBPB;
2419+
return;
2420+
}
24152421

24162422
if (has_microcode) {
24172423
/*
24182424
* Zen1/2 with SMT off aren't vulnerable after the right
24192425
* IBPB microcode has been applied.
2426+
*
2427+
* Zen1/2 don't have SBPB, no need to try to enable it here.
24202428
*/
24212429
if (boot_cpu_data.x86 < 0x19 && !cpu_smt_possible()) {
24222430
setup_force_cpu_cap(X86_FEATURE_SRSO_NO);
@@ -2439,7 +2447,9 @@ static void __init srso_select_mitigation(void)
24392447

24402448
switch (srso_cmd) {
24412449
case SRSO_CMD_OFF:
2442-
goto pred_cmd;
2450+
if (boot_cpu_has(X86_FEATURE_SBPB))
2451+
x86_pred_cmd = PRED_CMD_SBPB;
2452+
return;
24432453

24442454
case SRSO_CMD_MICROCODE:
24452455
if (has_microcode) {
@@ -2501,11 +2511,6 @@ static void __init srso_select_mitigation(void)
25012511

25022512
out:
25032513
pr_info("%s\n", srso_strings[srso_mitigation]);
2504-
2505-
pred_cmd:
2506-
if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) &&
2507-
boot_cpu_has(X86_FEATURE_SBPB))
2508-
x86_pred_cmd = PRED_CMD_SBPB;
25092514
}
25102515

25112516
#undef pr_fmt

0 commit comments

Comments
 (0)