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"
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");
59 size_t copy_to_user_mvcos(size_t size, void __user *ptr, const void *x)
61 register unsigned long reg0 asm("0") = 0x810000UL;
62 unsigned long tmp1, tmp2;
66 "0: .insn ss,0xc80000000000,0(%0,%1),0(%2),0\n"
72 "2: la %4,4095(%1)\n"/* %4 = ptr + 4095 */
73 " nr %4,%3\n" /* %4 = (ptr + 4095) & -4096 */
75 " "CLR" %0,%4\n" /* copy crosses next page boundary? */
77 "3: .insn ss,0xc80000000000,0(%4,%1),0(%2),0\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");
88 size_t copy_in_user_mvcos(size_t size, void __user *to, const void __user *from)
90 register unsigned long reg0 asm("0") = 0x810081UL;
91 unsigned long tmp1, tmp2;
94 /* FIXME: copy with reduced length. */
96 "0: .insn ss,0xc80000000000,0(%0,%1),0(%2),0\n"
105 : "+a" (size), "+a" (to), "+a" (from), "+a" (tmp1), "=a" (tmp2)
106 : "d" (reg0) : "cc", "memory");
110 size_t clear_user_mvcos(size_t size, void __user *to)
112 register unsigned long reg0 asm("0") = 0x810000UL;
113 unsigned long tmp1, tmp2;
117 "0: .insn ss,0xc80000000000,0(%0,%1),0(%4),0\n"
122 "2: la %3,4095(%1)\n"/* %4 = to + 4095 */
123 " nr %3,%2\n" /* %4 = (to + 4095) & -4096 */
125 " "CLR" %0,%3\n" /* copy crosses next page boundary? */
127 "3: .insn ss,0xc80000000000,0(%3,%1),0(%4),0\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");
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);
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,