Skip to content

Commit 50e4b3b

Browse files
skttbp3tk0v
authored andcommitted
x86/entry: Have entry_ibpb() invalidate return predictions
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]>
1 parent 3ea87df commit 50e4b3b

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
#include "calling.h"
1416

@@ -19,6 +21,9 @@ SYM_FUNC_START(entry_ibpb)
1921
movl $PRED_CMD_IBPB, %eax
2022
xorl %edx, %edx
2123
wrmsr
24+
25+
/* Make sure IBPB clears return stack preductions too. */
26+
FILL_RETURN_BUFFER %rax, RSB_CLEAR_LOOPS, X86_BUG_IBPB_NO_RET
2227
RET
2328
SYM_FUNC_END(entry_ibpb)
2429
/* For KVM */

0 commit comments

Comments
 (0)