xref: /openbmc/linux/arch/riscv/include/asm/asm-extable.h (revision 2bf847db0c7437c28b10fba2981b9a7db4b4e0e2)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef __ASM_ASM_EXTABLE_H
3 #define __ASM_ASM_EXTABLE_H
4 
5 #define EX_TYPE_NONE			0
6 #define EX_TYPE_FIXUP			1
7 #define EX_TYPE_BPF			2
8 
9 #ifdef __ASSEMBLY__
10 
11 #define __ASM_EXTABLE_RAW(insn, fixup, type, data)	\
12 	.pushsection	__ex_table, "a";		\
13 	.balign		4;				\
14 	.long		((insn) - .);			\
15 	.long		((fixup) - .);			\
16 	.short		(type);				\
17 	.short		(data);				\
18 	.popsection;
19 
20 	.macro		_asm_extable, insn, fixup
21 	__ASM_EXTABLE_RAW(\insn, \fixup, EX_TYPE_FIXUP, 0)
22 	.endm
23 
24 #else /* __ASSEMBLY__ */
25 
26 #include <linux/stringify.h>
27 
28 #define __ASM_EXTABLE_RAW(insn, fixup, type, data)	\
29 	".pushsection	__ex_table, \"a\"\n"		\
30 	".balign	4\n"				\
31 	".long		((" insn ") - .)\n"		\
32 	".long		((" fixup ") - .)\n"		\
33 	".short		(" type ")\n"			\
34 	".short		(" data ")\n"			\
35 	".popsection\n"
36 
37 #define _ASM_EXTABLE(insn, fixup)	\
38 	__ASM_EXTABLE_RAW(#insn, #fixup, __stringify(EX_TYPE_FIXUP), "0")
39 
40 #endif /* __ASSEMBLY__ */
41 
42 #endif /* __ASM_ASM_EXTABLE_H */
43