]>
Commit | Line | Data |
---|---|---|
0aea86a2 CM |
1 | /* |
2 | * Based on arch/arm/lib/clear_user.S | |
3 | * | |
4 | * Copyright (C) 2012 ARM Ltd. | |
5 | * | |
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. | |
9 | * | |
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. | |
14 | * | |
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/>. | |
17 | */ | |
18 | #include <linux/linkage.h> | |
338d4f49 | 19 | |
7c0f6ba6 | 20 | #include <linux/uaccess.h> |
0aea86a2 CM |
21 | |
22 | .text | |
23 | ||
24 | /* Prototype: int __clear_user(void *addr, size_t sz) | |
25 | * Purpose : clear some user memory | |
26 | * Params : addr - user memory address to clear | |
27 | * : sz - number of bytes to clear | |
28 | * Returns : number of bytes NOT cleared | |
29 | * | |
30 | * Alignment fixed up by hardware. | |
31 | */ | |
32 | ENTRY(__clear_user) | |
bd38967d | 33 | uaccess_enable_not_uao x2, x3 |
0aea86a2 CM |
34 | mov x2, x1 // save the size for fixup return |
35 | subs x1, x1, #8 | |
36 | b.mi 2f | |
37 | 1: | |
57f4959b | 38 | uao_user_alternative 9f, str, sttr, xzr, x0, 8 |
0aea86a2 CM |
39 | subs x1, x1, #8 |
40 | b.pl 1b | |
41 | 2: adds x1, x1, #4 | |
42 | b.mi 3f | |
57f4959b | 43 | uao_user_alternative 9f, str, sttr, wzr, x0, 4 |
0aea86a2 CM |
44 | sub x1, x1, #4 |
45 | 3: adds x1, x1, #2 | |
46 | b.mi 4f | |
57f4959b | 47 | uao_user_alternative 9f, strh, sttrh, wzr, x0, 2 |
0aea86a2 CM |
48 | sub x1, x1, #2 |
49 | 4: adds x1, x1, #1 | |
50 | b.mi 5f | |
57f4959b | 51 | uao_user_alternative 9f, strb, sttrb, wzr, x0, 0 |
0aea86a2 | 52 | 5: mov x0, #0 |
bd38967d | 53 | uaccess_disable_not_uao x2 |
0aea86a2 CM |
54 | ret |
55 | ENDPROC(__clear_user) | |
56 | ||
57 | .section .fixup,"ax" | |
58 | .align 2 | |
59 | 9: mov x0, x2 // return the original size | |
60 | ret | |
61 | .previous |