Skip to content

Commit 61211f2

Browse files
skttgregkh
authored andcommitted
x86/entry: Have entry_ibpb() invalidate return predictions
commit 50e4b3b upstream. entry_ibpb() should invalidate all indirect predictions, including return target predictions. Not all IBPB implementations do this, in which case the fallback is RSB filling. Prevent SRSO-style hijacks of return predictions following IBPB, as the return target predictor can be corrupted before the IBPB completes. [ bp: Massage. ] Signed-off-by: Johannes Wikner <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Cc: <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b28d3f4 commit 61211f2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/x86/entry/entry.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <asm/unwind_hints.h>
1010
#include <asm/segment.h>
1111
#include <asm/cache.h>
12+
#include <asm/cpufeatures.h>
13+
#include <asm/nospec-branch.h>
1214

1315
.pushsection .noinstr.text, "ax"
1416

@@ -17,6 +19,9 @@ SYM_FUNC_START(entry_ibpb)
1719
movl $PRED_CMD_IBPB, %eax
1820
xorl %edx, %edx
1921
wrmsr
22+
23+
/* Make sure IBPB clears return stack preductions too. */
24+
FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS, X86_BUG_IBPB_NO_RET
2025
RET
2126
SYM_FUNC_END(entry_ibpb)
2227
/* For KVM */

0 commit comments

Comments
 (0)