diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2013-09-24 03:14:56 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2013-10-24 11:16:57 -0400 |
commit | e258d719ff28ecc7a048eb8f78380e68c4b3a3f0 (patch) | |
tree | 1c7f496b97cef1111b230371940e603a2ca401a4 /arch/s390/lib | |
parent | 7d7c7b24e416afb2637be8447e03ca4457c100fd (diff) |
s390/uaccess: always run the kernel in home space
Simplify the uaccess code by removing the user_mode=home option.
The kernel will now always run in the home space mode.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/lib')
-rw-r--r-- | arch/s390/lib/Makefile | 2 | ||||
-rw-r--r-- | arch/s390/lib/uaccess_mvcos.c | 30 | ||||
-rw-r--r-- | arch/s390/lib/uaccess_pt.c | 2 | ||||
-rw-r--r-- | arch/s390/lib/uaccess_std.c | 305 |
4 files changed, 1 insertions, 338 deletions
diff --git a/arch/s390/lib/Makefile b/arch/s390/lib/Makefile index e506c5fb6f6a..b068729e50ac 100644 --- a/arch/s390/lib/Makefile +++ b/arch/s390/lib/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for s390-specific library files.. | 2 | # Makefile for s390-specific library files.. |
3 | # | 3 | # |
4 | 4 | ||
5 | lib-y += delay.o string.o uaccess_std.o uaccess_pt.o find.o | 5 | lib-y += delay.o string.o uaccess_pt.o find.o |
6 | obj-$(CONFIG_32BIT) += div64.o qrnnd.o ucmpdi2.o mem32.o | 6 | obj-$(CONFIG_32BIT) += div64.o qrnnd.o ucmpdi2.o mem32.o |
7 | obj-$(CONFIG_64BIT) += mem64.o | 7 | obj-$(CONFIG_64BIT) += mem64.o |
8 | lib-$(CONFIG_64BIT) += uaccess_mvcos.o | 8 | lib-$(CONFIG_64BIT) += uaccess_mvcos.o |
diff --git a/arch/s390/lib/uaccess_mvcos.c b/arch/s390/lib/uaccess_mvcos.c index 1829742bf479..4b7993bf69b9 100644 --- a/arch/s390/lib/uaccess_mvcos.c +++ b/arch/s390/lib/uaccess_mvcos.c | |||
@@ -65,13 +65,6 @@ static size_t copy_from_user_mvcos(size_t size, const void __user *ptr, void *x) | |||
65 | return size; | 65 | return size; |
66 | } | 66 | } |
67 | 67 | ||
68 | static size_t copy_from_user_mvcos_check(size_t size, const void __user *ptr, void *x) | ||
69 | { | ||
70 | if (size <= 256) | ||
71 | return copy_from_user_std(size, ptr, x); | ||
72 | return copy_from_user_mvcos(size, ptr, x); | ||
73 | } | ||
74 | |||
75 | static size_t copy_to_user_mvcos(size_t size, void __user *ptr, const void *x) | 68 | static size_t copy_to_user_mvcos(size_t size, void __user *ptr, const void *x) |
76 | { | 69 | { |
77 | register unsigned long reg0 asm("0") = 0x810000UL; | 70 | register unsigned long reg0 asm("0") = 0x810000UL; |
@@ -101,14 +94,6 @@ static size_t copy_to_user_mvcos(size_t size, void __user *ptr, const void *x) | |||
101 | return size; | 94 | return size; |
102 | } | 95 | } |
103 | 96 | ||
104 | static size_t copy_to_user_mvcos_check(size_t size, void __user *ptr, | ||
105 | const void *x) | ||
106 | { | ||
107 | if (size <= 256) | ||
108 | return copy_to_user_std(size, ptr, x); | ||
109 | return copy_to_user_mvcos(size, ptr, x); | ||
110 | } | ||
111 | |||
112 | static size_t copy_in_user_mvcos(size_t size, void __user *to, | 97 | static size_t copy_in_user_mvcos(size_t size, void __user *to, |
113 | const void __user *from) | 98 | const void __user *from) |
114 | { | 99 | { |
@@ -201,23 +186,8 @@ static size_t strncpy_from_user_mvcos(size_t count, const char __user *src, | |||
201 | } | 186 | } |
202 | 187 | ||
203 | struct uaccess_ops uaccess_mvcos = { | 188 | struct uaccess_ops uaccess_mvcos = { |
204 | .copy_from_user = copy_from_user_mvcos_check, | ||
205 | .copy_from_user_small = copy_from_user_std, | ||
206 | .copy_to_user = copy_to_user_mvcos_check, | ||
207 | .copy_to_user_small = copy_to_user_std, | ||
208 | .copy_in_user = copy_in_user_mvcos, | ||
209 | .clear_user = clear_user_mvcos, | ||
210 | .strnlen_user = strnlen_user_std, | ||
211 | .strncpy_from_user = strncpy_from_user_std, | ||
212 | .futex_atomic_op = futex_atomic_op_std, | ||
213 | .futex_atomic_cmpxchg = futex_atomic_cmpxchg_std, | ||
214 | }; | ||
215 | |||
216 | struct uaccess_ops uaccess_mvcos_switch = { | ||
217 | .copy_from_user = copy_from_user_mvcos, | 189 | .copy_from_user = copy_from_user_mvcos, |
218 | .copy_from_user_small = copy_from_user_mvcos, | ||
219 | .copy_to_user = copy_to_user_mvcos, | 190 | .copy_to_user = copy_to_user_mvcos, |
220 | .copy_to_user_small = copy_to_user_mvcos, | ||
221 | .copy_in_user = copy_in_user_mvcos, | 191 | .copy_in_user = copy_in_user_mvcos, |
222 | .clear_user = clear_user_mvcos, | 192 | .clear_user = clear_user_mvcos, |
223 | .strnlen_user = strnlen_user_mvcos, | 193 | .strnlen_user = strnlen_user_mvcos, |
diff --git a/arch/s390/lib/uaccess_pt.c b/arch/s390/lib/uaccess_pt.c index 1694d738b175..97e03caf7825 100644 --- a/arch/s390/lib/uaccess_pt.c +++ b/arch/s390/lib/uaccess_pt.c | |||
@@ -461,9 +461,7 @@ int futex_atomic_cmpxchg_pt(u32 *uval, u32 __user *uaddr, | |||
461 | 461 | ||
462 | struct uaccess_ops uaccess_pt = { | 462 | struct uaccess_ops uaccess_pt = { |
463 | .copy_from_user = copy_from_user_pt, | 463 | .copy_from_user = copy_from_user_pt, |
464 | .copy_from_user_small = copy_from_user_pt, | ||
465 | .copy_to_user = copy_to_user_pt, | 464 | .copy_to_user = copy_to_user_pt, |
466 | .copy_to_user_small = copy_to_user_pt, | ||
467 | .copy_in_user = copy_in_user_pt, | 465 | .copy_in_user = copy_in_user_pt, |
468 | .clear_user = clear_user_pt, | 466 | .clear_user = clear_user_pt, |
469 | .strnlen_user = strnlen_user_pt, | 467 | .strnlen_user = strnlen_user_pt, |
diff --git a/arch/s390/lib/uaccess_std.c b/arch/s390/lib/uaccess_std.c deleted file mode 100644 index 4a75d475b06a..000000000000 --- a/arch/s390/lib/uaccess_std.c +++ /dev/null | |||
@@ -1,305 +0,0 @@ | |||
1 | /* | ||
2 | * Standard user space access functions based on mvcp/mvcs and doing | ||
3 | * interesting things in the secondary space mode. | ||
4 | * | ||
5 | * Copyright IBM Corp. 2006 | ||
6 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), | ||
7 | * Gerald Schaefer (gerald.schaefer@de.ibm.com) | ||
8 | */ | ||
9 | |||
10 | #include <linux/errno.h> | ||
11 | #include <linux/mm.h> | ||
12 | #include <linux/uaccess.h> | ||
13 | #include <asm/futex.h> | ||
14 | #include "uaccess.h" | ||
15 | |||
16 | #ifndef CONFIG_64BIT | ||
17 | #define AHI "ahi" | ||
18 | #define ALR "alr" | ||
19 | #define CLR "clr" | ||
20 | #define LHI "lhi" | ||
21 | #define SLR "slr" | ||
22 | #else | ||
23 | #define AHI "aghi" | ||
24 | #define ALR "algr" | ||
25 | #define CLR "clgr" | ||
26 | #define LHI "lghi" | ||
27 | #define SLR "slgr" | ||
28 | #endif | ||
29 | |||
30 | size_t copy_from_user_std(size_t size, const void __user *ptr, void *x) | ||
31 | { | ||
32 | unsigned long tmp1, tmp2; | ||
33 | |||
34 | tmp1 = -256UL; | ||
35 | asm volatile( | ||
36 | "0: mvcp 0(%0,%2),0(%1),%3\n" | ||
37 | "10:jz 8f\n" | ||
38 | "1:"ALR" %0,%3\n" | ||
39 | " la %1,256(%1)\n" | ||
40 | " la %2,256(%2)\n" | ||
41 | "2: mvcp 0(%0,%2),0(%1),%3\n" | ||
42 | "11:jnz 1b\n" | ||
43 | " j 8f\n" | ||
44 | "3: la %4,255(%1)\n" /* %4 = ptr + 255 */ | ||
45 | " "LHI" %3,-4096\n" | ||
46 | " nr %4,%3\n" /* %4 = (ptr + 255) & -4096 */ | ||
47 | " "SLR" %4,%1\n" | ||
48 | " "CLR" %0,%4\n" /* copy crosses next page boundary? */ | ||
49 | " jnh 5f\n" | ||
50 | "4: mvcp 0(%4,%2),0(%1),%3\n" | ||
51 | "12:"SLR" %0,%4\n" | ||
52 | " "ALR" %2,%4\n" | ||
53 | "5:"LHI" %4,-1\n" | ||
54 | " "ALR" %4,%0\n" /* copy remaining size, subtract 1 */ | ||
55 | " bras %3,7f\n" /* memset loop */ | ||
56 | " xc 0(1,%2),0(%2)\n" | ||
57 | "6: xc 0(256,%2),0(%2)\n" | ||
58 | " la %2,256(%2)\n" | ||
59 | "7:"AHI" %4,-256\n" | ||
60 | " jnm 6b\n" | ||
61 | " ex %4,0(%3)\n" | ||
62 | " j 9f\n" | ||
63 | "8:"SLR" %0,%0\n" | ||
64 | "9: \n" | ||
65 | EX_TABLE(0b,3b) EX_TABLE(2b,3b) EX_TABLE(4b,5b) | ||
66 | EX_TABLE(10b,3b) EX_TABLE(11b,3b) EX_TABLE(12b,5b) | ||
67 | : "+a" (size), "+a" (ptr), "+a" (x), "+a" (tmp1), "=a" (tmp2) | ||
68 | : : "cc", "memory"); | ||
69 | return size; | ||
70 | } | ||
71 | |||
72 | static size_t copy_from_user_std_check(size_t size, const void __user *ptr, | ||
73 | void *x) | ||
74 | { | ||
75 | if (size <= 1024) | ||
76 | return copy_from_user_std(size, ptr, x); | ||
77 | return copy_from_user_pt(size, ptr, x); | ||
78 | } | ||
79 | |||
80 | size_t copy_to_user_std(size_t size, void __user *ptr, const void *x) | ||
81 | { | ||
82 | unsigned long tmp1, tmp2; | ||
83 | |||
84 | tmp1 = -256UL; | ||
85 | asm volatile( | ||
86 | "0: mvcs 0(%0,%1),0(%2),%3\n" | ||
87 | "7: jz 5f\n" | ||
88 | "1:"ALR" %0,%3\n" | ||
89 | " la %1,256(%1)\n" | ||
90 | " la %2,256(%2)\n" | ||
91 | "2: mvcs 0(%0,%1),0(%2),%3\n" | ||
92 | "8: jnz 1b\n" | ||
93 | " j 5f\n" | ||
94 | "3: la %4,255(%1)\n" /* %4 = ptr + 255 */ | ||
95 | " "LHI" %3,-4096\n" | ||
96 | " nr %4,%3\n" /* %4 = (ptr + 255) & -4096 */ | ||
97 | " "SLR" %4,%1\n" | ||
98 | " "CLR" %0,%4\n" /* copy crosses next page boundary? */ | ||
99 | " jnh 6f\n" | ||
100 | "4: mvcs 0(%4,%1),0(%2),%3\n" | ||
101 | "9:"SLR" %0,%4\n" | ||
102 | " j 6f\n" | ||
103 | "5:"SLR" %0,%0\n" | ||
104 | "6: \n" | ||
105 | EX_TABLE(0b,3b) EX_TABLE(2b,3b) EX_TABLE(4b,6b) | ||
106 | EX_TABLE(7b,3b) EX_TABLE(8b,3b) EX_TABLE(9b,6b) | ||
107 | : "+a" (size), "+a" (ptr), "+a" (x), "+a" (tmp1), "=a" (tmp2) | ||
108 | : : "cc", "memory"); | ||
109 | return size; | ||
110 | } | ||
111 | |||
112 | static size_t copy_to_user_std_check(size_t size, void __user *ptr, | ||
113 | const void *x) | ||
114 | { | ||
115 | if (size <= 1024) | ||
116 | return copy_to_user_std(size, ptr, x); | ||
117 | return copy_to_user_pt(size, ptr, x); | ||
118 | } | ||
119 | |||
120 | static size_t copy_in_user_std(size_t size, void __user *to, | ||
121 | const void __user *from) | ||
122 | { | ||
123 | unsigned long tmp1; | ||
124 | |||
125 | asm volatile( | ||
126 | " sacf 256\n" | ||
127 | " "AHI" %0,-1\n" | ||
128 | " jo 5f\n" | ||
129 | " bras %3,3f\n" | ||
130 | "0:"AHI" %0,257\n" | ||
131 | "1: mvc 0(1,%1),0(%2)\n" | ||
132 | " la %1,1(%1)\n" | ||
133 | " la %2,1(%2)\n" | ||
134 | " "AHI" %0,-1\n" | ||
135 | " jnz 1b\n" | ||
136 | " j 5f\n" | ||
137 | "2: mvc 0(256,%1),0(%2)\n" | ||
138 | " la %1,256(%1)\n" | ||
139 | " la %2,256(%2)\n" | ||
140 | "3:"AHI" %0,-256\n" | ||
141 | " jnm 2b\n" | ||
142 | "4: ex %0,1b-0b(%3)\n" | ||
143 | "5: "SLR" %0,%0\n" | ||
144 | "6: sacf 0\n" | ||
145 | EX_TABLE(1b,6b) EX_TABLE(2b,0b) EX_TABLE(4b,0b) | ||
146 | : "+a" (size), "+a" (to), "+a" (from), "=a" (tmp1) | ||
147 | : : "cc", "memory"); | ||
148 | return size; | ||
149 | } | ||
150 | |||
151 | static size_t clear_user_std(size_t size, void __user *to) | ||
152 | { | ||
153 | unsigned long tmp1, tmp2; | ||
154 | |||
155 | asm volatile( | ||
156 | " sacf 256\n" | ||
157 | " "AHI" %0,-1\n" | ||
158 | " jo 5f\n" | ||
159 | " bras %3,3f\n" | ||
160 | " xc 0(1,%1),0(%1)\n" | ||
161 | "0:"AHI" %0,257\n" | ||
162 | " la %2,255(%1)\n" /* %2 = ptr + 255 */ | ||
163 | " srl %2,12\n" | ||
164 | " sll %2,12\n" /* %2 = (ptr + 255) & -4096 */ | ||
165 | " "SLR" %2,%1\n" | ||
166 | " "CLR" %0,%2\n" /* clear crosses next page boundary? */ | ||
167 | " jnh 5f\n" | ||
168 | " "AHI" %2,-1\n" | ||
169 | "1: ex %2,0(%3)\n" | ||
170 | " "AHI" %2,1\n" | ||
171 | " "SLR" %0,%2\n" | ||
172 | " j 5f\n" | ||
173 | "2: xc 0(256,%1),0(%1)\n" | ||
174 | " la %1,256(%1)\n" | ||
175 | "3:"AHI" %0,-256\n" | ||
176 | " jnm 2b\n" | ||
177 | "4: ex %0,0(%3)\n" | ||
178 | "5: "SLR" %0,%0\n" | ||
179 | "6: sacf 0\n" | ||
180 | EX_TABLE(1b,6b) EX_TABLE(2b,0b) EX_TABLE(4b,0b) | ||
181 | : "+a" (size), "+a" (to), "=a" (tmp1), "=a" (tmp2) | ||
182 | : : "cc", "memory"); | ||
183 | return size; | ||
184 | } | ||
185 | |||
186 | size_t strnlen_user_std(size_t size, const char __user *src) | ||
187 | { | ||
188 | register unsigned long reg0 asm("0") = 0UL; | ||
189 | unsigned long tmp1, tmp2; | ||
190 | |||
191 | if (unlikely(!size)) | ||
192 | return 0; | ||
193 | asm volatile( | ||
194 | " la %2,0(%1)\n" | ||
195 | " la %3,0(%0,%1)\n" | ||
196 | " "SLR" %0,%0\n" | ||
197 | " sacf 256\n" | ||
198 | "0: srst %3,%2\n" | ||
199 | " jo 0b\n" | ||
200 | " la %0,1(%3)\n" /* strnlen_user results includes \0 */ | ||
201 | " "SLR" %0,%1\n" | ||
202 | "1: sacf 0\n" | ||
203 | EX_TABLE(0b,1b) | ||
204 | : "+a" (size), "+a" (src), "=a" (tmp1), "=a" (tmp2) | ||
205 | : "d" (reg0) : "cc", "memory"); | ||
206 | return size; | ||
207 | } | ||
208 | |||
209 | size_t strncpy_from_user_std(size_t count, const char __user *src, char *dst) | ||
210 | { | ||
211 | size_t done, len, offset, len_str; | ||
212 | |||
213 | if (unlikely(!count)) | ||
214 | return 0; | ||
215 | done = 0; | ||
216 | do { | ||
217 | offset = (size_t)src & ~PAGE_MASK; | ||
218 | len = min(count - done, PAGE_SIZE - offset); | ||
219 | if (copy_from_user_std(len, src, dst)) | ||
220 | return -EFAULT; | ||
221 | len_str = strnlen(dst, len); | ||
222 | done += len_str; | ||
223 | src += len_str; | ||
224 | dst += len_str; | ||
225 | } while ((len_str == len) && (done < count)); | ||
226 | return done; | ||
227 | } | ||
228 | |||
229 | #define __futex_atomic_op(insn, ret, oldval, newval, uaddr, oparg) \ | ||
230 | asm volatile( \ | ||
231 | " sacf 256\n" \ | ||
232 | "0: l %1,0(%6)\n" \ | ||
233 | "1:"insn \ | ||
234 | "2: cs %1,%2,0(%6)\n" \ | ||
235 | "3: jl 1b\n" \ | ||
236 | " lhi %0,0\n" \ | ||
237 | "4: sacf 0\n" \ | ||
238 | EX_TABLE(0b,4b) EX_TABLE(2b,4b) EX_TABLE(3b,4b) \ | ||
239 | : "=d" (ret), "=&d" (oldval), "=&d" (newval), \ | ||
240 | "=m" (*uaddr) \ | ||
241 | : "0" (-EFAULT), "d" (oparg), "a" (uaddr), \ | ||
242 | "m" (*uaddr) : "cc"); | ||
243 | |||
244 | int futex_atomic_op_std(int op, u32 __user *uaddr, int oparg, int *old) | ||
245 | { | ||
246 | int oldval = 0, newval, ret; | ||
247 | |||
248 | switch (op) { | ||
249 | case FUTEX_OP_SET: | ||
250 | __futex_atomic_op("lr %2,%5\n", | ||
251 | ret, oldval, newval, uaddr, oparg); | ||
252 | break; | ||
253 | case FUTEX_OP_ADD: | ||
254 | __futex_atomic_op("lr %2,%1\nar %2,%5\n", | ||
255 | ret, oldval, newval, uaddr, oparg); | ||
256 | break; | ||
257 | case FUTEX_OP_OR: | ||
258 | __futex_atomic_op("lr %2,%1\nor %2,%5\n", | ||
259 | ret, oldval, newval, uaddr, oparg); | ||
260 | break; | ||
261 | case FUTEX_OP_ANDN: | ||
262 | __futex_atomic_op("lr %2,%1\nnr %2,%5\n", | ||
263 | ret, oldval, newval, uaddr, oparg); | ||
264 | break; | ||
265 | case FUTEX_OP_XOR: | ||
266 | __futex_atomic_op("lr %2,%1\nxr %2,%5\n", | ||
267 | ret, oldval, newval, uaddr, oparg); | ||
268 | break; | ||
269 | default: | ||
270 | ret = -ENOSYS; | ||
271 | } | ||
272 | *old = oldval; | ||
273 | return ret; | ||
274 | } | ||
275 | |||
276 | int futex_atomic_cmpxchg_std(u32 *uval, u32 __user *uaddr, | ||
277 | u32 oldval, u32 newval) | ||
278 | { | ||
279 | int ret; | ||
280 | |||
281 | asm volatile( | ||
282 | " sacf 256\n" | ||
283 | "0: cs %1,%4,0(%5)\n" | ||
284 | "1: la %0,0\n" | ||
285 | "2: sacf 0\n" | ||
286 | EX_TABLE(0b,2b) EX_TABLE(1b,2b) | ||
287 | : "=d" (ret), "+d" (oldval), "=m" (*uaddr) | ||
288 | : "0" (-EFAULT), "d" (newval), "a" (uaddr), "m" (*uaddr) | ||
289 | : "cc", "memory" ); | ||
290 | *uval = oldval; | ||
291 | return ret; | ||
292 | } | ||
293 | |||
294 | struct uaccess_ops uaccess_std = { | ||
295 | .copy_from_user = copy_from_user_std_check, | ||
296 | .copy_from_user_small = copy_from_user_std, | ||
297 | .copy_to_user = copy_to_user_std_check, | ||
298 | .copy_to_user_small = copy_to_user_std, | ||
299 | .copy_in_user = copy_in_user_std, | ||
300 | .clear_user = clear_user_std, | ||
301 | .strnlen_user = strnlen_user_std, | ||
302 | .strncpy_from_user = strncpy_from_user_std, | ||
303 | .futex_atomic_op = futex_atomic_op_std, | ||
304 | .futex_atomic_cmpxchg = futex_atomic_cmpxchg_std, | ||
305 | }; | ||