x86: Simplify retpoline declaration

Because of how KSYM works, we need one declaration per line. Seeing
how we're going to be doubling the amount of retpoline symbols,
simplify the machinery in order to avoid having to copy/paste even
more.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20200428191700.091696925@infradead.org
This commit is contained in:
Peter Zijlstra 2020-04-22 17:03:22 +02:00
parent 089dd8e531
commit ca3f0d80dd
3 changed files with 48 additions and 40 deletions

View File

@ -0,0 +1,25 @@
#ifdef CONFIG_64BIT
GEN(rax)
GEN(rbx)
GEN(rcx)
GEN(rdx)
GEN(rsi)
GEN(rdi)
GEN(rbp)
GEN(r8)
GEN(r9)
GEN(r10)
GEN(r11)
GEN(r12)
GEN(r13)
GEN(r14)
GEN(r15)
#else
GEN(eax)
GEN(ebx)
GEN(ecx)
GEN(edx)
GEN(esi)
GEN(edi)
GEN(ebp)
#endif

View File

@ -17,24 +17,12 @@ extern void cmpxchg8b_emu(void);
#endif #endif
#ifdef CONFIG_RETPOLINE #ifdef CONFIG_RETPOLINE
#ifdef CONFIG_X86_32
#define INDIRECT_THUNK(reg) extern asmlinkage void __x86_indirect_thunk_e ## reg(void); #define DECL_INDIRECT_THUNK(reg) \
#else extern asmlinkage void __x86_indirect_thunk_ ## reg (void);
#define INDIRECT_THUNK(reg) extern asmlinkage void __x86_indirect_thunk_r ## reg(void);
INDIRECT_THUNK(8) #undef GEN
INDIRECT_THUNK(9) #define GEN(reg) DECL_INDIRECT_THUNK(reg)
INDIRECT_THUNK(10) #include <asm/GEN-for-each-reg.h>
INDIRECT_THUNK(11)
INDIRECT_THUNK(12)
INDIRECT_THUNK(13)
INDIRECT_THUNK(14)
INDIRECT_THUNK(15)
#endif
INDIRECT_THUNK(ax)
INDIRECT_THUNK(bx)
INDIRECT_THUNK(cx)
INDIRECT_THUNK(dx)
INDIRECT_THUNK(si)
INDIRECT_THUNK(di)
INDIRECT_THUNK(bp)
#endif /* CONFIG_RETPOLINE */ #endif /* CONFIG_RETPOLINE */

View File

@ -24,25 +24,20 @@ SYM_FUNC_END(__x86_indirect_thunk_\reg)
* only see one instance of "__x86_indirect_thunk_\reg" rather * only see one instance of "__x86_indirect_thunk_\reg" rather
* than one per register with the correct names. So we do it * than one per register with the correct names. So we do it
* the simple and nasty way... * the simple and nasty way...
*
* Worse, you can only have a single EXPORT_SYMBOL per line,
* and CPP can't insert newlines, so we have to repeat everything
* at least twice.
*/ */
#define __EXPORT_THUNK(sym) _ASM_NOKPROBE(sym); EXPORT_SYMBOL(sym)
#define EXPORT_THUNK(reg) __EXPORT_THUNK(__x86_indirect_thunk_ ## reg)
#define GENERATE_THUNK(reg) THUNK reg ; EXPORT_THUNK(reg)
GENERATE_THUNK(_ASM_AX) #define __EXPORT_THUNK(sym) _ASM_NOKPROBE(sym); EXPORT_SYMBOL(sym)
GENERATE_THUNK(_ASM_BX) #define EXPORT_THUNK(reg) __EXPORT_THUNK(__x86_indirect_thunk_ ## reg)
GENERATE_THUNK(_ASM_CX)
GENERATE_THUNK(_ASM_DX) #undef GEN
GENERATE_THUNK(_ASM_SI) #define GEN(reg) THUNK reg
GENERATE_THUNK(_ASM_DI) #include <asm/GEN-for-each-reg.h>
GENERATE_THUNK(_ASM_BP)
#ifdef CONFIG_64BIT #undef GEN
GENERATE_THUNK(r8) #define GEN(reg) EXPORT_THUNK(reg)
GENERATE_THUNK(r9) #include <asm/GEN-for-each-reg.h>
GENERATE_THUNK(r10)
GENERATE_THUNK(r11)
GENERATE_THUNK(r12)
GENERATE_THUNK(r13)
GENERATE_THUNK(r14)
GENERATE_THUNK(r15)
#endif