Skip to content

Commit c62fa11

Browse files
skttbp3tk0v
authored andcommitted
x86/bugs: Do not use UNTRAIN_RET with IBPB on entry
Since X86_FEATURE_ENTRY_IBPB will invalidate all harmful predictions with IBPB, no software-based untraining of returns is needed anymore. Currently, this change affects retbleed and SRSO mitigations so if either of the mitigations is doing IBPB and the other one does the software sequence, the latter is not needed anymore. [ bp: Massage commit message. ] Suggested-by: Borislav Petkov <[email protected]> Signed-off-by: Johannes Wikner <[email protected]> Cc: <[email protected]>
1 parent 0fad287 commit c62fa11

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,15 @@ static void __init retbleed_select_mitigation(void)
11151115

11161116
case RETBLEED_MITIGATION_IBPB:
11171117
setup_force_cpu_cap(X86_FEATURE_ENTRY_IBPB);
1118+
1119+
/*
1120+
* IBPB on entry already obviates the need for
1121+
* software-based untraining so clear those in case some
1122+
* other mitigation like SRSO has selected them.
1123+
*/
1124+
setup_clear_cpu_cap(X86_FEATURE_UNRET);
1125+
setup_clear_cpu_cap(X86_FEATURE_RETHUNK);
1126+
11181127
setup_force_cpu_cap(X86_FEATURE_IBPB_ON_VMEXIT);
11191128
mitigate_smt = true;
11201129

@@ -2635,6 +2644,14 @@ static void __init srso_select_mitigation(void)
26352644
if (has_microcode) {
26362645
setup_force_cpu_cap(X86_FEATURE_ENTRY_IBPB);
26372646
srso_mitigation = SRSO_MITIGATION_IBPB;
2647+
2648+
/*
2649+
* IBPB on entry already obviates the need for
2650+
* software-based untraining so clear those in case some
2651+
* other mitigation like Retbleed has selected them.
2652+
*/
2653+
setup_clear_cpu_cap(X86_FEATURE_UNRET);
2654+
setup_clear_cpu_cap(X86_FEATURE_RETHUNK);
26382655
}
26392656
} else {
26402657
pr_err("WARNING: kernel not compiled with MITIGATION_IBPB_ENTRY.\n");

0 commit comments

Comments
 (0)