2 * Copyright (C) 2012 ARM Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <linux/linkage.h>
19 #include <asm/alternative.h>
20 #include <asm/assembler.h>
21 #include <asm/cache.h>
22 #include <asm/cpufeature.h>
23 #include <asm/sysreg.h>
26 * Copy to user space from a kernel buffer (alignment handled by the hardware)
33 * x0 - bytes not copied
35 .macro ldrb1 ptr, regB, val
36 ldrb \ptr, [\regB], \val
39 .macro strb1 ptr, regB, val
40 USER(9998f, strb \ptr, [\regB], \val)
43 .macro ldrh1 ptr, regB, val
44 ldrh \ptr, [\regB], \val
47 .macro strh1 ptr, regB, val
48 USER(9998f, strh \ptr, [\regB], \val)
51 .macro ldr1 ptr, regB, val
52 ldr \ptr, [\regB], \val
55 .macro str1 ptr, regB, val
56 USER(9998f, str \ptr, [\regB], \val)
59 .macro ldp1 ptr, regB, regC, val
60 ldp \ptr, \regB, [\regC], \val
63 .macro stp1 ptr, regB, regC, val
64 USER(9998f, stp \ptr, \regB, [\regC], \val)
69 ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(0)), ARM64_HAS_PAN, \
72 #include "copy_template.S"
73 ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(1)), ARM64_HAS_PAN, \
77 ENDPROC(__copy_to_user)
81 9998: sub x0, end, dst // bytes not copied