Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Standard user space access functions based on mvcp/mvcs and doing |
| 4 | * interesting things in the secondary space mode. |
| 5 | * |
| 6 | * Copyright IBM Corp. 2006,2014 |
| 7 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), |
| 8 | * Gerald Schaefer (gerald.schaefer@de.ibm.com) |
| 9 | */ |
| 10 | |
| 11 | #include <linux/jump_label.h> |
| 12 | #include <linux/uaccess.h> |
| 13 | #include <linux/export.h> |
| 14 | #include <linux/errno.h> |
| 15 | #include <linux/mm.h> |
| 16 | #include <asm/mmu_context.h> |
| 17 | #include <asm/facility.h> |
| 18 | |
Sven Schnelle | 56e62a7 | 2020-11-21 11:14:56 +0100 | [diff] [blame] | 19 | #ifdef CONFIG_DEBUG_ENTRY |
| 20 | void debug_user_asce(int exit) |
Heiko Carstens | 062e527 | 2020-11-16 08:06:41 +0100 | [diff] [blame] | 21 | { |
| 22 | unsigned long cr1, cr7; |
| 23 | |
| 24 | __ctl_store(cr1, 1, 1); |
| 25 | __ctl_store(cr7, 7, 7); |
| 26 | if (cr1 == S390_lowcore.kernel_asce && cr7 == S390_lowcore.user_asce) |
| 27 | return; |
Sven Schnelle | 56e62a7 | 2020-11-21 11:14:56 +0100 | [diff] [blame] | 28 | panic("incorrect ASCE on kernel %s\n" |
Heiko Carstens | 062e527 | 2020-11-16 08:06:41 +0100 | [diff] [blame] | 29 | "cr1: %016lx cr7: %016lx\n" |
| 30 | "kernel: %016llx user: %016llx\n", |
Sven Schnelle | 56e62a7 | 2020-11-21 11:14:56 +0100 | [diff] [blame] | 31 | exit ? "exit" : "entry", cr1, cr7, |
| 32 | S390_lowcore.kernel_asce, S390_lowcore.user_asce); |
| 33 | |
Heiko Carstens | 062e527 | 2020-11-16 08:06:41 +0100 | [diff] [blame] | 34 | } |
Sven Schnelle | 56e62a7 | 2020-11-21 11:14:56 +0100 | [diff] [blame] | 35 | #endif /*CONFIG_DEBUG_ENTRY */ |
Heiko Carstens | 062e527 | 2020-11-16 08:06:41 +0100 | [diff] [blame] | 36 | |
Martin Schwidefsky | d66bf80 | 2017-08-21 14:47:04 +0200 | [diff] [blame] | 37 | #ifndef CONFIG_HAVE_MARCH_Z10_FEATURES |
Heiko Carstens | ed79e94 | 2015-07-29 08:31:24 +0200 | [diff] [blame] | 38 | static DEFINE_STATIC_KEY_FALSE(have_mvcos); |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 39 | |
Martin Schwidefsky | d66bf80 | 2017-08-21 14:47:04 +0200 | [diff] [blame] | 40 | static int __init uaccess_init(void) |
| 41 | { |
| 42 | if (test_facility(27)) |
| 43 | static_branch_enable(&have_mvcos); |
| 44 | return 0; |
| 45 | } |
| 46 | early_initcall(uaccess_init); |
| 47 | |
| 48 | static inline int copy_with_mvcos(void) |
| 49 | { |
| 50 | if (static_branch_likely(&have_mvcos)) |
| 51 | return 1; |
| 52 | return 0; |
| 53 | } |
| 54 | #else |
| 55 | static inline int copy_with_mvcos(void) |
| 56 | { |
| 57 | return 1; |
| 58 | } |
| 59 | #endif |
| 60 | |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 61 | static inline unsigned long copy_from_user_mvcos(void *x, const void __user *ptr, |
| 62 | unsigned long size) |
| 63 | { |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 64 | unsigned long tmp1, tmp2; |
Nico Boehr | 012a224 | 2022-01-11 11:00:03 +0100 | [diff] [blame] | 65 | union oac spec = { |
| 66 | .oac2.as = PSW_BITS_AS_SECONDARY, |
| 67 | .oac2.a = 1, |
| 68 | }; |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 69 | |
| 70 | tmp1 = -4096UL; |
| 71 | asm volatile( |
Nico Boehr | 012a224 | 2022-01-11 11:00:03 +0100 | [diff] [blame] | 72 | " lr 0,%[spec]\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 73 | "0: .insn ss,0xc80000000000,0(%0,%2),0(%1),0\n" |
Al Viro | 3709600 | 2017-03-28 15:06:24 -0400 | [diff] [blame] | 74 | "6: jz 4f\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 75 | "1: algr %0,%3\n" |
| 76 | " slgr %1,%3\n" |
| 77 | " slgr %2,%3\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 78 | " j 0b\n" |
| 79 | "2: la %4,4095(%1)\n"/* %4 = ptr + 4095 */ |
| 80 | " nr %4,%3\n" /* %4 = (ptr + 4095) & -4096 */ |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 81 | " slgr %4,%1\n" |
| 82 | " clgr %0,%4\n" /* copy crosses next page boundary? */ |
Al Viro | 3709600 | 2017-03-28 15:06:24 -0400 | [diff] [blame] | 83 | " jnh 5f\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 84 | "3: .insn ss,0xc80000000000,0(%4,%2),0(%1),0\n" |
Al Viro | 3709600 | 2017-03-28 15:06:24 -0400 | [diff] [blame] | 85 | "7: slgr %0,%4\n" |
| 86 | " j 5f\n" |
| 87 | "4: slgr %0,%0\n" |
| 88 | "5:\n" |
| 89 | EX_TABLE(0b,2b) EX_TABLE(3b,5b) EX_TABLE(6b,2b) EX_TABLE(7b,5b) |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 90 | : "+a" (size), "+a" (ptr), "+a" (x), "+a" (tmp1), "=a" (tmp2) |
Nico Boehr | 012a224 | 2022-01-11 11:00:03 +0100 | [diff] [blame] | 91 | : [spec] "d" (spec.val) |
Heiko Carstens | d1e18ef | 2021-06-21 13:38:45 +0200 | [diff] [blame] | 92 | : "cc", "memory", "0"); |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 93 | return size; |
| 94 | } |
| 95 | |
| 96 | static inline unsigned long copy_from_user_mvcp(void *x, const void __user *ptr, |
| 97 | unsigned long size) |
| 98 | { |
| 99 | unsigned long tmp1, tmp2; |
| 100 | |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 101 | tmp1 = -256UL; |
| 102 | asm volatile( |
| 103 | " sacf 0\n" |
| 104 | "0: mvcp 0(%0,%2),0(%1),%3\n" |
Al Viro | 3709600 | 2017-03-28 15:06:24 -0400 | [diff] [blame] | 105 | "7: jz 5f\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 106 | "1: algr %0,%3\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 107 | " la %1,256(%1)\n" |
| 108 | " la %2,256(%2)\n" |
| 109 | "2: mvcp 0(%0,%2),0(%1),%3\n" |
Al Viro | 3709600 | 2017-03-28 15:06:24 -0400 | [diff] [blame] | 110 | "8: jnz 1b\n" |
| 111 | " j 5f\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 112 | "3: la %4,255(%1)\n" /* %4 = ptr + 255 */ |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 113 | " lghi %3,-4096\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 114 | " nr %4,%3\n" /* %4 = (ptr + 255) & -4096 */ |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 115 | " slgr %4,%1\n" |
| 116 | " clgr %0,%4\n" /* copy crosses next page boundary? */ |
Al Viro | 3709600 | 2017-03-28 15:06:24 -0400 | [diff] [blame] | 117 | " jnh 6f\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 118 | "4: mvcp 0(%4,%2),0(%1),%3\n" |
Al Viro | 3709600 | 2017-03-28 15:06:24 -0400 | [diff] [blame] | 119 | "9: slgr %0,%4\n" |
| 120 | " j 6f\n" |
| 121 | "5: slgr %0,%0\n" |
| 122 | "6: sacf 768\n" |
| 123 | EX_TABLE(0b,3b) EX_TABLE(2b,3b) EX_TABLE(4b,6b) |
| 124 | EX_TABLE(7b,3b) EX_TABLE(8b,3b) EX_TABLE(9b,6b) |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 125 | : "+a" (size), "+a" (ptr), "+a" (x), "+a" (tmp1), "=a" (tmp2) |
| 126 | : : "cc", "memory"); |
| 127 | return size; |
| 128 | } |
| 129 | |
Al Viro | 3709600 | 2017-03-28 15:06:24 -0400 | [diff] [blame] | 130 | unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n) |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 131 | { |
Martin Schwidefsky | d66bf80 | 2017-08-21 14:47:04 +0200 | [diff] [blame] | 132 | if (copy_with_mvcos()) |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 133 | return copy_from_user_mvcos(to, from, n); |
| 134 | return copy_from_user_mvcp(to, from, n); |
| 135 | } |
Al Viro | 3709600 | 2017-03-28 15:06:24 -0400 | [diff] [blame] | 136 | EXPORT_SYMBOL(raw_copy_from_user); |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 137 | |
| 138 | static inline unsigned long copy_to_user_mvcos(void __user *ptr, const void *x, |
| 139 | unsigned long size) |
| 140 | { |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 141 | unsigned long tmp1, tmp2; |
Nico Boehr | 012a224 | 2022-01-11 11:00:03 +0100 | [diff] [blame] | 142 | union oac spec = { |
| 143 | .oac1.as = PSW_BITS_AS_SECONDARY, |
| 144 | .oac1.a = 1, |
| 145 | }; |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 146 | |
| 147 | tmp1 = -4096UL; |
| 148 | asm volatile( |
Nico Boehr | 012a224 | 2022-01-11 11:00:03 +0100 | [diff] [blame] | 149 | " lr 0,%[spec]\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 150 | "0: .insn ss,0xc80000000000,0(%0,%1),0(%2),0\n" |
| 151 | "6: jz 4f\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 152 | "1: algr %0,%3\n" |
| 153 | " slgr %1,%3\n" |
| 154 | " slgr %2,%3\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 155 | " j 0b\n" |
| 156 | "2: la %4,4095(%1)\n"/* %4 = ptr + 4095 */ |
| 157 | " nr %4,%3\n" /* %4 = (ptr + 4095) & -4096 */ |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 158 | " slgr %4,%1\n" |
| 159 | " clgr %0,%4\n" /* copy crosses next page boundary? */ |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 160 | " jnh 5f\n" |
| 161 | "3: .insn ss,0xc80000000000,0(%4,%1),0(%2),0\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 162 | "7: slgr %0,%4\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 163 | " j 5f\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 164 | "4: slgr %0,%0\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 165 | "5:\n" |
| 166 | EX_TABLE(0b,2b) EX_TABLE(3b,5b) EX_TABLE(6b,2b) EX_TABLE(7b,5b) |
| 167 | : "+a" (size), "+a" (ptr), "+a" (x), "+a" (tmp1), "=a" (tmp2) |
Nico Boehr | 012a224 | 2022-01-11 11:00:03 +0100 | [diff] [blame] | 168 | : [spec] "d" (spec.val) |
Heiko Carstens | d1e18ef | 2021-06-21 13:38:45 +0200 | [diff] [blame] | 169 | : "cc", "memory", "0"); |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 170 | return size; |
| 171 | } |
| 172 | |
| 173 | static inline unsigned long copy_to_user_mvcs(void __user *ptr, const void *x, |
| 174 | unsigned long size) |
| 175 | { |
| 176 | unsigned long tmp1, tmp2; |
| 177 | |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 178 | tmp1 = -256UL; |
| 179 | asm volatile( |
| 180 | " sacf 0\n" |
| 181 | "0: mvcs 0(%0,%1),0(%2),%3\n" |
| 182 | "7: jz 5f\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 183 | "1: algr %0,%3\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 184 | " la %1,256(%1)\n" |
| 185 | " la %2,256(%2)\n" |
| 186 | "2: mvcs 0(%0,%1),0(%2),%3\n" |
| 187 | "8: jnz 1b\n" |
| 188 | " j 5f\n" |
| 189 | "3: la %4,255(%1)\n" /* %4 = ptr + 255 */ |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 190 | " lghi %3,-4096\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 191 | " nr %4,%3\n" /* %4 = (ptr + 255) & -4096 */ |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 192 | " slgr %4,%1\n" |
| 193 | " clgr %0,%4\n" /* copy crosses next page boundary? */ |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 194 | " jnh 6f\n" |
| 195 | "4: mvcs 0(%4,%1),0(%2),%3\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 196 | "9: slgr %0,%4\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 197 | " j 6f\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 198 | "5: slgr %0,%0\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 199 | "6: sacf 768\n" |
| 200 | EX_TABLE(0b,3b) EX_TABLE(2b,3b) EX_TABLE(4b,6b) |
| 201 | EX_TABLE(7b,3b) EX_TABLE(8b,3b) EX_TABLE(9b,6b) |
| 202 | : "+a" (size), "+a" (ptr), "+a" (x), "+a" (tmp1), "=a" (tmp2) |
| 203 | : : "cc", "memory"); |
| 204 | return size; |
| 205 | } |
| 206 | |
Al Viro | 3709600 | 2017-03-28 15:06:24 -0400 | [diff] [blame] | 207 | unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n) |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 208 | { |
Martin Schwidefsky | d66bf80 | 2017-08-21 14:47:04 +0200 | [diff] [blame] | 209 | if (copy_with_mvcos()) |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 210 | return copy_to_user_mvcos(to, from, n); |
| 211 | return copy_to_user_mvcs(to, from, n); |
| 212 | } |
Al Viro | 3709600 | 2017-03-28 15:06:24 -0400 | [diff] [blame] | 213 | EXPORT_SYMBOL(raw_copy_to_user); |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 214 | |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 215 | static inline unsigned long clear_user_mvcos(void __user *to, unsigned long size) |
| 216 | { |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 217 | unsigned long tmp1, tmp2; |
Nico Boehr | 012a224 | 2022-01-11 11:00:03 +0100 | [diff] [blame] | 218 | union oac spec = { |
| 219 | .oac1.as = PSW_BITS_AS_SECONDARY, |
| 220 | .oac1.a = 1, |
| 221 | }; |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 222 | |
| 223 | tmp1 = -4096UL; |
| 224 | asm volatile( |
Nico Boehr | 012a224 | 2022-01-11 11:00:03 +0100 | [diff] [blame] | 225 | " lr 0,%[spec]\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 226 | "0: .insn ss,0xc80000000000,0(%0,%1),0(%4),0\n" |
| 227 | " jz 4f\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 228 | "1: algr %0,%2\n" |
| 229 | " slgr %1,%2\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 230 | " j 0b\n" |
| 231 | "2: la %3,4095(%1)\n"/* %4 = to + 4095 */ |
| 232 | " nr %3,%2\n" /* %4 = (to + 4095) & -4096 */ |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 233 | " slgr %3,%1\n" |
| 234 | " clgr %0,%3\n" /* copy crosses next page boundary? */ |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 235 | " jnh 5f\n" |
| 236 | "3: .insn ss,0xc80000000000,0(%3,%1),0(%4),0\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 237 | " slgr %0,%3\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 238 | " j 5f\n" |
Heiko Carstens | b8ac5e2 | 2016-06-10 09:35:51 +0200 | [diff] [blame] | 239 | "4: slgr %0,%0\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 240 | "5:\n" |
| 241 | EX_TABLE(0b,2b) EX_TABLE(3b,5b) |
| 242 | : "+a" (size), "+a" (to), "+a" (tmp1), "=a" (tmp2) |
Nico Boehr | 012a224 | 2022-01-11 11:00:03 +0100 | [diff] [blame] | 243 | : "a" (empty_zero_page), [spec] "d" (spec.val) |
Heiko Carstens | d1e18ef | 2021-06-21 13:38:45 +0200 | [diff] [blame] | 244 | : "cc", "memory", "0"); |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 245 | return size; |
| 246 | } |
| 247 | |
| 248 | static inline unsigned long clear_user_xc(void __user *to, unsigned long size) |
| 249 | { |
| 250 | unsigned long tmp1, tmp2; |
| 251 | |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 252 | asm volatile( |
| 253 | " sacf 256\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 254 | " aghi %0,-1\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 255 | " jo 5f\n" |
| 256 | " bras %3,3f\n" |
| 257 | " xc 0(1,%1),0(%1)\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 258 | "0: aghi %0,257\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 259 | " la %2,255(%1)\n" /* %2 = ptr + 255 */ |
| 260 | " srl %2,12\n" |
| 261 | " sll %2,12\n" /* %2 = (ptr + 255) & -4096 */ |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 262 | " slgr %2,%1\n" |
| 263 | " clgr %0,%2\n" /* clear crosses next page boundary? */ |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 264 | " jnh 5f\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 265 | " aghi %2,-1\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 266 | "1: ex %2,0(%3)\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 267 | " aghi %2,1\n" |
| 268 | " slgr %0,%2\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 269 | " j 5f\n" |
| 270 | "2: xc 0(256,%1),0(%1)\n" |
| 271 | " la %1,256(%1)\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 272 | "3: aghi %0,-256\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 273 | " jnm 2b\n" |
| 274 | "4: ex %0,0(%3)\n" |
Heiko Carstens | 5a79859a | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 275 | "5: slgr %0,%0\n" |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 276 | "6: sacf 768\n" |
| 277 | EX_TABLE(1b,6b) EX_TABLE(2b,0b) EX_TABLE(4b,0b) |
| 278 | : "+a" (size), "+a" (to), "=a" (tmp1), "=a" (tmp2) |
| 279 | : : "cc", "memory"); |
| 280 | return size; |
| 281 | } |
| 282 | |
| 283 | unsigned long __clear_user(void __user *to, unsigned long size) |
| 284 | { |
Martin Schwidefsky | d66bf80 | 2017-08-21 14:47:04 +0200 | [diff] [blame] | 285 | if (copy_with_mvcos()) |
Heiko Carstens | 457f218 | 2014-03-21 10:42:25 +0100 | [diff] [blame] | 286 | return clear_user_mvcos(to, size); |
| 287 | return clear_user_xc(to, size); |
| 288 | } |
| 289 | EXPORT_SYMBOL(__clear_user); |