summaryrefslogtreecommitdiffstats
path: root/arch/riscv/include/asm/asm-extable.h
diff options
context:
space:
mode:
authorJisheng Zhang <jszhang@kernel.org>2021-11-18 19:25:45 +0800
committerPalmer Dabbelt <palmer@rivosinc.com>2022-01-05 17:52:47 -0800
commit6dd10d9166a0c06260e0ac6b1fac454117c8024a (patch)
tree7102788ef5eb73d674726348999476a5559ea216 /arch/riscv/include/asm/asm-extable.h
parent9d504f9aa5c1b76673018da9503e76b351a24b8c (diff)
downloadlinux-6dd10d9166a0c06260e0ac6b1fac454117c8024a.tar.gz
linux-6dd10d9166a0c06260e0ac6b1fac454117c8024a.tar.bz2
linux-6dd10d9166a0c06260e0ac6b1fac454117c8024a.zip
riscv: extable: consolidate definitions
This is a riscv port of commit 819771cc2892 ("arm64: extable: consolidate definitions"). Signed-off-by: Jisheng Zhang <jszhang@kernel.org> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'arch/riscv/include/asm/asm-extable.h')
-rw-r--r--arch/riscv/include/asm/asm-extable.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/arch/riscv/include/asm/asm-extable.h b/arch/riscv/include/asm/asm-extable.h
new file mode 100644
index 000000000000..b790c02dbdda
--- /dev/null
+++ b/arch/riscv/include/asm/asm-extable.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_ASM_EXTABLE_H
+#define __ASM_ASM_EXTABLE_H
+
+#ifdef __ASSEMBLY__
+
+#define __ASM_EXTABLE_RAW(insn, fixup) \
+ .pushsection __ex_table, "a"; \
+ .balign 4; \
+ .long ((insn) - .); \
+ .long ((fixup) - .); \
+ .popsection;
+
+ .macro _asm_extable, insn, fixup
+ __ASM_EXTABLE_RAW(\insn, \fixup)
+ .endm
+
+#else /* __ASSEMBLY__ */
+
+#include <linux/stringify.h>
+
+#define __ASM_EXTABLE_RAW(insn, fixup) \
+ ".pushsection __ex_table, \"a\"\n" \
+ ".balign 4\n" \
+ ".long ((" insn ") - .)\n" \
+ ".long ((" fixup ") - .)\n" \
+ ".popsection\n"
+
+#define _ASM_EXTABLE(insn, fixup) __ASM_EXTABLE_RAW(#insn, #fixup)
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ASM_ASM_EXTABLE_H */