blob: dfb2ba91b670dca795100e7de84bf0e57800d7b3 [file] [log] [blame]
David Woodhouse2bb5de42018-01-11 21:46:25 +00001/* 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 Hiramatsu09402d82018-01-19 01:14:21 +090012 .section .text.__x86.indirect_thunk
David Woodhouse2bb5de42018-01-11 21:46:25 +000013
14ENTRY(__x86_indirect_thunk_\reg)
15 CFI_STARTPROC
16 JMP_NOSPEC %\reg
17 CFI_ENDPROC
18ENDPROC(__x86_indirect_thunk_\reg)
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 Hiramatsu36ad6ba2018-01-19 01:14:51 +090028#define __EXPORT_THUNK(sym) _ASM_NOKPROBE(sym); EXPORT_SYMBOL(sym)
29#define EXPORT_THUNK(reg) __EXPORT_THUNK(__x86_indirect_thunk_ ## reg)
David Woodhouse2bb5de42018-01-11 21:46:25 +000030#define GENERATE_THUNK(reg) THUNK reg ; EXPORT_THUNK(reg)
31
32GENERATE_THUNK(_ASM_AX)
33GENERATE_THUNK(_ASM_BX)
34GENERATE_THUNK(_ASM_CX)
35GENERATE_THUNK(_ASM_DX)
36GENERATE_THUNK(_ASM_SI)
37GENERATE_THUNK(_ASM_DI)
38GENERATE_THUNK(_ASM_BP)
39GENERATE_THUNK(_ASM_SP)
40#ifdef CONFIG_64BIT
41GENERATE_THUNK(r8)
42GENERATE_THUNK(r9)
43GENERATE_THUNK(r10)
44GENERATE_THUNK(r11)
45GENERATE_THUNK(r12)
46GENERATE_THUNK(r13)
47GENERATE_THUNK(r14)
48GENERATE_THUNK(r15)
49#endif