Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Paolo Ciarrocchi | 3f50dbc | 2008-02-29 12:50:56 +0100 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * User address space access functions. |
| 4 | * The non inlined parts of asm-i386/uaccess.h are here. |
| 5 | * |
| 6 | * Copyright 1997 Andi Kleen <ak@muc.de> |
| 7 | * Copyright 1997 Linus Torvalds |
| 8 | */ |
Paul Gortmaker | e683014 | 2016-07-13 20:18:57 -0400 | [diff] [blame] | 9 | #include <linux/export.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 10 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <asm/mmx.h> |
H. Peter Anvin | 9c67512 | 2012-04-20 12:19:52 -0700 | [diff] [blame] | 12 | #include <asm/asm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Thomas Petazzoni | 8bfcb39 | 2008-08-18 12:33:20 +0200 | [diff] [blame] | 14 | #ifdef CONFIG_X86_INTEL_USERCOPY |
| 15 | /* |
| 16 | * Alignment at which movsl is preferred for bulk memory copies. |
| 17 | */ |
| 18 | struct movsl_mask movsl_mask __read_mostly; |
| 19 | #endif |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | static inline int __movsl_is_ok(unsigned long a1, unsigned long a2, unsigned long n) |
| 22 | { |
| 23 | #ifdef CONFIG_X86_INTEL_USERCOPY |
| 24 | if (n >= 64 && ((a1 ^ a2) & movsl_mask.mask)) |
| 25 | return 0; |
| 26 | #endif |
| 27 | return 1; |
| 28 | } |
Paolo Ciarrocchi | 3f50dbc | 2008-02-29 12:50:56 +0100 | [diff] [blame] | 29 | #define movsl_is_ok(a1, a2, n) \ |
| 30 | __movsl_is_ok((unsigned long)(a1), (unsigned long)(a2), (n)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | * Zero Userspace |
| 34 | */ |
| 35 | |
| 36 | #define __do_clear_user(addr,size) \ |
| 37 | do { \ |
| 38 | int __d0; \ |
Nick Piggin | 3ee1afa | 2008-09-10 13:37:17 +0200 | [diff] [blame] | 39 | might_fault(); \ |
Paolo Ciarrocchi | 3f50dbc | 2008-02-29 12:50:56 +0100 | [diff] [blame] | 40 | __asm__ __volatile__( \ |
H. Peter Anvin | 63bcff2 | 2012-09-21 12:43:12 -0700 | [diff] [blame] | 41 | ASM_STAC "\n" \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | "0: rep; stosl\n" \ |
| 43 | " movl %2,%0\n" \ |
| 44 | "1: rep; stosb\n" \ |
H. Peter Anvin | 63bcff2 | 2012-09-21 12:43:12 -0700 | [diff] [blame] | 45 | "2: " ASM_CLAC "\n" \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | ".section .fixup,\"ax\"\n" \ |
| 47 | "3: lea 0(%2,%0,4),%0\n" \ |
| 48 | " jmp 2b\n" \ |
| 49 | ".previous\n" \ |
Jann Horn | 75045f7 | 2018-08-28 22:14:18 +0200 | [diff] [blame] | 50 | _ASM_EXTABLE_UA(0b, 3b) \ |
| 51 | _ASM_EXTABLE_UA(1b, 2b) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | : "=&c"(size), "=&D" (__d0) \ |
| 53 | : "r"(size & 3), "0"(size / 4), "1"(addr), "a"(0)); \ |
| 54 | } while (0) |
| 55 | |
| 56 | /** |
Mike Rapoport | bc8ff3c | 2019-03-05 15:48:39 -0800 | [diff] [blame] | 57 | * clear_user - Zero a block of memory in user space. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | * @to: Destination address, in user space. |
| 59 | * @n: Number of bytes to zero. |
| 60 | * |
| 61 | * Zero a block of memory in user space. |
| 62 | * |
Mike Rapoport | bc8ff3c | 2019-03-05 15:48:39 -0800 | [diff] [blame] | 63 | * Return: number of bytes that could not be cleared. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | * On success, this will be zero. |
| 65 | */ |
| 66 | unsigned long |
| 67 | clear_user(void __user *to, unsigned long n) |
| 68 | { |
Ingo Molnar | 1d18ef4 | 2008-09-11 20:53:21 +0200 | [diff] [blame] | 69 | might_fault(); |
Linus Torvalds | 96d4f26 | 2019-01-03 18:57:57 -0800 | [diff] [blame] | 70 | if (access_ok(to, n)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | __do_clear_user(to, n); |
| 72 | return n; |
| 73 | } |
Alexey Dobriyan | 129f694 | 2005-06-23 00:08:33 -0700 | [diff] [blame] | 74 | EXPORT_SYMBOL(clear_user); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
| 76 | /** |
Mike Rapoport | bc8ff3c | 2019-03-05 15:48:39 -0800 | [diff] [blame] | 77 | * __clear_user - Zero a block of memory in user space, with less checking. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | * @to: Destination address, in user space. |
| 79 | * @n: Number of bytes to zero. |
| 80 | * |
| 81 | * Zero a block of memory in user space. Caller must check |
| 82 | * the specified block with access_ok() before calling this function. |
| 83 | * |
Mike Rapoport | bc8ff3c | 2019-03-05 15:48:39 -0800 | [diff] [blame] | 84 | * Return: number of bytes that could not be cleared. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | * On success, this will be zero. |
| 86 | */ |
| 87 | unsigned long |
| 88 | __clear_user(void __user *to, unsigned long n) |
| 89 | { |
| 90 | __do_clear_user(to, n); |
| 91 | return n; |
| 92 | } |
Alexey Dobriyan | 129f694 | 2005-06-23 00:08:33 -0700 | [diff] [blame] | 93 | EXPORT_SYMBOL(__clear_user); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | #ifdef CONFIG_X86_INTEL_USERCOPY |
| 96 | static unsigned long |
| 97 | __copy_user_intel(void __user *to, const void *from, unsigned long size) |
| 98 | { |
| 99 | int d0, d1; |
| 100 | __asm__ __volatile__( |
| 101 | " .align 2,0x90\n" |
| 102 | "1: movl 32(%4), %%eax\n" |
| 103 | " cmpl $67, %0\n" |
| 104 | " jbe 3f\n" |
| 105 | "2: movl 64(%4), %%eax\n" |
| 106 | " .align 2,0x90\n" |
| 107 | "3: movl 0(%4), %%eax\n" |
| 108 | "4: movl 4(%4), %%edx\n" |
| 109 | "5: movl %%eax, 0(%3)\n" |
| 110 | "6: movl %%edx, 4(%3)\n" |
| 111 | "7: movl 8(%4), %%eax\n" |
| 112 | "8: movl 12(%4),%%edx\n" |
| 113 | "9: movl %%eax, 8(%3)\n" |
| 114 | "10: movl %%edx, 12(%3)\n" |
| 115 | "11: movl 16(%4), %%eax\n" |
| 116 | "12: movl 20(%4), %%edx\n" |
| 117 | "13: movl %%eax, 16(%3)\n" |
| 118 | "14: movl %%edx, 20(%3)\n" |
| 119 | "15: movl 24(%4), %%eax\n" |
| 120 | "16: movl 28(%4), %%edx\n" |
| 121 | "17: movl %%eax, 24(%3)\n" |
| 122 | "18: movl %%edx, 28(%3)\n" |
| 123 | "19: movl 32(%4), %%eax\n" |
| 124 | "20: movl 36(%4), %%edx\n" |
| 125 | "21: movl %%eax, 32(%3)\n" |
| 126 | "22: movl %%edx, 36(%3)\n" |
| 127 | "23: movl 40(%4), %%eax\n" |
| 128 | "24: movl 44(%4), %%edx\n" |
| 129 | "25: movl %%eax, 40(%3)\n" |
| 130 | "26: movl %%edx, 44(%3)\n" |
| 131 | "27: movl 48(%4), %%eax\n" |
| 132 | "28: movl 52(%4), %%edx\n" |
| 133 | "29: movl %%eax, 48(%3)\n" |
| 134 | "30: movl %%edx, 52(%3)\n" |
| 135 | "31: movl 56(%4), %%eax\n" |
| 136 | "32: movl 60(%4), %%edx\n" |
| 137 | "33: movl %%eax, 56(%3)\n" |
| 138 | "34: movl %%edx, 60(%3)\n" |
| 139 | " addl $-64, %0\n" |
| 140 | " addl $64, %4\n" |
| 141 | " addl $64, %3\n" |
| 142 | " cmpl $63, %0\n" |
| 143 | " ja 1b\n" |
| 144 | "35: movl %0, %%eax\n" |
| 145 | " shrl $2, %0\n" |
| 146 | " andl $3, %%eax\n" |
| 147 | " cld\n" |
| 148 | "99: rep; movsl\n" |
| 149 | "36: movl %%eax, %0\n" |
| 150 | "37: rep; movsb\n" |
| 151 | "100:\n" |
| 152 | ".section .fixup,\"ax\"\n" |
| 153 | "101: lea 0(%%eax,%0,4),%0\n" |
| 154 | " jmp 100b\n" |
| 155 | ".previous\n" |
Jann Horn | 75045f7 | 2018-08-28 22:14:18 +0200 | [diff] [blame] | 156 | _ASM_EXTABLE_UA(1b, 100b) |
| 157 | _ASM_EXTABLE_UA(2b, 100b) |
| 158 | _ASM_EXTABLE_UA(3b, 100b) |
| 159 | _ASM_EXTABLE_UA(4b, 100b) |
| 160 | _ASM_EXTABLE_UA(5b, 100b) |
| 161 | _ASM_EXTABLE_UA(6b, 100b) |
| 162 | _ASM_EXTABLE_UA(7b, 100b) |
| 163 | _ASM_EXTABLE_UA(8b, 100b) |
| 164 | _ASM_EXTABLE_UA(9b, 100b) |
| 165 | _ASM_EXTABLE_UA(10b, 100b) |
| 166 | _ASM_EXTABLE_UA(11b, 100b) |
| 167 | _ASM_EXTABLE_UA(12b, 100b) |
| 168 | _ASM_EXTABLE_UA(13b, 100b) |
| 169 | _ASM_EXTABLE_UA(14b, 100b) |
| 170 | _ASM_EXTABLE_UA(15b, 100b) |
| 171 | _ASM_EXTABLE_UA(16b, 100b) |
| 172 | _ASM_EXTABLE_UA(17b, 100b) |
| 173 | _ASM_EXTABLE_UA(18b, 100b) |
| 174 | _ASM_EXTABLE_UA(19b, 100b) |
| 175 | _ASM_EXTABLE_UA(20b, 100b) |
| 176 | _ASM_EXTABLE_UA(21b, 100b) |
| 177 | _ASM_EXTABLE_UA(22b, 100b) |
| 178 | _ASM_EXTABLE_UA(23b, 100b) |
| 179 | _ASM_EXTABLE_UA(24b, 100b) |
| 180 | _ASM_EXTABLE_UA(25b, 100b) |
| 181 | _ASM_EXTABLE_UA(26b, 100b) |
| 182 | _ASM_EXTABLE_UA(27b, 100b) |
| 183 | _ASM_EXTABLE_UA(28b, 100b) |
| 184 | _ASM_EXTABLE_UA(29b, 100b) |
| 185 | _ASM_EXTABLE_UA(30b, 100b) |
| 186 | _ASM_EXTABLE_UA(31b, 100b) |
| 187 | _ASM_EXTABLE_UA(32b, 100b) |
| 188 | _ASM_EXTABLE_UA(33b, 100b) |
| 189 | _ASM_EXTABLE_UA(34b, 100b) |
| 190 | _ASM_EXTABLE_UA(35b, 100b) |
| 191 | _ASM_EXTABLE_UA(36b, 100b) |
| 192 | _ASM_EXTABLE_UA(37b, 100b) |
| 193 | _ASM_EXTABLE_UA(99b, 101b) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | : "=&c"(size), "=&D" (d0), "=&S" (d1) |
| 195 | : "1"(to), "2"(from), "0"(size) |
| 196 | : "eax", "edx", "memory"); |
| 197 | return size; |
| 198 | } |
| 199 | |
NeilBrown | 7c12d81 | 2006-06-25 05:48:02 -0700 | [diff] [blame] | 200 | static unsigned long __copy_user_intel_nocache(void *to, |
| 201 | const void __user *from, unsigned long size) |
| 202 | { |
Paolo Ciarrocchi | 3f50dbc | 2008-02-29 12:50:56 +0100 | [diff] [blame] | 203 | int d0, d1; |
NeilBrown | 7c12d81 | 2006-06-25 05:48:02 -0700 | [diff] [blame] | 204 | |
| 205 | __asm__ __volatile__( |
| 206 | " .align 2,0x90\n" |
| 207 | "0: movl 32(%4), %%eax\n" |
| 208 | " cmpl $67, %0\n" |
| 209 | " jbe 2f\n" |
| 210 | "1: movl 64(%4), %%eax\n" |
| 211 | " .align 2,0x90\n" |
| 212 | "2: movl 0(%4), %%eax\n" |
| 213 | "21: movl 4(%4), %%edx\n" |
| 214 | " movnti %%eax, 0(%3)\n" |
| 215 | " movnti %%edx, 4(%3)\n" |
| 216 | "3: movl 8(%4), %%eax\n" |
| 217 | "31: movl 12(%4),%%edx\n" |
| 218 | " movnti %%eax, 8(%3)\n" |
| 219 | " movnti %%edx, 12(%3)\n" |
| 220 | "4: movl 16(%4), %%eax\n" |
| 221 | "41: movl 20(%4), %%edx\n" |
| 222 | " movnti %%eax, 16(%3)\n" |
| 223 | " movnti %%edx, 20(%3)\n" |
| 224 | "10: movl 24(%4), %%eax\n" |
| 225 | "51: movl 28(%4), %%edx\n" |
| 226 | " movnti %%eax, 24(%3)\n" |
| 227 | " movnti %%edx, 28(%3)\n" |
| 228 | "11: movl 32(%4), %%eax\n" |
| 229 | "61: movl 36(%4), %%edx\n" |
| 230 | " movnti %%eax, 32(%3)\n" |
| 231 | " movnti %%edx, 36(%3)\n" |
| 232 | "12: movl 40(%4), %%eax\n" |
| 233 | "71: movl 44(%4), %%edx\n" |
| 234 | " movnti %%eax, 40(%3)\n" |
| 235 | " movnti %%edx, 44(%3)\n" |
| 236 | "13: movl 48(%4), %%eax\n" |
| 237 | "81: movl 52(%4), %%edx\n" |
| 238 | " movnti %%eax, 48(%3)\n" |
| 239 | " movnti %%edx, 52(%3)\n" |
| 240 | "14: movl 56(%4), %%eax\n" |
| 241 | "91: movl 60(%4), %%edx\n" |
| 242 | " movnti %%eax, 56(%3)\n" |
| 243 | " movnti %%edx, 60(%3)\n" |
| 244 | " addl $-64, %0\n" |
| 245 | " addl $64, %4\n" |
| 246 | " addl $64, %3\n" |
| 247 | " cmpl $63, %0\n" |
| 248 | " ja 0b\n" |
| 249 | " sfence \n" |
| 250 | "5: movl %0, %%eax\n" |
| 251 | " shrl $2, %0\n" |
| 252 | " andl $3, %%eax\n" |
| 253 | " cld\n" |
| 254 | "6: rep; movsl\n" |
| 255 | " movl %%eax,%0\n" |
| 256 | "7: rep; movsb\n" |
| 257 | "8:\n" |
| 258 | ".section .fixup,\"ax\"\n" |
| 259 | "9: lea 0(%%eax,%0,4),%0\n" |
| 260 | "16: jmp 8b\n" |
| 261 | ".previous\n" |
Jann Horn | 75045f7 | 2018-08-28 22:14:18 +0200 | [diff] [blame] | 262 | _ASM_EXTABLE_UA(0b, 16b) |
| 263 | _ASM_EXTABLE_UA(1b, 16b) |
| 264 | _ASM_EXTABLE_UA(2b, 16b) |
| 265 | _ASM_EXTABLE_UA(21b, 16b) |
| 266 | _ASM_EXTABLE_UA(3b, 16b) |
| 267 | _ASM_EXTABLE_UA(31b, 16b) |
| 268 | _ASM_EXTABLE_UA(4b, 16b) |
| 269 | _ASM_EXTABLE_UA(41b, 16b) |
| 270 | _ASM_EXTABLE_UA(10b, 16b) |
| 271 | _ASM_EXTABLE_UA(51b, 16b) |
| 272 | _ASM_EXTABLE_UA(11b, 16b) |
| 273 | _ASM_EXTABLE_UA(61b, 16b) |
| 274 | _ASM_EXTABLE_UA(12b, 16b) |
| 275 | _ASM_EXTABLE_UA(71b, 16b) |
| 276 | _ASM_EXTABLE_UA(13b, 16b) |
| 277 | _ASM_EXTABLE_UA(81b, 16b) |
| 278 | _ASM_EXTABLE_UA(14b, 16b) |
| 279 | _ASM_EXTABLE_UA(91b, 16b) |
| 280 | _ASM_EXTABLE_UA(6b, 9b) |
| 281 | _ASM_EXTABLE_UA(7b, 16b) |
NeilBrown | 7c12d81 | 2006-06-25 05:48:02 -0700 | [diff] [blame] | 282 | : "=&c"(size), "=&D" (d0), "=&S" (d1) |
| 283 | : "1"(to), "2"(from), "0"(size) |
| 284 | : "eax", "edx", "memory"); |
| 285 | return size; |
| 286 | } |
| 287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | #else |
Hiro Yoshioka | c22ce14 | 2006-06-23 02:04:16 -0700 | [diff] [blame] | 289 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | /* |
| 291 | * Leave these declared but undefined. They should not be any references to |
| 292 | * them |
| 293 | */ |
Hiro Yoshioka | c22ce14 | 2006-06-23 02:04:16 -0700 | [diff] [blame] | 294 | unsigned long __copy_user_intel(void __user *to, const void *from, |
| 295 | unsigned long size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | #endif /* CONFIG_X86_INTEL_USERCOPY */ |
| 297 | |
| 298 | /* Generic arbitrary sized copy. */ |
Paolo Ciarrocchi | 3f50dbc | 2008-02-29 12:50:56 +0100 | [diff] [blame] | 299 | #define __copy_user(to, from, size) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | do { \ |
| 301 | int __d0, __d1, __d2; \ |
| 302 | __asm__ __volatile__( \ |
| 303 | " cmp $7,%0\n" \ |
| 304 | " jbe 1f\n" \ |
| 305 | " movl %1,%0\n" \ |
| 306 | " negl %0\n" \ |
| 307 | " andl $7,%0\n" \ |
| 308 | " subl %0,%3\n" \ |
| 309 | "4: rep; movsb\n" \ |
| 310 | " movl %3,%0\n" \ |
| 311 | " shrl $2,%0\n" \ |
| 312 | " andl $3,%3\n" \ |
| 313 | " .align 2,0x90\n" \ |
| 314 | "0: rep; movsl\n" \ |
| 315 | " movl %3,%0\n" \ |
| 316 | "1: rep; movsb\n" \ |
| 317 | "2:\n" \ |
| 318 | ".section .fixup,\"ax\"\n" \ |
| 319 | "5: addl %3,%0\n" \ |
| 320 | " jmp 2b\n" \ |
| 321 | "3: lea 0(%3,%0,4),%0\n" \ |
| 322 | " jmp 2b\n" \ |
| 323 | ".previous\n" \ |
Jann Horn | 75045f7 | 2018-08-28 22:14:18 +0200 | [diff] [blame] | 324 | _ASM_EXTABLE_UA(4b, 5b) \ |
| 325 | _ASM_EXTABLE_UA(0b, 3b) \ |
| 326 | _ASM_EXTABLE_UA(1b, 2b) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | : "=&c"(size), "=&D" (__d0), "=&S" (__d1), "=r"(__d2) \ |
| 328 | : "3"(size), "0"(size), "1"(to), "2"(from) \ |
| 329 | : "memory"); \ |
| 330 | } while (0) |
| 331 | |
Al Viro | beba3a2 | 2017-03-25 19:33:21 -0400 | [diff] [blame] | 332 | unsigned long __copy_user_ll(void *to, const void *from, unsigned long n) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | { |
Dan Williams | 304ec1b | 2018-01-29 17:02:49 -0800 | [diff] [blame] | 334 | __uaccess_begin_nospec(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | if (movsl_is_ok(to, from, n)) |
| 336 | __copy_user(to, from, n); |
| 337 | else |
| 338 | n = __copy_user_intel(to, from, n); |
Dan Williams | b5c4ae4f | 2018-01-29 17:02:44 -0800 | [diff] [blame] | 339 | __uaccess_end(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | return n; |
| 341 | } |
Al Viro | beba3a2 | 2017-03-25 19:33:21 -0400 | [diff] [blame] | 342 | EXPORT_SYMBOL(__copy_user_ll); |
NeilBrown | 7c12d81 | 2006-06-25 05:48:02 -0700 | [diff] [blame] | 343 | |
NeilBrown | 7c12d81 | 2006-06-25 05:48:02 -0700 | [diff] [blame] | 344 | unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *from, |
| 345 | unsigned long n) |
| 346 | { |
Dan Williams | 304ec1b | 2018-01-29 17:02:49 -0800 | [diff] [blame] | 347 | __uaccess_begin_nospec(); |
NeilBrown | 7c12d81 | 2006-06-25 05:48:02 -0700 | [diff] [blame] | 348 | #ifdef CONFIG_X86_INTEL_USERCOPY |
Borislav Petkov | 054efb6 | 2016-03-29 17:42:00 +0200 | [diff] [blame] | 349 | if (n > 64 && static_cpu_has(X86_FEATURE_XMM2)) |
Paolo Ciarrocchi | 3f50dbc | 2008-02-29 12:50:56 +0100 | [diff] [blame] | 350 | n = __copy_user_intel_nocache(to, from, n); |
NeilBrown | 7c12d81 | 2006-06-25 05:48:02 -0700 | [diff] [blame] | 351 | else |
| 352 | __copy_user(to, from, n); |
| 353 | #else |
Paolo Ciarrocchi | 3f50dbc | 2008-02-29 12:50:56 +0100 | [diff] [blame] | 354 | __copy_user(to, from, n); |
NeilBrown | 7c12d81 | 2006-06-25 05:48:02 -0700 | [diff] [blame] | 355 | #endif |
Dan Williams | b5c4ae4f | 2018-01-29 17:02:44 -0800 | [diff] [blame] | 356 | __uaccess_end(); |
NeilBrown | 7c12d81 | 2006-06-25 05:48:02 -0700 | [diff] [blame] | 357 | return n; |
| 358 | } |
Andrew Morton | 914c826 | 2008-01-30 23:27:57 +0100 | [diff] [blame] | 359 | EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero); |