Skip to content

Commit a4e22f0

Browse files
Mark Nelsonpaulusmack
authored andcommitted
powerpc: Update 64bit __copy_tofrom_user() using CPU_FTR_UNALIGNED_LD_STD
In exactly the same way that we updated memcpy() with new feature sections in commit 25d6e2d ("powerpc: Update 64bit memcpy() using CPU_FTR_UNALIGNED_LD_STD"), we do the same thing here for __copy_tofrom_user(). Once again this is purely a performance tweak for Cell and Power6 - this has no effect on all the other 64bit powerpc chips. We can make these same changes to __copy_tofrom_user() because the basic copy algorithm is the same as in memcpy() - this version just has all the exception handling logic needed when copying to or from userspace as well as a special case for copying whole 4K pages that are page aligned. CPU_FTR_UNALIGNED_LD_STD CPU was added in commit 4ec577a ("powerpc: Add new CPU feature: CPU_FTR_UNALIGNED_LD_STD"). We also make the same simple one line change from cmpldi r1,... to cmpldi cr1,... for consistency. Signed-off-by: Mark Nelson <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 7526ff7 commit a4e22f0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

arch/powerpc/lib/copyuser_64.S

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,24 @@ _GLOBAL(__copy_tofrom_user)
2626
andi. r6,r6,7
2727
PPC_MTOCRF 0x01,r5
2828
blt cr1,.Lshort_copy
29+
/* Below we want to nop out the bne if we're on a CPU that has the
30+
* CPU_FTR_UNALIGNED_LD_STD bit set and the CPU_FTR_CP_USE_DCBTZ bit
31+
* cleared.
32+
* At the time of writing the only CPU that has this combination of bits
33+
* set is Power6.
34+
*/
35+
BEGIN_FTR_SECTION
36+
nop
37+
FTR_SECTION_ELSE
2938
bne .Ldst_unaligned
39+
ALT_FTR_SECTION_END(CPU_FTR_UNALIGNED_LD_STD | CPU_FTR_CP_USE_DCBTZ, \
40+
CPU_FTR_UNALIGNED_LD_STD)
3041
.Ldst_aligned:
31-
andi. r0,r4,7
3242
addi r3,r3,-16
43+
BEGIN_FTR_SECTION
44+
andi. r0,r4,7
3345
bne .Lsrc_unaligned
46+
END_FTR_SECTION_IFCLR(CPU_FTR_UNALIGNED_LD_STD)
3447
srdi r7,r5,4
3548
20: ld r9,0(r4)
3649
addi r4,r4,-8
@@ -138,7 +151,7 @@ _GLOBAL(__copy_tofrom_user)
138151
PPC_MTOCRF 0x01,r6 /* put #bytes to 8B bdry into cr7 */
139152
subf r5,r6,r5
140153
li r7,0
141-
cmpldi r1,r5,16
154+
cmpldi cr1,r5,16
142155
bf cr7*4+3,1f
143156
35: lbz r0,0(r4)
144157
81: stb r0,0(r3)

0 commit comments

Comments
 (0)