Merge tag 'mips_5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
[linux-2.6-microblaze.git] / arch / arm64 / lib / copy_in_user.S
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copy from user space to user space
4  *
5  * Copyright (C) 2012 ARM Ltd.
6  */
7
8 #include <linux/linkage.h>
9
10 #include <asm/asm-uaccess.h>
11 #include <asm/assembler.h>
12 #include <asm/cache.h>
13
14 /*
15  * Copy from user space to user space (alignment handled by the hardware)
16  *
17  * Parameters:
18  *      x0 - to
19  *      x1 - from
20  *      x2 - n
21  * Returns:
22  *      x0 - bytes not copied
23  */
24         .macro ldrb1 reg, ptr, val
25         user_ldst 9998f, ldtrb, \reg, \ptr, \val
26         .endm
27
28         .macro strb1 reg, ptr, val
29         user_ldst 9998f, sttrb, \reg, \ptr, \val
30         .endm
31
32         .macro ldrh1 reg, ptr, val
33         user_ldst 9997f, ldtrh, \reg, \ptr, \val
34         .endm
35
36         .macro strh1 reg, ptr, val
37         user_ldst 9997f, sttrh, \reg, \ptr, \val
38         .endm
39
40         .macro ldr1 reg, ptr, val
41         user_ldst 9997f, ldtr, \reg, \ptr, \val
42         .endm
43
44         .macro str1 reg, ptr, val
45         user_ldst 9997f, sttr, \reg, \ptr, \val
46         .endm
47
48         .macro ldp1 reg1, reg2, ptr, val
49         user_ldp 9997f, \reg1, \reg2, \ptr, \val
50         .endm
51
52         .macro stp1 reg1, reg2, ptr, val
53         user_stp 9997f, \reg1, \reg2, \ptr, \val
54         .endm
55
56 end     .req    x5
57 srcin   .req    x15
58 SYM_FUNC_START(__arch_copy_in_user)
59         add     end, x0, x2
60         mov     srcin, x1
61 #include "copy_template.S"
62         mov     x0, #0
63         ret
64 SYM_FUNC_END(__arch_copy_in_user)
65 EXPORT_SYMBOL(__arch_copy_in_user)
66
67         .section .fixup,"ax"
68         .align  2
69 9997:   cmp     dst, dstin
70         b.ne    9998f
71         // Before being absolutely sure we couldn't copy anything, try harder
72 USER(9998f, ldtrb tmp1w, [srcin])
73 USER(9998f, sttrb tmp1w, [dst])
74         add     dst, dst, #1
75 9998:   sub     x0, end, dst                    // bytes not copied
76         ret
77         .previous