riscv: lib: uaccess: fold fixups into body
authorJisheng Zhang <jszhang@kernel.org>
Thu, 18 Nov 2021 11:25:14 +0000 (19:25 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Thu, 6 Jan 2022 01:52:39 +0000 (17:52 -0800)
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 <jszhang@kernel.org>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/lib/uaccess.S

index 55f80f84e23fbb077ab34442d8ed6ce76a3aa72a..047f517ac780e89d8cbcd5658edd9588f6902507 100644 (file)
@@ -173,6 +173,13 @@ ENTRY(__asm_copy_from_user)
        csrc CSR_STATUS, t6
        li      a0, 0
        ret
+
+       /* Exception fixup code */
+10:
+       /* Disable access to user memory */
+       csrs CSR_STATUS, t6
+       mv a0, t5
+       ret
 ENDPROC(__asm_copy_to_user)
 ENDPROC(__asm_copy_from_user)
 EXPORT_SYMBOL(__asm_copy_to_user)
@@ -218,19 +225,12 @@ ENTRY(__clear_user)
        addi a0, a0, 1
        bltu a0, a3, 5b
        j 3b
-ENDPROC(__clear_user)
-EXPORT_SYMBOL(__clear_user)
 
-       .section .fixup,"ax"
-       .balign 4
-       /* Fixup code for __copy_user(10) and __clear_user(11) */
-10:
-       /* Disable access to user memory */
-       csrs CSR_STATUS, t6
-       mv a0, t5
-       ret
+       /* Exception fixup code */
 11:
+       /* Disable access to user memory */
        csrs CSR_STATUS, t6
        mv a0, a1
        ret
-       .previous
+ENDPROC(__clear_user)
+EXPORT_SYMBOL(__clear_user)