Commit | Line | Data |
---|---|---|
0aea86a2 CM |
1 | /* |
2 | * Copyright (C) 2012 ARM Ltd. | |
3 | * | |
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. | |
7 | * | |
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. | |
12 | * | |
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/>. | |
15 | */ | |
16 | ||
17 | #include <linux/linkage.h> | |
338d4f49 JM |
18 | |
19 | #include <asm/alternative.h> | |
0aea86a2 | 20 | #include <asm/assembler.h> |
40426882 | 21 | #include <asm/cache.h> |
338d4f49 JM |
22 | #include <asm/cpufeature.h> |
23 | #include <asm/sysreg.h> | |
0aea86a2 CM |
24 | |
25 | /* | |
26 | * Copy from user space to a kernel buffer (alignment handled by the hardware) | |
27 | * | |
28 | * Parameters: | |
29 | * x0 - to | |
30 | * x1 - from | |
31 | * x2 - n | |
32 | * Returns: | |
33 | * x0 - bytes not copied | |
34 | */ | |
40426882 FK |
35 | |
36 | .macro ldrb1 ptr, regB, val | |
57f4959b | 37 | uao_user_alternative 9998f, ldrb, ldtrb, \ptr, \regB, \val |
40426882 FK |
38 | .endm |
39 | ||
40 | .macro strb1 ptr, regB, val | |
41 | strb \ptr, [\regB], \val | |
42 | .endm | |
43 | ||
44 | .macro ldrh1 ptr, regB, val | |
57f4959b | 45 | uao_user_alternative 9998f, ldrh, ldtrh, \ptr, \regB, \val |
40426882 FK |
46 | .endm |
47 | ||
48 | .macro strh1 ptr, regB, val | |
49 | strh \ptr, [\regB], \val | |
50 | .endm | |
51 | ||
52 | .macro ldr1 ptr, regB, val | |
57f4959b | 53 | uao_user_alternative 9998f, ldr, ldtr, \ptr, \regB, \val |
40426882 FK |
54 | .endm |
55 | ||
56 | .macro str1 ptr, regB, val | |
57 | str \ptr, [\regB], \val | |
58 | .endm | |
59 | ||
60 | .macro ldp1 ptr, regB, regC, val | |
57f4959b | 61 | uao_ldp 9998f, \ptr, \regB, \regC, \val |
40426882 FK |
62 | .endm |
63 | ||
64 | .macro stp1 ptr, regB, regC, val | |
65 | stp \ptr, \regB, [\regC], \val | |
66 | .endm | |
67 | ||
68 | end .req x5 | |
bffe1baf | 69 | ENTRY(__arch_copy_from_user) |
70544196 | 70 | ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(0)), ARM64_ALT_PAN_NOT_UAO, \ |
338d4f49 | 71 | CONFIG_ARM64_PAN) |
40426882 FK |
72 | add end, x0, x2 |
73 | #include "copy_template.S" | |
70544196 | 74 | ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(1)), ARM64_ALT_PAN_NOT_UAO, \ |
338d4f49 | 75 | CONFIG_ARM64_PAN) |
40426882 | 76 | mov x0, #0 // Nothing to copy |
0aea86a2 | 77 | ret |
bffe1baf | 78 | ENDPROC(__arch_copy_from_user) |
0aea86a2 CM |
79 | |
80 | .section .fixup,"ax" | |
81 | .align 2 | |
40426882 FK |
82 | 9998: |
83 | sub x0, end, dst | |
84 | 9999: | |
85 | strb wzr, [dst], #1 // zero remaining buffer space | |
86 | cmp dst, end | |
87 | b.lo 9999b | |
0aea86a2 CM |
88 | ret |
89 | .previous |