1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2012 ARM Ltd.
6 #include <linux/linkage.h>
8 #include <asm/asm-uaccess.h>
9 #include <asm/assembler.h>
10 #include <asm/cache.h>
13 * Copy to user space from a kernel buffer (alignment handled by the hardware)
20 * x0 - bytes not copied
22 .macro ldrb1 reg, ptr, val
23 ldrb \reg, [\ptr], \val
26 .macro strb1 reg, ptr, val
27 user_ldst 9998f, sttrb, \reg, \ptr, \val
30 .macro ldrh1 reg, ptr, val
31 ldrh \reg, [\ptr], \val
34 .macro strh1 reg, ptr, val
35 user_ldst 9997f, sttrh, \reg, \ptr, \val
38 .macro ldr1 reg, ptr, val
39 ldr \reg, [\ptr], \val
42 .macro str1 reg, ptr, val
43 user_ldst 9997f, sttr, \reg, \ptr, \val
46 .macro ldp1 reg1, reg2, ptr, val
47 ldp \reg1, \reg2, [\ptr], \val
50 .macro stp1 reg1, reg2, ptr, val
51 user_stp 9997f, \reg1, \reg2, \ptr, \val
56 SYM_FUNC_START(__arch_copy_to_user)
59 #include "copy_template.S"
66 // Before being absolutely sure we couldn't copy anything, try harder
68 USER(9998f, sttrb tmp1w, [dst])
70 9998: sub x0, end, dst // bytes not copied
72 SYM_FUNC_END(__arch_copy_to_user)
73 EXPORT_SYMBOL(__arch_copy_to_user)