blob: 66e90bf528e2bf3a4f9ba710418eee539d38c816 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/* copy_in_user.S: Copy from userspace to userspace.
3 *
4 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com)
5 */
6
David S. Milleraeb39872009-02-08 22:32:31 -08007#include <linux/linkage.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <asm/asi.h>
Al Virod3867f042016-01-16 21:39:30 -05009#include <asm/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11#define XCC xcc
12
David S. Miller0096ac92016-08-15 15:08:18 -070013#define EX(x,y,z) \
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498: x,y; \
David S. Miller4d000d52006-03-04 23:23:56 -080015 .section __ex_table,"a";\
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 .align 4; \
David S. Miller0096ac92016-08-15 15:08:18 -070017 .word 98b, z; \
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 .text; \
19 .align 4;
20
David S. Miller0096ac92016-08-15 15:08:18 -070021#define EX_O4(x,y) EX(x,y,__retl_o4_plus_8)
22#define EX_O2_4(x,y) EX(x,y,__retl_o2_plus_4)
23#define EX_O2_1(x,y) EX(x,y,__retl_o2_plus_1)
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 .register %g2,#scratch
26 .register %g3,#scratch
27
28 .text
David S. Miller0096ac92016-08-15 15:08:18 -070029__retl_o4_plus_8:
30 add %o4, %o2, %o4
31 retl
32 add %o4, 8, %o0
33__retl_o2_plus_4:
34 retl
35 add %o2, 4, %o0
36__retl_o2_plus_1:
37 retl
38 add %o2, 1, %o0
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 .align 32
41
42 /* Don't try to get too fancy here, just nice and
43 * simple. This is predominantly used for well aligned
44 * small copies in the compat layer. It is also used
45 * to copy register windows around during thread cloning.
46 */
47
Al Viro31af2f32017-03-21 17:04:45 -040048ENTRY(raw_copy_in_user) /* %o0=dst, %o1=src, %o2=len */
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 cmp %o2, 0
50 be,pn %XCC, 85f
51 or %o0, %o1, %o3
52 cmp %o2, 16
53 bleu,a,pn %XCC, 80f
54 or %o3, %o2, %o3
55
56 /* 16 < len <= 64 */
57 andcc %o3, 0x7, %g0
58 bne,pn %XCC, 90f
David S. Milleraeb39872009-02-08 22:32:31 -080059 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61 andn %o2, 0x7, %o4
62 and %o2, 0x7, %o2
631: subcc %o4, 0x8, %o4
David S. Miller0096ac92016-08-15 15:08:18 -070064 EX_O4(ldxa [%o1] %asi, %o5)
65 EX_O4(stxa %o5, [%o0] %asi)
David S. Milleraeb39872009-02-08 22:32:31 -080066 add %o1, 0x8, %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 bgu,pt %XCC, 1b
David S. Milleraeb39872009-02-08 22:32:31 -080068 add %o0, 0x8, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 andcc %o2, 0x4, %g0
70 be,pt %XCC, 1f
71 nop
72 sub %o2, 0x4, %o2
David S. Miller0096ac92016-08-15 15:08:18 -070073 EX_O2_4(lduwa [%o1] %asi, %o5)
74 EX_O2_4(stwa %o5, [%o0] %asi)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 add %o1, 0x4, %o1
David S. Milleraeb39872009-02-08 22:32:31 -080076 add %o0, 0x4, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771: cmp %o2, 0
78 be,pt %XCC, 85f
79 nop
80 ba,pt %xcc, 90f
81 nop
82
8380: /* 0 < len <= 16 */
84 andcc %o3, 0x3, %g0
85 bne,pn %XCC, 90f
David S. Milleraeb39872009-02-08 22:32:31 -080086 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
8882:
89 subcc %o2, 4, %o2
David S. Miller0096ac92016-08-15 15:08:18 -070090 EX_O2_4(lduwa [%o1] %asi, %g1)
91 EX_O2_4(stwa %g1, [%o0] %asi)
David S. Milleraeb39872009-02-08 22:32:31 -080092 add %o1, 4, %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 bgu,pt %XCC, 82b
David S. Milleraeb39872009-02-08 22:32:31 -080094 add %o0, 4, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
9685: retl
97 clr %o0
98
99 .align 32
10090:
101 subcc %o2, 1, %o2
David S. Miller0096ac92016-08-15 15:08:18 -0700102 EX_O2_1(lduba [%o1] %asi, %g1)
103 EX_O2_1(stba %g1, [%o0] %asi)
David S. Milleraeb39872009-02-08 22:32:31 -0800104 add %o1, 1, %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 bgu,pt %XCC, 90b
David S. Milleraeb39872009-02-08 22:32:31 -0800106 add %o0, 1, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 retl
108 clr %o0
Al Viro31af2f32017-03-21 17:04:45 -0400109ENDPROC(raw_copy_in_user)
110EXPORT_SYMBOL(raw_copy_in_user)