summaryrefslogtreecommitdiffstats
path: root/arch/riscv/lib
diff options
context:
space:
mode:
authorLuc Van Oostenryck2018-06-09 02:33:51 +0200
committerPalmer Dabbelt2018-06-09 21:34:31 +0200
commit86406d51d3600bfa2b6f86e1e6bfce712bec0d53 (patch)
tree377b5f849722635bc2e919a4a7176da05d7859d0 /arch/riscv/lib
parentriscv: no __user for probe_kernel_address() (diff)
downloadkernel-qcow2-linux-86406d51d3600bfa2b6f86e1e6bfce712bec0d53.tar.gz
kernel-qcow2-linux-86406d51d3600bfa2b6f86e1e6bfce712bec0d53.tar.xz
kernel-qcow2-linux-86406d51d3600bfa2b6f86e1e6bfce712bec0d53.zip
riscv: split the declaration of __copy_user
We use a single __copy_user assembly function to copy memory both from and to userspace. While this works, it triggers sparse errors because we're implicitly casting between the kernel and user address spaces by calling __copy_user. This patch splits the C declaration into a pair of functions, __asm_copy_{to,from}_user, that have sane semantics WRT __user. This split make things fine from sparse's point of view. The assembly implementation keeps a single definition but add a double ENTRY() for it, one for __asm_copy_to_user and another one for __asm_copy_from_user. The result is a spare-safe implementation that pays no performance or code size penalty. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
Diffstat (limited to 'arch/riscv/lib')
-rw-r--r--arch/riscv/lib/uaccess.S6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/riscv/lib/uaccess.S b/arch/riscv/lib/uaccess.S
index 58fb2877c865..f8e6440cad6e 100644
--- a/arch/riscv/lib/uaccess.S
+++ b/arch/riscv/lib/uaccess.S
@@ -13,7 +13,8 @@ _epc:
.previous
.endm
-ENTRY(__copy_user)
+ENTRY(__asm_copy_to_user)
+ENTRY(__asm_copy_from_user)
/* Enable access to user memory */
li t6, SR_SUM
@@ -63,7 +64,8 @@ ENTRY(__copy_user)
addi a0, a0, 1
bltu a1, a3, 5b
j 3b
-ENDPROC(__copy_user)
+ENDPROC(__asm_copy_to_user)
+ENDPROC(__asm_copy_from_user)
ENTRY(__clear_user)