History

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.

Peter Zijlstra committed 4 years ago

Commit b17c2ba1 parent f94909c11 files · +19 −14Browse files

Unified · Split

11 files
  1. arch/x86/include/asm/linkage.h +4 −0
  2. arch/x86/include/asm/paravirt.h +1 −1
  3. arch/x86/include/asm/qspinlock_paravirt.h +2 −2
  4. arch/x86/kernel/alternative.c +1 −1
  5. arch/x86/kernel/kprobes/core.c +1 −1
  6. arch/x86/kernel/paravirt.c +2 −2
  7. arch/x86/kvm/emulate.c +2 −2
  8. arch/x86/lib/error-inject.c +2 −1
  9. samples/ftrace/ftrace-direct-modify.c +2 −2
  10. samples/ftrace/ftrace-direct-too.c +1 −1
  11. samples/ftrace/ftrace-direct.c +1 −1
arch/x86/include/asm/linkage.h+4−0
@@ -18,6 +18,10 @@ · 17 unmodified lines
1818 #define __ALIGN_STR __stringify(__ALIGN)
1919 #endif
2020
21+#else /* __ASSEMBLY__ */
22+
23+#define ASM_RET "ret\n\t"
24+
2125 #endif /* __ASSEMBLY__ */
2226
2327 #endif /* _ASM_X86_LINKAGE_H */
arch/x86/include/asm/paravirt.h+1−1
@@ -671,7 +671,7 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu); · 670 unmodified lines
671671 "call " #func ";" \
672672 PV_RESTORE_ALL_CALLER_REGS \
673673 FRAME_END \
674− "ret;" \
674+ ASM_RET \
675675 ".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
676676 ".popsection")
677677
arch/x86/include/asm/qspinlock_paravirt.h+2−2
@@ -48,7 +48,7 @@ asm (".pushsection .text;" · 47 unmodified lines
4848 "jne .slowpath;"
4949 "pop %rdx;"
5050 FRAME_END
51− "ret;"
51+ ASM_RET
5252 ".slowpath: "
5353 "push %rsi;"
5454 "movzbl %al,%esi;"
@@ -56,7 +56,7 @@ asm (".pushsection .text;" · 1 unmodified line
5656 "pop %rsi;"
5757 "pop %rdx;"
5858 FRAME_END
59− "ret;"
59+ ASM_RET
6060 ".size " PV_UNLOCK ", .-" PV_UNLOCK ";"
6161 ".popsection");
6262
arch/x86/kernel/alternative.c+1−1
@@ -714,7 +714,7 @@ asm ( · 713 unmodified lines
714714 " .type int3_magic, @function\n"
715715 "int3_magic:\n"
716716 " movl $1, (%" _ASM_ARG1 ")\n"
717−" ret\n"
717+ ASM_RET
718718 " .size int3_magic, .-int3_magic\n"
719719 " .popsection\n"
720720 );
arch/x86/kernel/kprobes/core.c+1−1
@@ -1051,7 +1051,7 @@ asm( · 1050 unmodified lines
10511051 " addl $4, %esp\n"
10521052 " popfl\n"
10531053 #endif
1054− " ret\n"
1054+ ASM_RET
10551055 ".size __kretprobe_trampoline, .-__kretprobe_trampoline\n"
10561056 );
10571057 NOKPROBE_SYMBOL(__kretprobe_trampoline);
arch/x86/kernel/paravirt.c+2−2
@@ -41,7 +41,7 @@ extern void _paravirt_nop(void); · 40 unmodified lines
4141 asm (".pushsection .entry.text, \"ax\"\n"
4242 ".global _paravirt_nop\n"
4343 "_paravirt_nop:\n\t"
44− "ret\n\t"
44+ ASM_RET
4545 ".size _paravirt_nop, . - _paravirt_nop\n\t"
4646 ".type _paravirt_nop, @function\n\t"
4747 ".popsection");
@@ -51,7 +51,7 @@ asm (".pushsection .entry.text, \"ax\"\n" · 3 unmodified lines
5151 ".global paravirt_ret0\n"
5252 "paravirt_ret0:\n\t"
5353 "xor %" _ASM_AX ", %" _ASM_AX ";\n\t"
54− "ret\n\t"
54+ ASM_RET
5555 ".size paravirt_ret0, . - paravirt_ret0\n\t"
5656 ".type paravirt_ret0, @function\n\t"
5757 ".popsection");
arch/x86/kvm/emulate.c+2−2
@@ -315,7 +315,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop); · 314 unmodified lines
315315 __FOP_FUNC(#name)
316316
317317 #define __FOP_RET(name) \
318− "ret \n\t" \
318+ ASM_RET \
319319 ".size " name ", .-" name "\n\t"
320320
321321 #define FOP_RET(name) \
@@ -435,7 +435,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop); · 113 unmodified lines
435435 __FOP_RET(#op)
436436
437437 asm(".pushsection .fixup, \"ax\"\n"
438− "kvm_fastop_exception: xor %esi, %esi; ret\n"
438+ "kvm_fastop_exception: xor %esi, %esi; " ASM_RET
439439 ".popsection");
440440
441441 FOP_START(setcc)
arch/x86/lib/error-inject.c+2−1
@@ -1,5 +1,6 @@
11 // SPDX-License-Identifier: GPL-2.0
22
3+#include <linux/linkage.h>
34 #include <linux/error-injection.h>
45 #include <linux/kprobes.h>
56
@@ -10,7 +11,7 @@ asm( · 4 unmodified lines
1011 ".type just_return_func, @function\n"
1112 ".globl just_return_func\n"
1213 "just_return_func:\n"
13− " ret\n"
14+ ASM_RET
1415 ".size just_return_func, .-just_return_func\n"
1516 );
1617
samples/ftrace/ftrace-direct-modify.c+2−2
@@ -31,7 +31,7 @@ asm ( · 30 unmodified lines
3131 " call my_direct_func1\n"
3232 " leave\n"
3333 " .size my_tramp1, .-my_tramp1\n"
34−" ret\n"
34+ ASM_RET
3535 " .type my_tramp2, @function\n"
3636 " .globl my_tramp2\n"
3737 " my_tramp2:"
@@ -39,7 +39,7 @@ asm ( · 1 unmodified line
3939 " movq %rsp, %rbp\n"
4040 " call my_direct_func2\n"
4141 " leave\n"
42−" ret\n"
42+ ASM_RET
4343 " .size my_tramp2, .-my_tramp2\n"
4444 " .popsection\n"
4545 );
samples/ftrace/ftrace-direct-too.c+1−1
@@ -31,7 +31,7 @@ asm ( · 30 unmodified lines
3131 " popq %rsi\n"
3232 " popq %rdi\n"
3333 " leave\n"
34−" ret\n"
34+ ASM_RET
3535 " .size my_tramp, .-my_tramp\n"
3636 " .popsection\n"
3737 );
samples/ftrace/ftrace-direct.c+1−1
@@ -25,7 +25,7 @@ asm ( · 24 unmodified lines
2525 " call my_direct_func\n"
2626 " popq %rdi\n"
2727 " leave\n"
28−" ret\n"
28+ ASM_RET
2929 " .size my_tramp, .-my_tramp\n"
3030 " .popsection\n"
3131 );

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t