Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * MMX 3DNow! library helper functions |
| 4 | * |
| 5 | * To do: |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 6 | * We can use MMX just for prefetch in IRQ's. This may be a win. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * (reported so on K6-III) |
| 8 | * We should use a better code neutral filler for the short jump |
| 9 | * leal ebx. [ebx] is apparently best for K6-2, but Cyrix ?? |
| 10 | * We also want to clobber the filler register so we don't get any |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 11 | * register forwarding stalls on the filler. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * |
| 13 | * Add *user handling. Checksums are not a win with MMX on any CPU |
| 14 | * tested so far for any MMX solution figured. |
| 15 | * |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 16 | * 22/09/2000 - Arjan van de Ven |
| 17 | * Improved for non-egineering-sample Athlons |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | * |
| 19 | */ |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 20 | #include <linux/hardirq.h> |
| 21 | #include <linux/string.h> |
Paul Gortmaker | e683014 | 2016-07-13 20:18:57 -0400 | [diff] [blame] | 22 | #include <linux/export.h> |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 23 | #include <linux/sched.h> |
| 24 | #include <linux/types.h> |
| 25 | |
Ingo Molnar | df6b35f | 2015-04-24 02:46:00 +0200 | [diff] [blame] | 26 | #include <asm/fpu/api.h> |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 27 | #include <asm/asm.h> |
| 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | void *_mmx_memcpy(void *to, const void *from, size_t len) |
| 30 | { |
| 31 | void *p; |
| 32 | int i; |
| 33 | |
| 34 | if (unlikely(in_interrupt())) |
| 35 | return __memcpy(to, from, len); |
| 36 | |
| 37 | p = to; |
| 38 | i = len >> 6; /* len/64 */ |
| 39 | |
| 40 | kernel_fpu_begin(); |
| 41 | |
| 42 | __asm__ __volatile__ ( |
| 43 | "1: prefetch (%0)\n" /* This set is 28 bytes */ |
| 44 | " prefetch 64(%0)\n" |
| 45 | " prefetch 128(%0)\n" |
| 46 | " prefetch 192(%0)\n" |
| 47 | " prefetch 256(%0)\n" |
| 48 | "2: \n" |
| 49 | ".section .fixup, \"ax\"\n" |
| 50 | "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */ |
| 51 | " jmp 2b\n" |
| 52 | ".previous\n" |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 53 | _ASM_EXTABLE(1b, 3b) |
| 54 | : : "r" (from)); |
| 55 | |
| 56 | for ( ; i > 5; i--) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | __asm__ __volatile__ ( |
| 58 | "1: prefetch 320(%0)\n" |
| 59 | "2: movq (%0), %%mm0\n" |
| 60 | " movq 8(%0), %%mm1\n" |
| 61 | " movq 16(%0), %%mm2\n" |
| 62 | " movq 24(%0), %%mm3\n" |
| 63 | " movq %%mm0, (%1)\n" |
| 64 | " movq %%mm1, 8(%1)\n" |
| 65 | " movq %%mm2, 16(%1)\n" |
| 66 | " movq %%mm3, 24(%1)\n" |
| 67 | " movq 32(%0), %%mm0\n" |
| 68 | " movq 40(%0), %%mm1\n" |
| 69 | " movq 48(%0), %%mm2\n" |
| 70 | " movq 56(%0), %%mm3\n" |
| 71 | " movq %%mm0, 32(%1)\n" |
| 72 | " movq %%mm1, 40(%1)\n" |
| 73 | " movq %%mm2, 48(%1)\n" |
| 74 | " movq %%mm3, 56(%1)\n" |
| 75 | ".section .fixup, \"ax\"\n" |
| 76 | "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */ |
| 77 | " jmp 2b\n" |
| 78 | ".previous\n" |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 79 | _ASM_EXTABLE(1b, 3b) |
| 80 | : : "r" (from), "r" (to) : "memory"); |
| 81 | |
| 82 | from += 64; |
| 83 | to += 64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 86 | for ( ; i > 0; i--) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | __asm__ __volatile__ ( |
| 88 | " movq (%0), %%mm0\n" |
| 89 | " movq 8(%0), %%mm1\n" |
| 90 | " movq 16(%0), %%mm2\n" |
| 91 | " movq 24(%0), %%mm3\n" |
| 92 | " movq %%mm0, (%1)\n" |
| 93 | " movq %%mm1, 8(%1)\n" |
| 94 | " movq %%mm2, 16(%1)\n" |
| 95 | " movq %%mm3, 24(%1)\n" |
| 96 | " movq 32(%0), %%mm0\n" |
| 97 | " movq 40(%0), %%mm1\n" |
| 98 | " movq 48(%0), %%mm2\n" |
| 99 | " movq 56(%0), %%mm3\n" |
| 100 | " movq %%mm0, 32(%1)\n" |
| 101 | " movq %%mm1, 40(%1)\n" |
| 102 | " movq %%mm2, 48(%1)\n" |
| 103 | " movq %%mm3, 56(%1)\n" |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 104 | : : "r" (from), "r" (to) : "memory"); |
| 105 | |
| 106 | from += 64; |
| 107 | to += 64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | } |
| 109 | /* |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 110 | * Now do the tail of the block: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | */ |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 112 | __memcpy(to, from, len & 63); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | kernel_fpu_end(); |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | return p; |
| 116 | } |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 117 | EXPORT_SYMBOL(_mmx_memcpy); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
| 119 | #ifdef CONFIG_MK7 |
| 120 | |
| 121 | /* |
| 122 | * The K7 has streaming cache bypass load/store. The Cyrix III, K6 and |
| 123 | * other MMX using processors do not. |
| 124 | */ |
| 125 | |
| 126 | static void fast_clear_page(void *page) |
| 127 | { |
| 128 | int i; |
| 129 | |
| 130 | kernel_fpu_begin(); |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | __asm__ __volatile__ ( |
| 133 | " pxor %%mm0, %%mm0\n" : : |
| 134 | ); |
| 135 | |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 136 | for (i = 0; i < 4096/64; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | __asm__ __volatile__ ( |
| 138 | " movntq %%mm0, (%0)\n" |
| 139 | " movntq %%mm0, 8(%0)\n" |
| 140 | " movntq %%mm0, 16(%0)\n" |
| 141 | " movntq %%mm0, 24(%0)\n" |
| 142 | " movntq %%mm0, 32(%0)\n" |
| 143 | " movntq %%mm0, 40(%0)\n" |
| 144 | " movntq %%mm0, 48(%0)\n" |
| 145 | " movntq %%mm0, 56(%0)\n" |
| 146 | : : "r" (page) : "memory"); |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 147 | page += 64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | } |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 149 | |
| 150 | /* |
| 151 | * Since movntq is weakly-ordered, a "sfence" is needed to become |
| 152 | * ordered again: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | */ |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 154 | __asm__ __volatile__("sfence\n"::); |
| 155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | kernel_fpu_end(); |
| 157 | } |
| 158 | |
| 159 | static void fast_copy_page(void *to, void *from) |
| 160 | { |
| 161 | int i; |
| 162 | |
| 163 | kernel_fpu_begin(); |
| 164 | |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 165 | /* |
| 166 | * maybe the prefetch stuff can go before the expensive fnsave... |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | * but that is for later. -AV |
| 168 | */ |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 169 | __asm__ __volatile__( |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | "1: prefetch (%0)\n" |
| 171 | " prefetch 64(%0)\n" |
| 172 | " prefetch 128(%0)\n" |
| 173 | " prefetch 192(%0)\n" |
| 174 | " prefetch 256(%0)\n" |
| 175 | "2: \n" |
| 176 | ".section .fixup, \"ax\"\n" |
| 177 | "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */ |
| 178 | " jmp 2b\n" |
| 179 | ".previous\n" |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 180 | _ASM_EXTABLE(1b, 3b) : : "r" (from)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 182 | for (i = 0; i < (4096-320)/64; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | __asm__ __volatile__ ( |
| 184 | "1: prefetch 320(%0)\n" |
| 185 | "2: movq (%0), %%mm0\n" |
| 186 | " movntq %%mm0, (%1)\n" |
| 187 | " movq 8(%0), %%mm1\n" |
| 188 | " movntq %%mm1, 8(%1)\n" |
| 189 | " movq 16(%0), %%mm2\n" |
| 190 | " movntq %%mm2, 16(%1)\n" |
| 191 | " movq 24(%0), %%mm3\n" |
| 192 | " movntq %%mm3, 24(%1)\n" |
| 193 | " movq 32(%0), %%mm4\n" |
| 194 | " movntq %%mm4, 32(%1)\n" |
| 195 | " movq 40(%0), %%mm5\n" |
| 196 | " movntq %%mm5, 40(%1)\n" |
| 197 | " movq 48(%0), %%mm6\n" |
| 198 | " movntq %%mm6, 48(%1)\n" |
| 199 | " movq 56(%0), %%mm7\n" |
| 200 | " movntq %%mm7, 56(%1)\n" |
| 201 | ".section .fixup, \"ax\"\n" |
| 202 | "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */ |
| 203 | " jmp 2b\n" |
| 204 | ".previous\n" |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 205 | _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory"); |
| 206 | |
| 207 | from += 64; |
| 208 | to += 64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | } |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 210 | |
| 211 | for (i = (4096-320)/64; i < 4096/64; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | __asm__ __volatile__ ( |
| 213 | "2: movq (%0), %%mm0\n" |
| 214 | " movntq %%mm0, (%1)\n" |
| 215 | " movq 8(%0), %%mm1\n" |
| 216 | " movntq %%mm1, 8(%1)\n" |
| 217 | " movq 16(%0), %%mm2\n" |
| 218 | " movntq %%mm2, 16(%1)\n" |
| 219 | " movq 24(%0), %%mm3\n" |
| 220 | " movntq %%mm3, 24(%1)\n" |
| 221 | " movq 32(%0), %%mm4\n" |
| 222 | " movntq %%mm4, 32(%1)\n" |
| 223 | " movq 40(%0), %%mm5\n" |
| 224 | " movntq %%mm5, 40(%1)\n" |
| 225 | " movq 48(%0), %%mm6\n" |
| 226 | " movntq %%mm6, 48(%1)\n" |
| 227 | " movq 56(%0), %%mm7\n" |
| 228 | " movntq %%mm7, 56(%1)\n" |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 229 | : : "r" (from), "r" (to) : "memory"); |
| 230 | from += 64; |
| 231 | to += 64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | } |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 233 | /* |
| 234 | * Since movntq is weakly-ordered, a "sfence" is needed to become |
| 235 | * ordered again: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | */ |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 237 | __asm__ __volatile__("sfence \n"::); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | kernel_fpu_end(); |
| 239 | } |
| 240 | |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 241 | #else /* CONFIG_MK7 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | |
| 243 | /* |
| 244 | * Generic MMX implementation without K7 specific streaming |
| 245 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | static void fast_clear_page(void *page) |
| 247 | { |
| 248 | int i; |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 249 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | kernel_fpu_begin(); |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 251 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | __asm__ __volatile__ ( |
| 253 | " pxor %%mm0, %%mm0\n" : : |
| 254 | ); |
| 255 | |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 256 | for (i = 0; i < 4096/128; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | __asm__ __volatile__ ( |
| 258 | " movq %%mm0, (%0)\n" |
| 259 | " movq %%mm0, 8(%0)\n" |
| 260 | " movq %%mm0, 16(%0)\n" |
| 261 | " movq %%mm0, 24(%0)\n" |
| 262 | " movq %%mm0, 32(%0)\n" |
| 263 | " movq %%mm0, 40(%0)\n" |
| 264 | " movq %%mm0, 48(%0)\n" |
| 265 | " movq %%mm0, 56(%0)\n" |
| 266 | " movq %%mm0, 64(%0)\n" |
| 267 | " movq %%mm0, 72(%0)\n" |
| 268 | " movq %%mm0, 80(%0)\n" |
| 269 | " movq %%mm0, 88(%0)\n" |
| 270 | " movq %%mm0, 96(%0)\n" |
| 271 | " movq %%mm0, 104(%0)\n" |
| 272 | " movq %%mm0, 112(%0)\n" |
| 273 | " movq %%mm0, 120(%0)\n" |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 274 | : : "r" (page) : "memory"); |
| 275 | page += 128; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | kernel_fpu_end(); |
| 279 | } |
| 280 | |
| 281 | static void fast_copy_page(void *to, void *from) |
| 282 | { |
| 283 | int i; |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 284 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | kernel_fpu_begin(); |
| 286 | |
| 287 | __asm__ __volatile__ ( |
| 288 | "1: prefetch (%0)\n" |
| 289 | " prefetch 64(%0)\n" |
| 290 | " prefetch 128(%0)\n" |
| 291 | " prefetch 192(%0)\n" |
| 292 | " prefetch 256(%0)\n" |
| 293 | "2: \n" |
| 294 | ".section .fixup, \"ax\"\n" |
| 295 | "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */ |
| 296 | " jmp 2b\n" |
| 297 | ".previous\n" |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 298 | _ASM_EXTABLE(1b, 3b) : : "r" (from)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 300 | for (i = 0; i < 4096/64; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | __asm__ __volatile__ ( |
| 302 | "1: prefetch 320(%0)\n" |
| 303 | "2: movq (%0), %%mm0\n" |
| 304 | " movq 8(%0), %%mm1\n" |
| 305 | " movq 16(%0), %%mm2\n" |
| 306 | " movq 24(%0), %%mm3\n" |
| 307 | " movq %%mm0, (%1)\n" |
| 308 | " movq %%mm1, 8(%1)\n" |
| 309 | " movq %%mm2, 16(%1)\n" |
| 310 | " movq %%mm3, 24(%1)\n" |
| 311 | " movq 32(%0), %%mm0\n" |
| 312 | " movq 40(%0), %%mm1\n" |
| 313 | " movq 48(%0), %%mm2\n" |
| 314 | " movq 56(%0), %%mm3\n" |
| 315 | " movq %%mm0, 32(%1)\n" |
| 316 | " movq %%mm1, 40(%1)\n" |
| 317 | " movq %%mm2, 48(%1)\n" |
| 318 | " movq %%mm3, 56(%1)\n" |
| 319 | ".section .fixup, \"ax\"\n" |
| 320 | "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */ |
| 321 | " jmp 2b\n" |
| 322 | ".previous\n" |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 323 | _ASM_EXTABLE(1b, 3b) |
| 324 | : : "r" (from), "r" (to) : "memory"); |
| 325 | |
| 326 | from += 64; |
| 327 | to += 64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | } |
| 329 | kernel_fpu_end(); |
| 330 | } |
| 331 | |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 332 | #endif /* !CONFIG_MK7 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | |
| 334 | /* |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 335 | * Favour MMX for page clear and copy: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | */ |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 337 | static void slow_zero_page(void *page) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | { |
| 339 | int d0, d1; |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 340 | |
| 341 | __asm__ __volatile__( |
| 342 | "cld\n\t" |
| 343 | "rep ; stosl" |
| 344 | |
| 345 | : "=&c" (d0), "=&D" (d1) |
| 346 | :"a" (0), "1" (page), "0" (1024) |
| 347 | :"memory"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | } |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 349 | |
| 350 | void mmx_clear_page(void *page) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | { |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 352 | if (unlikely(in_interrupt())) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | slow_zero_page(page); |
| 354 | else |
| 355 | fast_clear_page(page); |
| 356 | } |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 357 | EXPORT_SYMBOL(mmx_clear_page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | |
| 359 | static void slow_copy_page(void *to, void *from) |
| 360 | { |
| 361 | int d0, d1, d2; |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 362 | |
| 363 | __asm__ __volatile__( |
| 364 | "cld\n\t" |
| 365 | "rep ; movsl" |
| 366 | : "=&c" (d0), "=&D" (d1), "=&S" (d2) |
| 367 | : "0" (1024), "1" ((long) to), "2" ((long) from) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | : "memory"); |
| 369 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | |
| 371 | void mmx_copy_page(void *to, void *from) |
| 372 | { |
Ingo Molnar | ca5d3f1 | 2008-02-18 08:53:56 +0100 | [diff] [blame] | 373 | if (unlikely(in_interrupt())) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | slow_copy_page(to, from); |
| 375 | else |
| 376 | fast_copy_page(to, from); |
| 377 | } |
Alexey Dobriyan | 129f694 | 2005-06-23 00:08:33 -0700 | [diff] [blame] | 378 | EXPORT_SYMBOL(mmx_copy_page); |