David Woodhouse | 76b0438 | 2018-01-11 21:46:25 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | |
| 3 | #include <linux/stringify.h> |
| 4 | #include <linux/linkage.h> |
| 5 | #include <asm/dwarf2.h> |
| 6 | #include <asm/cpufeatures.h> |
| 7 | #include <asm/alternative-asm.h> |
| 8 | #include <asm/export.h> |
| 9 | #include <asm/nospec-branch.h> |
| 10 | |
| 11 | .macro THUNK reg |
Masami Hiramatsu | 736e80a | 2018-01-19 01:14:21 +0900 | [diff] [blame] | 12 | .section .text.__x86.indirect_thunk |
David Woodhouse | 76b0438 | 2018-01-11 21:46:25 +0000 | [diff] [blame] | 13 | |
Jiri Slaby | 6dcc562 | 2019-10-11 13:51:04 +0200 | [diff] [blame] | 14 | SYM_FUNC_START(__x86_indirect_thunk_\reg) |
David Woodhouse | 76b0438 | 2018-01-11 21:46:25 +0000 | [diff] [blame] | 15 | CFI_STARTPROC |
| 16 | JMP_NOSPEC %\reg |
| 17 | CFI_ENDPROC |
Jiri Slaby | 6dcc562 | 2019-10-11 13:51:04 +0200 | [diff] [blame] | 18 | SYM_FUNC_END(__x86_indirect_thunk_\reg) |
David Woodhouse | 76b0438 | 2018-01-11 21:46:25 +0000 | [diff] [blame] | 19 | .endm |
| 20 | |
| 21 | /* |
| 22 | * Despite being an assembler file we can't just use .irp here |
| 23 | * because __KSYM_DEPS__ only uses the C preprocessor and would |
| 24 | * only see one instance of "__x86_indirect_thunk_\reg" rather |
| 25 | * than one per register with the correct names. So we do it |
| 26 | * the simple and nasty way... |
| 27 | */ |
Masami Hiramatsu | c1804a2 | 2018-01-19 01:14:51 +0900 | [diff] [blame] | 28 | #define __EXPORT_THUNK(sym) _ASM_NOKPROBE(sym); EXPORT_SYMBOL(sym) |
| 29 | #define EXPORT_THUNK(reg) __EXPORT_THUNK(__x86_indirect_thunk_ ## reg) |
David Woodhouse | 76b0438 | 2018-01-11 21:46:25 +0000 | [diff] [blame] | 30 | #define GENERATE_THUNK(reg) THUNK reg ; EXPORT_THUNK(reg) |
| 31 | |
| 32 | GENERATE_THUNK(_ASM_AX) |
| 33 | GENERATE_THUNK(_ASM_BX) |
| 34 | GENERATE_THUNK(_ASM_CX) |
| 35 | GENERATE_THUNK(_ASM_DX) |
| 36 | GENERATE_THUNK(_ASM_SI) |
| 37 | GENERATE_THUNK(_ASM_DI) |
| 38 | GENERATE_THUNK(_ASM_BP) |
David Woodhouse | 76b0438 | 2018-01-11 21:46:25 +0000 | [diff] [blame] | 39 | #ifdef CONFIG_64BIT |
| 40 | GENERATE_THUNK(r8) |
| 41 | GENERATE_THUNK(r9) |
| 42 | GENERATE_THUNK(r10) |
| 43 | GENERATE_THUNK(r11) |
| 44 | GENERATE_THUNK(r12) |
| 45 | GENERATE_THUNK(r13) |
| 46 | GENERATE_THUNK(r14) |
| 47 | GENERATE_THUNK(r15) |
| 48 | #endif |