]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/m68k/lib/uaccess.c
UBUNTU: Ubuntu-4.15.0-96.97
[mirror_ubuntu-bionic-kernel.git] / arch / m68k / lib / uaccess.c
CommitLineData
d94af931
RZ
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file COPYING in the main directory of this archive
4 * for more details.
5 */
6
7#include <linux/module.h>
7c0f6ba6 8#include <linux/uaccess.h>
d94af931
RZ
9
10unsigned long __generic_copy_from_user(void *to, const void __user *from,
11 unsigned long n)
12{
13 unsigned long tmp, res;
14
15 asm volatile ("\n"
16 " tst.l %0\n"
17 " jeq 2f\n"
e08d703c 18 "1: "MOVES".l (%1)+,%3\n"
d94af931
RZ
19 " move.l %3,(%2)+\n"
20 " subq.l #1,%0\n"
21 " jne 1b\n"
22 "2: btst #1,%5\n"
23 " jeq 4f\n"
e08d703c 24 "3: "MOVES".w (%1)+,%3\n"
d94af931
RZ
25 " move.w %3,(%2)+\n"
26 "4: btst #0,%5\n"
27 " jeq 6f\n"
e08d703c 28 "5: "MOVES".b (%1)+,%3\n"
d94af931
RZ
29 " move.b %3,(%2)+\n"
30 "6:\n"
31 " .section .fixup,\"ax\"\n"
32 " .even\n"
7cefa5a0 33 "10: lsl.l #2,%0\n"
d94af931
RZ
34 " btst #1,%5\n"
35 " jeq 8f\n"
7cefa5a0 36 "30: addq.l #2,%0\n"
d94af931
RZ
37 "8: btst #0,%5\n"
38 " jeq 6b\n"
7cefa5a0 39 "50: addq.l #1,%0\n"
d94af931
RZ
40 " jra 6b\n"
41 " .previous\n"
42 "\n"
43 " .section __ex_table,\"a\"\n"
44 " .align 4\n"
45 " .long 1b,10b\n"
46 " .long 3b,30b\n"
47 " .long 5b,50b\n"
48 " .previous"
631d8b67 49 : "=d" (res), "+a" (from), "+a" (to), "=&d" (tmp)
d94af931
RZ
50 : "0" (n / 4), "d" (n & 3));
51
52 return res;
53}
54EXPORT_SYMBOL(__generic_copy_from_user);
55
56unsigned long __generic_copy_to_user(void __user *to, const void *from,
57 unsigned long n)
58{
59 unsigned long tmp, res;
60
61 asm volatile ("\n"
62 " tst.l %0\n"
63 " jeq 4f\n"
64 "1: move.l (%1)+,%3\n"
e08d703c 65 "2: "MOVES".l %3,(%2)+\n"
d94af931
RZ
66 "3: subq.l #1,%0\n"
67 " jne 1b\n"
68 "4: btst #1,%5\n"
69 " jeq 6f\n"
70 " move.w (%1)+,%3\n"
e08d703c 71 "5: "MOVES".w %3,(%2)+\n"
d94af931
RZ
72 "6: btst #0,%5\n"
73 " jeq 8f\n"
74 " move.b (%1)+,%3\n"
e08d703c 75 "7: "MOVES".b %3,(%2)+\n"
d94af931
RZ
76 "8:\n"
77 " .section .fixup,\"ax\"\n"
78 " .even\n"
79 "20: lsl.l #2,%0\n"
80 "50: add.l %5,%0\n"
6c04c28a 81 " jra 8b\n"
d94af931
RZ
82 " .previous\n"
83 "\n"
84 " .section __ex_table,\"a\"\n"
85 " .align 4\n"
86 " .long 2b,20b\n"
87 " .long 3b,20b\n"
88 " .long 5b,50b\n"
89 " .long 6b,50b\n"
90 " .long 7b,50b\n"
91 " .long 8b,50b\n"
92 " .previous"
631d8b67 93 : "=d" (res), "+a" (from), "+a" (to), "=&d" (tmp)
d94af931
RZ
94 : "0" (n / 4), "d" (n & 3));
95
96 return res;
97}
98EXPORT_SYMBOL(__generic_copy_to_user);
99
d94af931
RZ
100/*
101 * Zero Userspace
102 */
103
3c46bdca 104unsigned long __clear_user(void __user *to, unsigned long n)
d94af931
RZ
105{
106 unsigned long res;
107
108 asm volatile ("\n"
109 " tst.l %0\n"
110 " jeq 3f\n"
e08d703c 111 "1: "MOVES".l %2,(%1)+\n"
d94af931
RZ
112 "2: subq.l #1,%0\n"
113 " jne 1b\n"
114 "3: btst #1,%4\n"
115 " jeq 5f\n"
e08d703c 116 "4: "MOVES".w %2,(%1)+\n"
d94af931
RZ
117 "5: btst #0,%4\n"
118 " jeq 7f\n"
e08d703c 119 "6: "MOVES".b %2,(%1)\n"
d94af931
RZ
120 "7:\n"
121 " .section .fixup,\"ax\"\n"
122 " .even\n"
123 "10: lsl.l #2,%0\n"
124 "40: add.l %4,%0\n"
125 " jra 7b\n"
126 " .previous\n"
127 "\n"
128 " .section __ex_table,\"a\"\n"
129 " .align 4\n"
130 " .long 1b,10b\n"
131 " .long 2b,10b\n"
132 " .long 4b,40b\n"
133 " .long 5b,40b\n"
134 " .long 6b,40b\n"
135 " .long 7b,40b\n"
136 " .previous"
137 : "=d" (res), "+a" (to)
631d8b67 138 : "d" (0), "0" (n / 4), "d" (n & 3));
d94af931
RZ
139
140 return res;
141}
3c46bdca 142EXPORT_SYMBOL(__clear_user);