Skip to content

Commit 9d504f9

Browse files
xhackerustcpalmer-dabbelt
authored andcommitted
riscv: lib: uaccess: fold fixups into body
uaccess functions such __asm_copy_to_user(), __arch_copy_from_user() and __clear_user() place their exception fixups in the `.fixup` section without any clear association with themselves. If we backtrace the fixup code, it will be symbolized as an offset from the nearest prior symbol. Similar as arm64 does, we must move fixups into the body of the functions themselves, after the usual fast-path returns. Signed-off-by: Jisheng Zhang <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 4c2e7ce commit 9d504f9

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

arch/riscv/lib/uaccess.S

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ ENTRY(__asm_copy_from_user)
173173
csrc CSR_STATUS, t6
174174
li a0, 0
175175
ret
176+
177+
/* Exception fixup code */
178+
10:
179+
/* Disable access to user memory */
180+
csrs CSR_STATUS, t6
181+
mv a0, t5
182+
ret
176183
ENDPROC(__asm_copy_to_user)
177184
ENDPROC(__asm_copy_from_user)
178185
EXPORT_SYMBOL(__asm_copy_to_user)
@@ -218,19 +225,12 @@ ENTRY(__clear_user)
218225
addi a0, a0, 1
219226
bltu a0, a3, 5b
220227
j 3b
221-
ENDPROC(__clear_user)
222-
EXPORT_SYMBOL(__clear_user)
223228

224-
.section .fixup,"ax"
225-
.balign 4
226-
/* Fixup code for __copy_user(10) and __clear_user(11) */
227-
10:
228-
/* Disable access to user memory */
229-
csrs CSR_STATUS, t6
230-
mv a0, t5
231-
ret
229+
/* Exception fixup code */
232230
11:
231+
/* Disable access to user memory */
233232
csrs CSR_STATUS, t6
234233
mv a0, a1
235234
ret
236-
.previous
235+
ENDPROC(__clear_user)
236+
EXPORT_SYMBOL(__clear_user)

0 commit comments

Comments
 (0)