2 * Copyright (C) 2002 Paul Mackerras, IBM Corp.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 #include <asm/processor.h>
10 #include <asm/ppc_asm.h>
11 #include <asm/export.h>
12 #include <asm/asm-compat.h>
13 #include <asm/feature-fixups.h>
16 #define sLd sld /* Shift towards low-numbered address. */
17 #define sHd srd /* Shift towards high-numbered address. */
19 #define sLd srd /* Shift towards low-numbered address. */
20 #define sHd sld /* Shift towards high-numbered address. */
24 _GLOBAL_TOC(__copy_tofrom_user)
25 #ifdef CONFIG_PPC_BOOK3S_64
29 b __copy_tofrom_user_power7
30 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_VMX_COPY)
32 _GLOBAL(__copy_tofrom_user_base)
33 /* first check for a whole page copy on a page boundary */
37 neg r6,r3 /* LS 3 bits = # bytes to 8-byte dest bdry */
40 crand cr0*4+2,cr0*4+2,cr6*4+2
48 /* Below we want to nop out the bne if we're on a CPU that has the
49 * CPU_FTR_UNALIGNED_LD_STD bit set and the CPU_FTR_CP_USE_DCBTZ bit
51 * At the time of writing the only CPU that has this combination of bits
58 ALT_FTR_SECTION_END(CPU_FTR_UNALIGNED_LD_STD | CPU_FTR_CP_USE_DCBTZ, \
59 CPU_FTR_UNALIGNED_LD_STD)
65 END_FTR_SECTION_IFCLR(CPU_FTR_UNALIGNED_LD_STD)
66 blt cr1,.Ldo_tail /* if < 16 bytes to copy */
132 24: ld r9,0(r4) /* 3+2n loads, 2+2n stores */
143 28: ld r0,0(r4) /* 4+2n loads, 3+2n stores */
188 #ifdef __BIG_ENDIAN__
192 #ifdef __LITTLE_ENDIAN__
197 #ifdef __BIG_ENDIAN__
201 #ifdef __LITTLE_ENDIAN__
206 #ifdef __BIG_ENDIAN__
210 #ifdef __LITTLE_ENDIAN__
217 PPC_MTOCRF(0x01,r6) /* put #bytes to 8B bdry into cr7 */
232 3: PPC_MTOCRF(0x01,r5)
262 * exception handlers follow
263 * we have to return the number of bytes not copied
264 * for an exception on a load, we set the rest of the destination to 0
303 * here we have had a fault on a load and r3 points to the first
304 * unmodified byte of the destination
311 subf r5,r6,r5 /* #bytes left to go */
314 * first see if we can copy any more bytes before hitting another exception
322 li r3,0 /* huh? all copied successfully this time? */
326 * here we have trapped again, amount remaining is in ctr.
332 * exception handlers for stores: we just need to work
333 * out how many bytes weren't copied
372 subf r3,r3,r6 /* #bytes not copied */
434 * Routine to copy a whole page of data, optimized for POWER4.
435 * On POWER4 it is more than 50% faster than the simple loop
436 * above (following the .Ldst_aligned label).
552 * on an exception, reset to the beginning and jump back into the
553 * standard __copy_tofrom_user
645 EXPORT_SYMBOL(__copy_tofrom_user)