@@ -11,8 +11,10 @@
#include <asm/asm_defns.h>
+#ifdef CONFIG_SPECULATIVE_HARDEN_BRANCH
/* Don't transform the "ret" further down. */
.purgem ret
+#endif
.macro IND_THUNK_RETPOLINE reg:req
call 2f
@@ -45,7 +47,9 @@ ENTRY(__x86_indirect_thunk_\reg)
__stringify(IND_THUNK_LFENCE \reg), X86_FEATURE_IND_THUNK_LFENCE, \
__stringify(IND_THUNK_JMP \reg), X86_FEATURE_IND_THUNK_JMP
+#ifdef CONFIG_SPECULATIVE_HARDEN_BRANCH
int3 /* Halt straight-line speculation */
+#endif
.size __x86_indirect_thunk_\reg, . - __x86_indirect_thunk_\reg
.type __x86_indirect_thunk_\reg, @function
@@ -51,6 +51,8 @@
INDIRECT_BRANCH jmp \arg
.endm
+#ifdef CONFIG_SPECULATIVE_HARDEN_BRANCH
+
/*
* To guard against speculation past RET, insert a breakpoint insn
* immediately after them.
@@ -66,3 +68,5 @@
.word \operand
.endif
.endm
+
+#endif
Put insertion of INT3 behind CONFIG_SPECULATIVE_HARDEN_BRANCH conditionals. Signed-off-by: Jan Beulich <jbeulich@suse.com> --- v3: New.