2 * arch/s390/lib/uaccess_mvcos.c
4 * Optimized user space space access functions based on mvcos.
6 * Copyright (C) IBM Corp. 2006
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
8 * Gerald Schaefer (gerald.schaefer@de.ibm.com)
11 #include <linux/errno.h>
13 #include <asm/uaccess.h>
14 #include <asm/futex.h>
30 size_t copy_from_user_mvcos(size_t size, const void __user *ptr, void *x)
32 register unsigned long reg0 asm("0") = 0x81UL;
33 unsigned long tmp1, tmp2;
37 "0: .insn ss,0xc80000000000,0(%0,%2),0(%1),0\n"
43 "2: la %4,4095(%1)\n"/* %4 = ptr + 4095 */
44 " nr %4,%3\n" /* %4 = (ptr + 4095) & -4096 */
46 " "CLR" %0,%4\n" /* copy crosses next page boundary? */
48 "3: .insn ss,0xc80000000000,0(%4,%2),0(%1),0\n"
52 " "ALR" %4,%0\n" /* copy remaining size, subtract 1 */
53 " bras %3,6f\n" /* memset loop */
55 "5: xc 0(256,%2),0(%2)\n"
63 EX_TABLE(0b,2b) EX_TABLE(3b,4b)
64 : "+a" (size), "+a" (ptr), "+a" (x), "+a" (tmp1), "=a" (tmp2)
65 : "d" (reg0) : "cc", "memory");
69 size_t copy_to_user_mvcos(size_t size, void __user *ptr, const void *x)
71 register unsigned long reg0 asm("0") = 0x810000UL;
72 unsigned long tmp1, tmp2;
76 "0: .insn ss,0xc80000000000,0(%0,%1),0(%2),0\n"
82 "2: la %4,4095(%1)\n"/* %4 = ptr + 4095 */
83 " nr %4,%3\n" /* %4 = (ptr + 4095) & -4096 */
85 " "CLR" %0,%4\n" /* copy crosses next page boundary? */
87 "3: .insn ss,0xc80000000000,0(%4,%1),0(%2),0\n"
92 EX_TABLE(0b,2b) EX_TABLE(3b,5b)
93 : "+a" (size), "+a" (ptr), "+a" (x), "+a" (tmp1), "=a" (tmp2)
94 : "d" (reg0) : "cc", "memory");
98 size_t copy_in_user_mvcos(size_t size, void __user *to, const void __user *from)
100 register unsigned long reg0 asm("0") = 0x810081UL;
101 unsigned long tmp1, tmp2;
104 /* FIXME: copy with reduced length. */
106 "0: .insn ss,0xc80000000000,0(%0,%1),0(%2),0\n"
115 : "+a" (size), "+a" (to), "+a" (from), "+a" (tmp1), "=a" (tmp2)
116 : "d" (reg0) : "cc", "memory");
120 size_t clear_user_mvcos(size_t size, void __user *to)
122 register unsigned long reg0 asm("0") = 0x810000UL;
123 unsigned long tmp1, tmp2;
127 "0: .insn ss,0xc80000000000,0(%0,%1),0(%4),0\n"
132 "2: la %3,4095(%1)\n"/* %4 = to + 4095 */
133 " nr %3,%2\n" /* %4 = (to + 4095) & -4096 */
135 " "CLR" %0,%3\n" /* copy crosses next page boundary? */
137 "3: .insn ss,0xc80000000000,0(%3,%1),0(%4),0\n"
142 EX_TABLE(0b,2b) EX_TABLE(3b,5b)
143 : "+a" (size), "+a" (to), "+a" (tmp1), "=a" (tmp2)
144 : "a" (empty_zero_page), "d" (reg0) : "cc", "memory");
148 extern size_t copy_from_user_std_small(size_t, const void __user *, void *);
149 extern size_t copy_to_user_std_small(size_t, void __user *, const void *);
150 extern size_t strnlen_user_std(size_t, const char __user *);
151 extern size_t strncpy_from_user_std(size_t, const char __user *, char *);
152 extern int futex_atomic_op(int, int __user *, int, int *);
153 extern int futex_atomic_cmpxchg(int __user *, int, int);
155 struct uaccess_ops uaccess_mvcos = {
156 .copy_from_user = copy_from_user_mvcos,
157 .copy_from_user_small = copy_from_user_std_small,
158 .copy_to_user = copy_to_user_mvcos,
159 .copy_to_user_small = copy_to_user_std_small,
160 .copy_in_user = copy_in_user_mvcos,
161 .clear_user = clear_user_mvcos,
162 .strnlen_user = strnlen_user_std,
163 .strncpy_from_user = strncpy_from_user_std,
164 .futex_atomic_op = futex_atomic_op,
165 .futex_atomic_cmpxchg = futex_atomic_cmpxchg,