Brooklyn/arch/x86/lib/retpoline.S

64 lines
1.6 KiB
ArmAsm
Raw Normal View History

2021-05-26 19:09:36 +00:00
/* SPDX-License-Identifier: GPL-2.0 */
#include <linux/stringify.h>
#include <linux/linkage.h>
#include <asm/dwarf2.h>
#include <asm/cpufeatures.h>
2021-09-23 16:59:15 +00:00
#include <asm/alternative-asm.h>
2021-05-26 19:09:36 +00:00
#include <asm/export.h>
#include <asm/nospec-branch.h>
#include <asm/unwind_hints.h>
#include <asm/frame.h>
2021-09-23 16:59:15 +00:00
.macro THUNK reg
2021-05-26 19:09:36 +00:00
.section .text.__x86.indirect_thunk
2021-09-23 16:59:15 +00:00
.align 32
SYM_FUNC_START(__x86_indirect_thunk_\reg)
JMP_NOSPEC \reg
SYM_FUNC_END(__x86_indirect_thunk_\reg)
SYM_FUNC_START_NOALIGN(__x86_retpoline_\reg)
2021-05-26 19:09:36 +00:00
ANNOTATE_INTRA_FUNCTION_CALL
2021-09-23 16:59:15 +00:00
call .Ldo_rop_\@
2021-05-26 19:09:36 +00:00
.Lspec_trap_\@:
UNWIND_HINT_EMPTY
pause
lfence
2021-09-23 16:59:15 +00:00
jmp .Lspec_trap_\@
2021-05-26 19:09:36 +00:00
.Ldo_rop_\@:
2021-09-23 16:59:15 +00:00
mov %\reg, (%_ASM_SP)
UNWIND_HINT_RET_OFFSET
2021-05-26 19:09:36 +00:00
ret
2021-09-23 16:59:15 +00:00
SYM_FUNC_END(__x86_retpoline_\reg)
2021-05-26 19:09:36 +00:00
.endm
/*
* Despite being an assembler file we can't just use .irp here
* because __KSYM_DEPS__ only uses the C preprocessor and would
* only see one instance of "__x86_indirect_thunk_\reg" rather
* than one per register with the correct names. So we do it
* 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)
2021-09-23 16:59:15 +00:00
#define EXPORT_RETPOLINE(reg) __EXPORT_THUNK(__x86_retpoline_ ## reg)
2021-05-26 19:09:36 +00:00
#undef GEN
#define GEN(reg) THUNK reg
#include <asm/GEN-for-each-reg.h>
#undef GEN
#define GEN(reg) EXPORT_THUNK(reg)
#include <asm/GEN-for-each-reg.h>
#undef GEN
2021-09-23 16:59:15 +00:00
#define GEN(reg) EXPORT_RETPOLINE(reg)
2021-05-26 19:09:36 +00:00
#include <asm/GEN-for-each-reg.h>