1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Copyright (C) IBM Corporation, 2011
6 * Author: Anton Blanchard <anton@au.ibm.com>
8 #include <asm/ppc_asm.h>
11 /* 0 == don't use VMX, 1 == use VMX */
12 #define SELFTEST_CASE 0
16 #define LVS(VRT,RA,RB) lvsl VRT,RA,RB
17 #define VPERM(VRT,VRA,VRB,VRC) vperm VRT,VRA,VRB,VRC
19 #define LVS(VRT,RA,RB) lvsr VRT,RA,RB
20 #define VPERM(VRT,VRA,VRB,VRC) vperm VRT,VRB,VRA,VRC
25 EX_TABLE(100b,.Ldo_err1)
30 EX_TABLE(200b,.Ldo_err2)
36 EX_TABLE(300b,.Ldo_err3)
41 EX_TABLE(400b,.Ldo_err4)
46 ld r16,STK_REG(R16)(r1)
47 ld r15,STK_REG(R15)(r1)
48 ld r14,STK_REG(R14)(r1)
50 bl CFUNC(exit_vmx_usercopy)
51 ld r0,STACKFRAMESIZE+16(r1)
54 #endif /* CONFIG_ALTIVEC */
57 ld r22,STK_REG(R22)(r1)
58 ld r21,STK_REG(R21)(r1)
59 ld r20,STK_REG(R20)(r1)
60 ld r19,STK_REG(R19)(r1)
61 ld r18,STK_REG(R18)(r1)
62 ld r17,STK_REG(R17)(r1)
63 ld r16,STK_REG(R16)(r1)
64 ld r15,STK_REG(R15)(r1)
65 ld r14,STK_REG(R14)(r1)
67 addi r1,r1,STACKFRAMESIZE
69 ld r3,-STACKFRAMESIZE+STK_REG(R31)(r1)
70 ld r4,-STACKFRAMESIZE+STK_REG(R30)(r1)
71 ld r5,-STACKFRAMESIZE+STK_REG(R29)(r1)
72 b __copy_tofrom_user_base
75 _GLOBAL(__copy_tofrom_user_power7)
79 std r3,-STACKFRAMESIZE+STK_REG(R31)(r1)
80 std r4,-STACKFRAMESIZE+STK_REG(R30)(r1)
81 std r5,-STACKFRAMESIZE+STK_REG(R29)(r1)
86 test_feature = SELFTEST_CASE
89 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
93 /* Get the source 8B aligned */
121 stdu r1,-STACKFRAMESIZE(r1)
122 std r14,STK_REG(R14)(r1)
123 std r15,STK_REG(R15)(r1)
124 std r16,STK_REG(R16)(r1)
125 std r17,STK_REG(R17)(r1)
126 std r18,STK_REG(R18)(r1)
127 std r19,STK_REG(R19)(r1)
128 std r20,STK_REG(R20)(r1)
129 std r21,STK_REG(R21)(r1)
130 std r22,STK_REG(R22)(r1)
131 std r0,STACKFRAMESIZE+16(r1)
136 /* Now do cacheline (128B) sized loads and stores. */
169 err2; std r19,104(r3)
170 err2; std r20,112(r3)
171 err2; std r21,120(r3)
177 ld r14,STK_REG(R14)(r1)
178 ld r15,STK_REG(R15)(r1)
179 ld r16,STK_REG(R16)(r1)
180 ld r17,STK_REG(R17)(r1)
181 ld r18,STK_REG(R18)(r1)
182 ld r19,STK_REG(R19)(r1)
183 ld r20,STK_REG(R20)(r1)
184 ld r21,STK_REG(R21)(r1)
185 ld r22,STK_REG(R22)(r1)
186 addi r1,r1,STACKFRAMESIZE
188 /* Up to 127B to go */
212 /* Up to 63B to go */
225 /* Up to 31B to go */
234 9: clrldi r5,r5,(64-4)
236 /* Up to 15B to go */
240 err1; lwz r0,0(r4) /* Less chance of a reject with word ops */
266 .Lunwind_stack_nonvmx_copy:
267 addi r1,r1,STACKFRAMESIZE
271 #ifdef CONFIG_ALTIVEC
274 stdu r1,-STACKFRAMESIZE(r1)
275 bl CFUNC(enter_vmx_usercopy)
277 ld r0,STACKFRAMESIZE+16(r1)
278 ld r3,STK_REG(R31)(r1)
279 ld r4,STK_REG(R30)(r1)
280 ld r5,STK_REG(R29)(r1)
284 * We prefetch both the source and destination using enhanced touch
285 * instructions. We use a stream ID of 0 for the load side and
286 * 1 for the store side.
290 ori r9,r9,1 /* stream=1 */
292 srdi r7,r5,7 /* length in cachelines, capped at 0x3FF */
296 1: lis r0,0x0E00 /* depth=7 */
299 ori r10,r7,1 /* stream=1 */
301 DCBT_SETUP_STREAMS(r6, r7, r9, r10, r8)
303 beq cr1,.Lunwind_stack_nonvmx_copy
306 * If source and destination are not relatively aligned we use a
307 * slower permute loop.
310 rldicl. r6,r6,0,(64-4)
311 bne .Lvmx_unaligned_copy
313 /* Get the destination 16B aligned */
344 /* Get the desination 128B aligned */
383 std r14,STK_REG(R14)(r1)
384 std r15,STK_REG(R15)(r1)
385 std r16,STK_REG(R16)(r1)
395 * Now do cacheline sized loads and stores. By this stage the
396 * cacheline stores are also cacheline aligned.
420 ld r14,STK_REG(R14)(r1)
421 ld r15,STK_REG(R15)(r1)
422 ld r16,STK_REG(R16)(r1)
424 /* Up to 127B to go */
455 /* Up to 15B to go */
456 11: clrldi r5,r5,(64-4)
480 15: addi r1,r1,STACKFRAMESIZE
481 b CFUNC(exit_vmx_usercopy) /* tail call optimise */
483 .Lvmx_unaligned_copy:
484 /* Get the destination 16B aligned */
508 err3; lwz r0,0(r4) /* Less chance of a reject with word ops */
517 /* Get the desination 128B aligned */
527 LVS(v16,0,r4) /* Setup permute control vector */
561 err3; stvx v10,r3,r10
562 err3; stvx v11,r3,r11
568 std r14,STK_REG(R14)(r1)
569 std r15,STK_REG(R15)(r1)
570 std r16,STK_REG(R16)(r1)
580 * Now do cacheline sized loads and stores. By this stage the
581 * cacheline stores are also cacheline aligned.
604 err4; stvx v10,r3,r10
605 err4; stvx v11,r3,r11
606 err4; stvx v12,r3,r12
607 err4; stvx v13,r3,r14
608 err4; stvx v14,r3,r15
609 err4; stvx v15,r3,r16
613 ld r14,STK_REG(R14)(r1)
614 ld r15,STK_REG(R15)(r1)
615 ld r16,STK_REG(R16)(r1)
617 /* Up to 127B to go */
634 err3; stvx v10,r3,r10
635 err3; stvx v11,r3,r11
655 /* Up to 15B to go */
656 11: clrldi r5,r5,(64-4)
657 addi r4,r4,-16 /* Unwind the +16 load offset */
660 err3; lwz r0,0(r4) /* Less chance of a reject with word ops */
683 15: addi r1,r1,STACKFRAMESIZE
684 b CFUNC(exit_vmx_usercopy) /* tail call optimise */
685 #endif /* CONFIG_ALTIVEC */