2 * Copy from user space to user space
4 * Copyright (C) 2012 ARM Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <linux/linkage.h>
21 #include <asm/alternative.h>
22 #include <asm/assembler.h>
23 #include <asm/cpufeature.h>
24 #include <asm/sysreg.h>
27 * Copy from user space to user space (alignment handled by the hardware)
34 * x0 - bytes not copied
37 ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(0)), ARM64_HAS_PAN, \
39 add x5, x0, x2 // upper user buffer boundary
43 USER(9f, ldp x3, x4, [x1], #16)
45 USER(9f, stp x3, x4, [x0], #16)
49 USER(9f, ldr x3, [x1], #8 )
51 USER(9f, str x3, [x0], #8 )
54 USER(9f, ldr w3, [x1], #4 )
56 USER(9f, str w3, [x0], #4 )
59 USER(9f, ldrh w3, [x1], #2 )
61 USER(9f, strh w3, [x0], #2 )
64 USER(9f, ldrb w3, [x1] )
65 USER(9f, strb w3, [x0] )
67 ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(1)), ARM64_HAS_PAN, \
70 ENDPROC(__copy_in_user)
74 9: sub x0, x5, x0 // bytes not copied