Skip to content

Commit c04670d

Browse files
skttgregkh
authored andcommitted
x86/bugs: Do not use UNTRAIN_RET with IBPB on entry
commit c62fa11 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c42a343 commit c04670d

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
@@ -1113,6 +1113,15 @@ static void __init retbleed_select_mitigation(void)
11131113

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

@@ -2618,6 +2627,14 @@ static void __init srso_select_mitigation(void)
26182627
if (has_microcode) {
26192628
setup_force_cpu_cap(X86_FEATURE_ENTRY_IBPB);
26202629
srso_mitigation = SRSO_MITIGATION_IBPB;
2630+
2631+
/*
2632+
* IBPB on entry already obviates the need for
2633+
* software-based untraining so clear those in case some
2634+
* other mitigation like Retbleed has selected them.
2635+
*/
2636+
setup_clear_cpu_cap(X86_FEATURE_UNRET);
2637+
setup_clear_cpu_cap(X86_FEATURE_RETHUNK);
26212638
}
26222639
} else {
26232640
pr_err("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n");

0 commit comments

Comments
 (0)