Commit b17c2baa authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Borislav Petkov

x86: Prepare inline-asm for straight-line-speculation

Replace all ret/retq instructions with ASM_RET in preparation of
making it more than a single instruction.
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20211204134907.964635458@infradead.org
parent f94909ce
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
#define __ALIGN_STR __stringify(__ALIGN) #define __ALIGN_STR __stringify(__ALIGN)
#endif #endif
#else /* __ASSEMBLY__ */
#define ASM_RET "ret\n\t"
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* _ASM_X86_LINKAGE_H */ #endif /* _ASM_X86_LINKAGE_H */
......
...@@ -671,7 +671,7 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu); ...@@ -671,7 +671,7 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
"call " #func ";" \ "call " #func ";" \
PV_RESTORE_ALL_CALLER_REGS \ PV_RESTORE_ALL_CALLER_REGS \
FRAME_END \ FRAME_END \
"ret;" \ ASM_RET \
".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \ ".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
".popsection") ".popsection")
......
...@@ -48,7 +48,7 @@ asm (".pushsection .text;" ...@@ -48,7 +48,7 @@ asm (".pushsection .text;"
"jne .slowpath;" "jne .slowpath;"
"pop %rdx;" "pop %rdx;"
FRAME_END FRAME_END
"ret;" ASM_RET
".slowpath: " ".slowpath: "
"push %rsi;" "push %rsi;"
"movzbl %al,%esi;" "movzbl %al,%esi;"
...@@ -56,7 +56,7 @@ asm (".pushsection .text;" ...@@ -56,7 +56,7 @@ asm (".pushsection .text;"
"pop %rsi;" "pop %rsi;"
"pop %rdx;" "pop %rdx;"
FRAME_END FRAME_END
"ret;" ASM_RET
".size " PV_UNLOCK ", .-" PV_UNLOCK ";" ".size " PV_UNLOCK ", .-" PV_UNLOCK ";"
".popsection"); ".popsection");
......
...@@ -714,7 +714,7 @@ asm ( ...@@ -714,7 +714,7 @@ asm (
" .type int3_magic, @function\n" " .type int3_magic, @function\n"
"int3_magic:\n" "int3_magic:\n"
" movl $1, (%" _ASM_ARG1 ")\n" " movl $1, (%" _ASM_ARG1 ")\n"
" ret\n" ASM_RET
" .size int3_magic, .-int3_magic\n" " .size int3_magic, .-int3_magic\n"
" .popsection\n" " .popsection\n"
); );
......
...@@ -1051,7 +1051,7 @@ asm( ...@@ -1051,7 +1051,7 @@ asm(
" addl $4, %esp\n" " addl $4, %esp\n"
" popfl\n" " popfl\n"
#endif #endif
" ret\n" ASM_RET
".size __kretprobe_trampoline, .-__kretprobe_trampoline\n" ".size __kretprobe_trampoline, .-__kretprobe_trampoline\n"
); );
NOKPROBE_SYMBOL(__kretprobe_trampoline); NOKPROBE_SYMBOL(__kretprobe_trampoline);
......
...@@ -41,7 +41,7 @@ extern void _paravirt_nop(void); ...@@ -41,7 +41,7 @@ extern void _paravirt_nop(void);
asm (".pushsection .entry.text, \"ax\"\n" asm (".pushsection .entry.text, \"ax\"\n"
".global _paravirt_nop\n" ".global _paravirt_nop\n"
"_paravirt_nop:\n\t" "_paravirt_nop:\n\t"
"ret\n\t" ASM_RET
".size _paravirt_nop, . - _paravirt_nop\n\t" ".size _paravirt_nop, . - _paravirt_nop\n\t"
".type _paravirt_nop, @function\n\t" ".type _paravirt_nop, @function\n\t"
".popsection"); ".popsection");
...@@ -51,7 +51,7 @@ asm (".pushsection .entry.text, \"ax\"\n" ...@@ -51,7 +51,7 @@ asm (".pushsection .entry.text, \"ax\"\n"
".global paravirt_ret0\n" ".global paravirt_ret0\n"
"paravirt_ret0:\n\t" "paravirt_ret0:\n\t"
"xor %" _ASM_AX ", %" _ASM_AX ";\n\t" "xor %" _ASM_AX ", %" _ASM_AX ";\n\t"
"ret\n\t" ASM_RET
".size paravirt_ret0, . - paravirt_ret0\n\t" ".size paravirt_ret0, . - paravirt_ret0\n\t"
".type paravirt_ret0, @function\n\t" ".type paravirt_ret0, @function\n\t"
".popsection"); ".popsection");
......
...@@ -315,7 +315,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop); ...@@ -315,7 +315,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
__FOP_FUNC(#name) __FOP_FUNC(#name)
#define __FOP_RET(name) \ #define __FOP_RET(name) \
"ret \n\t" \ ASM_RET \
".size " name ", .-" name "\n\t" ".size " name ", .-" name "\n\t"
#define FOP_RET(name) \ #define FOP_RET(name) \
...@@ -435,7 +435,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop); ...@@ -435,7 +435,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
__FOP_RET(#op) __FOP_RET(#op)
asm(".pushsection .fixup, \"ax\"\n" asm(".pushsection .fixup, \"ax\"\n"
"kvm_fastop_exception: xor %esi, %esi; ret\n" "kvm_fastop_exception: xor %esi, %esi; " ASM_RET
".popsection"); ".popsection");
FOP_START(setcc) FOP_START(setcc)
......
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include <linux/linkage.h>
#include <linux/error-injection.h> #include <linux/error-injection.h>
#include <linux/kprobes.h> #include <linux/kprobes.h>
...@@ -10,7 +11,7 @@ asm( ...@@ -10,7 +11,7 @@ asm(
".type just_return_func, @function\n" ".type just_return_func, @function\n"
".globl just_return_func\n" ".globl just_return_func\n"
"just_return_func:\n" "just_return_func:\n"
" ret\n" ASM_RET
".size just_return_func, .-just_return_func\n" ".size just_return_func, .-just_return_func\n"
); );
......
...@@ -31,7 +31,7 @@ asm ( ...@@ -31,7 +31,7 @@ asm (
" call my_direct_func1\n" " call my_direct_func1\n"
" leave\n" " leave\n"
" .size my_tramp1, .-my_tramp1\n" " .size my_tramp1, .-my_tramp1\n"
" ret\n" ASM_RET
" .type my_tramp2, @function\n" " .type my_tramp2, @function\n"
" .globl my_tramp2\n" " .globl my_tramp2\n"
" my_tramp2:" " my_tramp2:"
...@@ -39,7 +39,7 @@ asm ( ...@@ -39,7 +39,7 @@ asm (
" movq %rsp, %rbp\n" " movq %rsp, %rbp\n"
" call my_direct_func2\n" " call my_direct_func2\n"
" leave\n" " leave\n"
" ret\n" ASM_RET
" .size my_tramp2, .-my_tramp2\n" " .size my_tramp2, .-my_tramp2\n"
" .popsection\n" " .popsection\n"
); );
......
...@@ -31,7 +31,7 @@ asm ( ...@@ -31,7 +31,7 @@ asm (
" popq %rsi\n" " popq %rsi\n"
" popq %rdi\n" " popq %rdi\n"
" leave\n" " leave\n"
" ret\n" ASM_RET
" .size my_tramp, .-my_tramp\n" " .size my_tramp, .-my_tramp\n"
" .popsection\n" " .popsection\n"
); );
......
...@@ -25,7 +25,7 @@ asm ( ...@@ -25,7 +25,7 @@ asm (
" call my_direct_func\n" " call my_direct_func\n"
" popq %rdi\n" " popq %rdi\n"
" leave\n" " leave\n"
" ret\n" ASM_RET
" .size my_tramp, .-my_tramp\n" " .size my_tramp, .-my_tramp\n"
" .popsection\n" " .popsection\n"
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment