OSDN Git Service

riscv: extable: consolidate definitions
authorJisheng Zhang <jszhang@kernel.org>
Thu, 18 Nov 2021 11:25:45 +0000 (19:25 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Thu, 6 Jan 2022 01:52:47 +0000 (17:52 -0800)
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>
arch/riscv/include/asm/asm-extable.h [new file with mode: 0644]
arch/riscv/include/asm/futex.h
arch/riscv/include/asm/uaccess.h
arch/riscv/lib/uaccess.S

diff --git a/arch/riscv/include/asm/asm-extable.h b/arch/riscv/include/asm/asm-extable.h
new file mode 100644 (file)
index 0000000..b790c02
--- /dev/null
@@ -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 */
index 3191574..2e15e8e 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/uaccess.h>
 #include <linux/errno.h>
 #include <asm/asm.h>
+#include <asm/asm-extable.h>
 
 /* We don't even really need the extable code, but for now keep it simple */
 #ifndef CONFIG_MMU
index 0f2c5b9..40e6099 100644 (file)
@@ -8,14 +8,9 @@
 #ifndef _ASM_RISCV_UACCESS_H
 #define _ASM_RISCV_UACCESS_H
 
+#include <asm/asm-extable.h>
 #include <asm/pgtable.h>               /* for TASK_SIZE */
 
-#define _ASM_EXTABLE(from, to)                                         \
-       "       .pushsection    __ex_table, \"a\"\n"                    \
-       "       .balign         4\n"                                    \
-       "       .long           (" #from " - .), (" #to " - .)\n"       \
-       "       .popsection\n"
-
 /*
  * User space memory access functions
  */
index 047f517..8c475f4 100644 (file)
@@ -1,15 +1,13 @@
 #include <linux/linkage.h>
 #include <asm-generic/export.h>
 #include <asm/asm.h>
+#include <asm/asm-extable.h>
 #include <asm/csr.h>
 
        .macro fixup op reg addr lbl
 100:
        \op \reg, \addr
-       .section __ex_table,"a"
-       .balign 4
-       .long (100b - .), (\lbl - .)
-       .previous
+       _asm_extable    100b, \lbl
        .endm
 
 ENTRY(__asm_copy_to_user)