Skip to content

Commit 3eebb50

Browse files
committed
x86/bugs: Do not use UNTRAIN_RET with IBPB on entry
JIRA: https://issues.redhat.com/browse/RHEL-88224 commit c62fa11 Author: Johannes Wikner <kwikner@ethz.ch> Date: Tue, 8 Oct 2024 12:58:03 +0200 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 <bp@alien8.de> Signed-off-by: Johannes Wikner <kwikner@ethz.ch> Cc: <stable@kernel.org> Signed-off-by: Waiman Long <longman@redhat.com>
1 parent 8c3307e commit 3eebb50

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

11231123
case RETBLEED_MITIGATION_IBPB:
11241124
setup_force_cpu_cap(X86_FEATURE_ENTRY_IBPB);
1125+
1126+
/*
1127+
* IBPB on entry already obviates the need for
1128+
* software-based untraining so clear those in case some
1129+
* other mitigation like SRSO has selected them.
1130+
*/
1131+
setup_clear_cpu_cap(X86_FEATURE_UNRET);
1132+
setup_clear_cpu_cap(X86_FEATURE_RETHUNK);
1133+
11251134
setup_force_cpu_cap(X86_FEATURE_IBPB_ON_VMEXIT);
11261135
mitigate_smt = true;
11271136

@@ -2720,6 +2729,14 @@ static void __init srso_select_mitigation(void)
27202729
if (has_microcode) {
27212730
setup_force_cpu_cap(X86_FEATURE_ENTRY_IBPB);
27222731
srso_mitigation = SRSO_MITIGATION_IBPB;
2732+
2733+
/*
2734+
* IBPB on entry already obviates the need for
2735+
* software-based untraining so clear those in case some
2736+
* other mitigation like Retbleed has selected them.
2737+
*/
2738+
setup_clear_cpu_cap(X86_FEATURE_UNRET);
2739+
setup_clear_cpu_cap(X86_FEATURE_RETHUNK);
27232740
}
27242741
} else {
27252742
pr_err("WARNING: kernel not compiled with MITIGATION_IBPB_ENTRY.\n");

0 commit comments

Comments
 (0)