]> xenbits.xensource.com Git - xen.git/commitdiff
x86/spec-ctrl: Protect against CALL/JMP straight-line speculation
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 7 Aug 2020 15:30:35 +0000 (17:30 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 7 Aug 2020 15:30:35 +0000 (17:30 +0200)
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>
master commit: 3b7dab93f2401b08c673244c9ae0f92e08bd03ba
master date: 2020-07-01 17:01:24 +0100

xen/arch/x86/indirect-thunk.S

index 3c17f75c23dc4fa562e857ee92a4f94f312b3466..7392aee127439f35912a53c9a8d4ae8dc0a5e514 100644 (file)
 .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
 
 /*