diff options
-rw-r--r-- | arch/s390/kernel/head64.S | 13 | ||||
-rw-r--r-- | arch/s390/kernel/setup.c | 6 | ||||
-rw-r--r-- | arch/s390/lib/Makefile | 1 | ||||
-rw-r--r-- | arch/s390/lib/uaccess_mvcos.c | 156 | ||||
-rw-r--r-- | include/asm-s390/setup.h | 2 | ||||
-rw-r--r-- | include/asm-s390/uaccess.h | 1 |
6 files changed, 178 insertions, 1 deletions
diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S index 1ebaa338aa7e..a8bdd96494c7 100644 --- a/arch/s390/kernel/head64.S +++ b/arch/s390/kernel/head64.S | |||
@@ -250,6 +250,19 @@ startup_continue: | |||
250 | oi 7(%r12),0x80 # set IDTE flag | 250 | oi 7(%r12),0x80 # set IDTE flag |
251 | 0: | 251 | 0: |
252 | 252 | ||
253 | # | ||
254 | # find out if we have the MVCOS instruction | ||
255 | # | ||
256 | la %r1,0f-.LPG1(%r13) # set program check address | ||
257 | stg %r1,__LC_PGM_NEW_PSW+8 | ||
258 | .short 0xc800 # mvcos 0(%r0),0(%r0),%r0 | ||
259 | .short 0x0000 | ||
260 | .short 0x0000 | ||
261 | 0: tm 0x8f,0x13 # special-operation exception? | ||
262 | bno 1f-.LPG1(%r13) # if yes, MVCOS is present | ||
263 | oi 6(%r12),2 # set MVCOS flag | ||
264 | 1: | ||
265 | |||
253 | lpswe .Lentry-.LPG1(13) # jump to _stext in primary-space, | 266 | lpswe .Lentry-.LPG1(13) # jump to _stext in primary-space, |
254 | # virtual and never return ... | 267 | # virtual and never return ... |
255 | .align 16 | 268 | .align 16 |
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index e229af59976c..e3d9325f6022 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c | |||
@@ -647,7 +647,11 @@ setup_arch(char **cmdline_p) | |||
647 | 647 | ||
648 | memory_end = memory_size; | 648 | memory_end = memory_size; |
649 | 649 | ||
650 | memcpy(&uaccess, &uaccess_std, sizeof(uaccess)); | 650 | if (MACHINE_HAS_MVCOS) |
651 | memcpy(&uaccess, &uaccess_mvcos, sizeof(uaccess)); | ||
652 | else | ||
653 | memcpy(&uaccess, &uaccess_std, sizeof(uaccess)); | ||
654 | |||
651 | parse_early_param(); | 655 | parse_early_param(); |
652 | 656 | ||
653 | #ifndef CONFIG_64BIT | 657 | #ifndef CONFIG_64BIT |
diff --git a/arch/s390/lib/Makefile b/arch/s390/lib/Makefile index 96c82424d88b..c42ffedfdb49 100644 --- a/arch/s390/lib/Makefile +++ b/arch/s390/lib/Makefile | |||
@@ -5,4 +5,5 @@ | |||
5 | EXTRA_AFLAGS := -traditional | 5 | EXTRA_AFLAGS := -traditional |
6 | 6 | ||
7 | lib-y += delay.o string.o uaccess_std.o | 7 | lib-y += delay.o string.o uaccess_std.o |
8 | lib-$(CONFIG_64BIT) += uaccess_mvcos.o | ||
8 | lib-$(CONFIG_SMP) += spinlock.o | 9 | lib-$(CONFIG_SMP) += spinlock.o |
diff --git a/arch/s390/lib/uaccess_mvcos.c b/arch/s390/lib/uaccess_mvcos.c new file mode 100644 index 000000000000..86c96d6c191a --- /dev/null +++ b/arch/s390/lib/uaccess_mvcos.c | |||
@@ -0,0 +1,156 @@ | |||
1 | /* | ||
2 | * arch/s390/lib/uaccess_mvcos.c | ||
3 | * | ||
4 | * Optimized user space space access functions based on mvcos. | ||
5 | * | ||
6 | * Copyright (C) IBM Corp. 2006 | ||
7 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), | ||
8 | * Gerald Schaefer (gerald.schaefer@de.ibm.com) | ||
9 | */ | ||
10 | |||
11 | #include <linux/errno.h> | ||
12 | #include <linux/mm.h> | ||
13 | #include <asm/uaccess.h> | ||
14 | #include <asm/futex.h> | ||
15 | |||
16 | #ifndef __s390x__ | ||
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_mvcos(size_t size, const void __user *ptr, void *x) | ||
31 | { | ||
32 | register unsigned long reg0 asm("0") = 0x81UL; | ||
33 | unsigned long tmp1, tmp2; | ||
34 | |||
35 | tmp1 = -4096UL; | ||
36 | asm volatile( | ||
37 | "0: .insn ss,0xc80000000000,0(%0,%2),0(%1),0\n" | ||
38 | " jz 4f\n" | ||
39 | "1:"ALR" %0,%3\n" | ||
40 | " "SLR" %1,%3\n" | ||
41 | " "SLR" %2,%3\n" | ||
42 | " j 0b\n" | ||
43 | "2: la %4,4095(%1)\n"/* %4 = ptr + 4095 */ | ||
44 | " nr %4,%3\n" /* %4 = (ptr + 4095) & -4096 */ | ||
45 | " "SLR" %4,%1\n" | ||
46 | " "CLR" %0,%4\n" /* copy crosses next page boundary? */ | ||
47 | " jnh 5f\n" | ||
48 | "3: .insn ss,0xc80000000000,0(%4,%2),0(%1),0\n" | ||
49 | " "SLR" %0,%4\n" | ||
50 | " j 5f\n" | ||
51 | "4:"SLR" %0,%0\n" | ||
52 | "5: \n" | ||
53 | EX_TABLE(0b,2b) EX_TABLE(3b,5b) | ||
54 | : "+a" (size), "+a" (ptr), "+a" (x), "+a" (tmp1), "=a" (tmp2) | ||
55 | : "d" (reg0) : "cc", "memory"); | ||
56 | return size; | ||
57 | } | ||
58 | |||
59 | size_t copy_to_user_mvcos(size_t size, void __user *ptr, const void *x) | ||
60 | { | ||
61 | register unsigned long reg0 asm("0") = 0x810000UL; | ||
62 | unsigned long tmp1, tmp2; | ||
63 | |||
64 | tmp1 = -4096UL; | ||
65 | asm volatile( | ||
66 | "0: .insn ss,0xc80000000000,0(%0,%1),0(%2),0\n" | ||
67 | " jz 4f\n" | ||
68 | "1:"ALR" %0,%3\n" | ||
69 | " "SLR" %1,%3\n" | ||
70 | " "SLR" %2,%3\n" | ||
71 | " j 0b\n" | ||
72 | "2: la %4,4095(%1)\n"/* %4 = ptr + 4095 */ | ||
73 | " nr %4,%3\n" /* %4 = (ptr + 4095) & -4096 */ | ||
74 | " "SLR" %4,%1\n" | ||
75 | " "CLR" %0,%4\n" /* copy crosses next page boundary? */ | ||
76 | " jnh 5f\n" | ||
77 | "3: .insn ss,0xc80000000000,0(%4,%1),0(%2),0\n" | ||
78 | " "SLR" %0,%4\n" | ||
79 | " j 5f\n" | ||
80 | "4:"SLR" %0,%0\n" | ||
81 | "5: \n" | ||
82 | EX_TABLE(0b,2b) EX_TABLE(3b,5b) | ||
83 | : "+a" (size), "+a" (ptr), "+a" (x), "+a" (tmp1), "=a" (tmp2) | ||
84 | : "d" (reg0) : "cc", "memory"); | ||
85 | return size; | ||
86 | } | ||
87 | |||
88 | size_t copy_in_user_mvcos(size_t size, void __user *to, const void __user *from) | ||
89 | { | ||
90 | register unsigned long reg0 asm("0") = 0x810081UL; | ||
91 | unsigned long tmp1, tmp2; | ||
92 | |||
93 | tmp1 = -4096UL; | ||
94 | /* FIXME: copy with reduced length. */ | ||
95 | asm volatile( | ||
96 | "0: .insn ss,0xc80000000000,0(%0,%1),0(%2),0\n" | ||
97 | " jz 2f\n" | ||
98 | "1:"ALR" %0,%3\n" | ||
99 | " "SLR" %1,%3\n" | ||
100 | " "SLR" %2,%3\n" | ||
101 | " j 0b\n" | ||
102 | "2:"SLR" %0,%0\n" | ||
103 | "3: \n" | ||
104 | EX_TABLE(0b,3b) | ||
105 | : "+a" (size), "+a" (to), "+a" (from), "+a" (tmp1), "=a" (tmp2) | ||
106 | : "d" (reg0) : "cc", "memory"); | ||
107 | return size; | ||
108 | } | ||
109 | |||
110 | size_t clear_user_mvcos(size_t size, void __user *to) | ||
111 | { | ||
112 | register unsigned long reg0 asm("0") = 0x810000UL; | ||
113 | unsigned long tmp1, tmp2; | ||
114 | |||
115 | tmp1 = -4096UL; | ||
116 | asm volatile( | ||
117 | "0: .insn ss,0xc80000000000,0(%0,%1),0(%4),0\n" | ||
118 | " jz 4f\n" | ||
119 | "1:"ALR" %0,%2\n" | ||
120 | " "SLR" %1,%2\n" | ||
121 | " j 0b\n" | ||
122 | "2: la %3,4095(%1)\n"/* %4 = to + 4095 */ | ||
123 | " nr %3,%2\n" /* %4 = (to + 4095) & -4096 */ | ||
124 | " "SLR" %3,%1\n" | ||
125 | " "CLR" %0,%3\n" /* copy crosses next page boundary? */ | ||
126 | " jnh 5f\n" | ||
127 | "3: .insn ss,0xc80000000000,0(%3,%1),0(%4),0\n" | ||
128 | " "SLR" %0,%3\n" | ||
129 | " j 5f\n" | ||
130 | "4:"SLR" %0,%0\n" | ||
131 | "5: \n" | ||
132 | EX_TABLE(0b,2b) EX_TABLE(3b,5b) | ||
133 | : "+a" (size), "+a" (to), "+a" (tmp1), "=a" (tmp2) | ||
134 | : "a" (empty_zero_page), "d" (reg0) : "cc", "memory"); | ||
135 | return size; | ||
136 | } | ||
137 | |||
138 | extern size_t copy_from_user_std_small(size_t, const void __user *, void *); | ||
139 | extern size_t copy_to_user_std_small(size_t, void __user *, const void *); | ||
140 | extern size_t strnlen_user_std(size_t, const char __user *); | ||
141 | extern size_t strncpy_from_user_std(size_t, const char __user *, char *); | ||
142 | extern int futex_atomic_op(int, int __user *, int, int *); | ||
143 | extern int futex_atomic_cmpxchg(int __user *, int, int); | ||
144 | |||
145 | struct uaccess_ops uaccess_mvcos = { | ||
146 | .copy_from_user = copy_from_user_mvcos, | ||
147 | .copy_from_user_small = copy_from_user_std_small, | ||
148 | .copy_to_user = copy_to_user_mvcos, | ||
149 | .copy_to_user_small = copy_to_user_std_small, | ||
150 | .copy_in_user = copy_in_user_mvcos, | ||
151 | .clear_user = clear_user_mvcos, | ||
152 | .strnlen_user = strnlen_user_std, | ||
153 | .strncpy_from_user = strncpy_from_user_std, | ||
154 | .futex_atomic_op = futex_atomic_op, | ||
155 | .futex_atomic_cmpxchg = futex_atomic_cmpxchg, | ||
156 | }; | ||
diff --git a/include/asm-s390/setup.h b/include/asm-s390/setup.h index 00c03e46689b..f1959732b6fd 100644 --- a/include/asm-s390/setup.h +++ b/include/asm-s390/setup.h | |||
@@ -44,10 +44,12 @@ extern unsigned long machine_flags; | |||
44 | #define MACHINE_HAS_IEEE (machine_flags & 2) | 44 | #define MACHINE_HAS_IEEE (machine_flags & 2) |
45 | #define MACHINE_HAS_CSP (machine_flags & 8) | 45 | #define MACHINE_HAS_CSP (machine_flags & 8) |
46 | #define MACHINE_HAS_DIAG44 (1) | 46 | #define MACHINE_HAS_DIAG44 (1) |
47 | #define MACHINE_HAS_MVCOS (0) | ||
47 | #else /* __s390x__ */ | 48 | #else /* __s390x__ */ |
48 | #define MACHINE_HAS_IEEE (1) | 49 | #define MACHINE_HAS_IEEE (1) |
49 | #define MACHINE_HAS_CSP (1) | 50 | #define MACHINE_HAS_CSP (1) |
50 | #define MACHINE_HAS_DIAG44 (machine_flags & 32) | 51 | #define MACHINE_HAS_DIAG44 (machine_flags & 32) |
52 | #define MACHINE_HAS_MVCOS (machine_flags & 512) | ||
51 | #endif /* __s390x__ */ | 53 | #endif /* __s390x__ */ |
52 | 54 | ||
53 | 55 | ||
diff --git a/include/asm-s390/uaccess.h b/include/asm-s390/uaccess.h index 39a2716ae188..e2047b0c9092 100644 --- a/include/asm-s390/uaccess.h +++ b/include/asm-s390/uaccess.h | |||
@@ -100,6 +100,7 @@ struct uaccess_ops { | |||
100 | 100 | ||
101 | extern struct uaccess_ops uaccess; | 101 | extern struct uaccess_ops uaccess; |
102 | extern struct uaccess_ops uaccess_std; | 102 | extern struct uaccess_ops uaccess_std; |
103 | extern struct uaccess_ops uaccess_mvcos; | ||
103 | 104 | ||
104 | static inline int __put_user_fn(size_t size, void __user *ptr, void *x) | 105 | static inline int __put_user_fn(size_t size, void __user *ptr, void *x) |
105 | { | 106 | { |