Skip to content

Commit f938709

Browse files
skttmehmetb0
authored andcommitted
x86/bugs: Do not use UNTRAIN_RET with IBPB on entry
BugLink: https://bugs.launchpad.net/bugs/2088231 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 <bp@alien8.de> Signed-off-by: Johannes Wikner <kwikner@ethz.ch> Cc: <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Portia Stephens <portia.stephens@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
1 parent 4fcf9a9 commit f938709

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

10931093
case RETBLEED_MITIGATION_IBPB:
10941094
setup_force_cpu_cap(X86_FEATURE_ENTRY_IBPB);
1095+
1096+
/*
1097+
* IBPB on entry already obviates the need for
1098+
* software-based untraining so clear those in case some
1099+
* other mitigation like SRSO has selected them.
1100+
*/
1101+
setup_clear_cpu_cap(X86_FEATURE_UNRET);
1102+
setup_clear_cpu_cap(X86_FEATURE_RETHUNK);
1103+
10951104
mitigate_smt = true;
10961105

10971106
/*
@@ -2599,6 +2608,14 @@ static void __init srso_select_mitigation(void)
25992608
if (has_microcode) {
26002609
setup_force_cpu_cap(X86_FEATURE_ENTRY_IBPB);
26012610
srso_mitigation = SRSO_MITIGATION_IBPB;
2611+
2612+
/*
2613+
* IBPB on entry already obviates the need for
2614+
* software-based untraining so clear those in case some
2615+
* other mitigation like Retbleed has selected them.
2616+
*/
2617+
setup_clear_cpu_cap(X86_FEATURE_UNRET);
2618+
setup_clear_cpu_cap(X86_FEATURE_RETHUNK);
26022619
}
26032620
} else {
26042621
pr_err("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n");

0 commit comments

Comments
 (0)