x86/spec-ctrl: Protect against CALL/JMP straight-line speculation

Some x86 CPUs speculatively execute beyond indirect CALL/JMP instructions.

With CONFIG_INDIRECT_THUNK / Retpolines, indirect CALL/JMP instructions are
converted to direct CALL/JMP's to __x86_indirect_thunk_REG(), leaving just a
handful of indirect JMPs implementing those stubs.

There is no architectrual execution beyond an indirect JMP, so use INT3 as
recommended by vendors to halt speculative execution.  This is shorter than
LFENCE (which would also work fine), but also shows up in logs if we do
unexpected execute them.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Paul Durrant <paul@xen.org>
This commit is contained in:
Andrew Cooper committed 2020-07-01 17:01:24 +01:00
1 parent 23ca7ec0ba
commit 3b7dab93f2
1 file changed
+2
+2
View File
@@ -24,10 +24,12 @@
.macro IND_THUNK_LFENCE reg:req
lfence
jmp *%\reg
int3 /* Halt straight-line speculation */
.endm
.macro IND_THUNK_JMP reg:req
jmp *%\reg
int3 /* Halt straight-line speculation */
.endm
/*
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.