Skip to content

Commit f8f2ad0

Browse files
xhackerustcpalmer-dabbelt
authored andcommitted
riscv: consolidate __ex_table construction
Consolidate all the __ex_table constuction code with a _ASM_EXTABLE helper. There should be no functional change as a result of this patch. Signed-off-by: Jisheng Zhang <jszhang@kernel.org> Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent ddad0b8 commit f8f2ad0

2 files changed

Lines changed: 15 additions & 27 deletions

File tree

‎arch/riscv/include/asm/futex.h‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@
3030
"3: li %[r],%[e] \n" \
3131
" jump 2b,%[t] \n" \
3232
" .previous \n" \
33-
" .section __ex_table,\"a\" \n" \
34-
" .balign " RISCV_SZPTR " \n" \
35-
" " RISCV_PTR " 1b, 3b \n" \
36-
" .previous \n" \
33+
_ASM_EXTABLE(1b, 3b) \
3734
: [r] "+r" (ret), [ov] "=&r" (oldval), \
3835
[u] "+m" (*uaddr), [t] "=&r" (tmp) \
3936
: [op] "Jr" (oparg), [e] "i" (-EFAULT) \
@@ -103,11 +100,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
103100
"4: li %[r],%[e] \n"
104101
" jump 3b,%[t] \n"
105102
" .previous \n"
106-
" .section __ex_table,\"a\" \n"
107-
" .balign " RISCV_SZPTR " \n"
108-
" " RISCV_PTR " 1b, 4b \n"
109-
" " RISCV_PTR " 2b, 4b \n"
110-
" .previous \n"
103+
_ASM_EXTABLE(1b, 4b) \
104+
_ASM_EXTABLE(2b, 4b) \
111105
: [r] "+r" (ret), [v] "=&r" (val), [u] "+m" (*uaddr), [t] "=&r" (tmp)
112106
: [ov] "Jr" (oldval), [nv] "Jr" (newval), [e] "i" (-EFAULT)
113107
: "memory");

‎arch/riscv/include/asm/uaccess.h‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
#include <asm/pgtable.h> /* for TASK_SIZE */
1212

13+
#define _ASM_EXTABLE(from, to) \
14+
" .pushsection __ex_table, \"a\"\n" \
15+
" .balign " RISCV_SZPTR " \n" \
16+
" " RISCV_PTR "(" #from "), (" #to ")\n" \
17+
" .popsection\n"
18+
1319
/*
1420
* User space memory access functions
1521
*/
@@ -93,10 +99,7 @@ do { \
9399
" li %1, 0\n" \
94100
" jump 2b, %2\n" \
95101
" .previous\n" \
96-
" .section __ex_table,\"a\"\n" \
97-
" .balign " RISCV_SZPTR "\n" \
98-
" " RISCV_PTR " 1b, 3b\n" \
99-
" .previous" \
102+
_ASM_EXTABLE(1b, 3b) \
100103
: "+r" (err), "=&r" (__x), "=r" (__tmp) \
101104
: "m" (*(ptr)), "i" (-EFAULT)); \
102105
(x) = __x; \
@@ -125,11 +128,8 @@ do { \
125128
" li %2, 0\n" \
126129
" jump 3b, %3\n" \
127130
" .previous\n" \
128-
" .section __ex_table,\"a\"\n" \
129-
" .balign " RISCV_SZPTR "\n" \
130-
" " RISCV_PTR " 1b, 4b\n" \
131-
" " RISCV_PTR " 2b, 4b\n" \
132-
" .previous" \
131+
_ASM_EXTABLE(1b, 4b) \
132+
_ASM_EXTABLE(2b, 4b) \
133133
: "+r" (err), "=&r" (__lo), "=r" (__hi), \
134134
"=r" (__tmp) \
135135
: "m" (__ptr[__LSW]), "m" (__ptr[__MSW]), \
@@ -233,10 +233,7 @@ do { \
233233
" li %0, %4\n" \
234234
" jump 2b, %1\n" \
235235
" .previous\n" \
236-
" .section __ex_table,\"a\"\n" \
237-
" .balign " RISCV_SZPTR "\n" \
238-
" " RISCV_PTR " 1b, 3b\n" \
239-
" .previous" \
236+
_ASM_EXTABLE(1b, 3b) \
240237
: "+r" (err), "=r" (__tmp), "=m" (*(ptr)) \
241238
: "rJ" (__x), "i" (-EFAULT)); \
242239
} while (0)
@@ -262,11 +259,8 @@ do { \
262259
" li %0, %6\n" \
263260
" jump 3b, %1\n" \
264261
" .previous\n" \
265-
" .section __ex_table,\"a\"\n" \
266-
" .balign " RISCV_SZPTR "\n" \
267-
" " RISCV_PTR " 1b, 4b\n" \
268-
" " RISCV_PTR " 2b, 4b\n" \
269-
" .previous" \
262+
_ASM_EXTABLE(1b, 4b) \
263+
_ASM_EXTABLE(2b, 4b) \
270264
: "+r" (err), "=r" (__tmp), \
271265
"=m" (__ptr[__LSW]), \
272266
"=m" (__ptr[__MSW]) \

0 commit comments

Comments
 (0)