Merge tag 'vfio-v4.21-rc1' of git://github.com/awilliam/linux-vfio
[sfrench/cifs-2.6.git] / arch / arm64 / lib / copy_in_user.S
1 /*
2  * Copy from user space to user space
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
19 #include <linux/linkage.h>
20
21 #include <asm/asm-uaccess.h>
22 #include <asm/assembler.h>
23 #include <asm/cache.h>
24
25 /*
26  * Copy from user space to user space (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  */
35         .macro ldrb1 ptr, regB, val
36         uao_user_alternative 9998f, ldrb, ldtrb, \ptr, \regB, \val
37         .endm
38
39         .macro strb1 ptr, regB, val
40         uao_user_alternative 9998f, strb, sttrb, \ptr, \regB, \val
41         .endm
42
43         .macro ldrh1 ptr, regB, val
44         uao_user_alternative 9998f, ldrh, ldtrh, \ptr, \regB, \val
45         .endm
46
47         .macro strh1 ptr, regB, val
48         uao_user_alternative 9998f, strh, sttrh, \ptr, \regB, \val
49         .endm
50
51         .macro ldr1 ptr, regB, val
52         uao_user_alternative 9998f, ldr, ldtr, \ptr, \regB, \val
53         .endm
54
55         .macro str1 ptr, regB, val
56         uao_user_alternative 9998f, str, sttr, \ptr, \regB, \val
57         .endm
58
59         .macro ldp1 ptr, regB, regC, val
60         uao_ldp 9998f, \ptr, \regB, \regC, \val
61         .endm
62
63         .macro stp1 ptr, regB, regC, val
64         uao_stp 9998f, \ptr, \regB, \regC, \val
65         .endm
66
67 end     .req    x5
68
69 ENTRY(__arch_copy_in_user)
70         uaccess_enable_not_uao x3, x4, x5
71         add     end, x0, x2
72 #include "copy_template.S"
73         uaccess_disable_not_uao x3, x4
74         mov     x0, #0
75         ret
76 ENDPROC(__arch_copy_in_user)
77 EXPORT_SYMBOL(__arch_copy_in_user)
78
79         .section .fixup,"ax"
80         .align  2
81 9998:   sub     x0, end, dst                    // bytes not copied
82         ret
83         .previous