Skip to content

Commit 6dd10d9

Browse files
xhackerustcpalmer-dabbelt
authored andcommitted
riscv: extable: consolidate definitions
This is a riscv port of commit 819771c ("arm64: extable: consolidate definitions"). Signed-off-by: Jisheng Zhang <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 9d504f9 commit 6dd10d9

File tree

4 files changed

+37
-10
lines changed

4 files changed

+37
-10
lines changed

arch/riscv/include/asm/asm-extable.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef __ASM_ASM_EXTABLE_H
3+
#define __ASM_ASM_EXTABLE_H
4+
5+
#ifdef __ASSEMBLY__
6+
7+
#define __ASM_EXTABLE_RAW(insn, fixup) \
8+
.pushsection __ex_table, "a"; \
9+
.balign 4; \
10+
.long ((insn) - .); \
11+
.long ((fixup) - .); \
12+
.popsection;
13+
14+
.macro _asm_extable, insn, fixup
15+
__ASM_EXTABLE_RAW(\insn, \fixup)
16+
.endm
17+
18+
#else /* __ASSEMBLY__ */
19+
20+
#include <linux/stringify.h>
21+
22+
#define __ASM_EXTABLE_RAW(insn, fixup) \
23+
".pushsection __ex_table, \"a\"\n" \
24+
".balign 4\n" \
25+
".long ((" insn ") - .)\n" \
26+
".long ((" fixup ") - .)\n" \
27+
".popsection\n"
28+
29+
#define _ASM_EXTABLE(insn, fixup) __ASM_EXTABLE_RAW(#insn, #fixup)
30+
31+
#endif /* __ASSEMBLY__ */
32+
33+
#endif /* __ASM_ASM_EXTABLE_H */

arch/riscv/include/asm/futex.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/uaccess.h>
1212
#include <linux/errno.h>
1313
#include <asm/asm.h>
14+
#include <asm/asm-extable.h>
1415

1516
/* We don't even really need the extable code, but for now keep it simple */
1617
#ifndef CONFIG_MMU

arch/riscv/include/asm/uaccess.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@
88
#ifndef _ASM_RISCV_UACCESS_H
99
#define _ASM_RISCV_UACCESS_H
1010

11+
#include <asm/asm-extable.h>
1112
#include <asm/pgtable.h> /* for TASK_SIZE */
1213

13-
#define _ASM_EXTABLE(from, to) \
14-
" .pushsection __ex_table, \"a\"\n" \
15-
" .balign 4\n" \
16-
" .long (" #from " - .), (" #to " - .)\n" \
17-
" .popsection\n"
18-
1914
/*
2015
* User space memory access functions
2116
*/

arch/riscv/lib/uaccess.S

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#include <linux/linkage.h>
22
#include <asm-generic/export.h>
33
#include <asm/asm.h>
4+
#include <asm/asm-extable.h>
45
#include <asm/csr.h>
56

67
.macro fixup op reg addr lbl
78
100:
89
\op \reg, \addr
9-
.section __ex_table,"a"
10-
.balign 4
11-
.long (100b - .), (\lbl - .)
12-
.previous
10+
_asm_extable 100b, \lbl
1311
.endm
1412

1513
ENTRY(__asm_copy_to_user)

0 commit comments

Comments
 (0)