2005-09-26 10:04:21 +04:00
/ *
* Copyright ( C ) 2 0 0 2 P a u l M a c k e r r a s , I B M C o r p .
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or
* modify i t u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* as p u b l i s h e d b y t h e F r e e S o f t w a r e F o u n d a t i o n ; either version
* 2 of t h e L i c e n s e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
* /
# include < a s m / p r o c e s s o r . h >
# include < a s m / p p c _ a s m . h >
2016-01-14 07:33:46 +03:00
# include < a s m / e x p o r t . h >
2018-07-05 19:24:57 +03:00
# include < a s m / a s m - c o m p a t . h >
2018-07-05 19:25:01 +03:00
# include < a s m / f e a t u r e - f i x u p s . h >
2005-09-26 10:04:21 +04:00
2013-12-18 02:29:57 +04:00
# ifdef _ _ B I G _ E N D I A N _ _
# define s L d s l d / * S h i f t t o w a r d s l o w - n u m b e r e d a d d r e s s . * /
# define s H d s r d / * S h i f t t o w a r d s h i g h - n u m b e r e d a d d r e s s . * /
# else
# define s L d s r d / * S h i f t t o w a r d s l o w - n u m b e r e d a d d r e s s . * /
# define s H d s l d / * S h i f t t o w a r d s h i g h - n u m b e r e d a d d r e s s . * /
# endif
2005-09-26 10:04:21 +04:00
.align 7
2014-04-03 09:01:11 +04:00
_ GLOBAL_ T O C ( _ _ c o p y _ t o f r o m _ u s e r )
2018-02-20 22:08:26 +03:00
# ifdef C O N F I G _ P P C _ B O O K 3 S _ 6 4
powerpc: POWER7 optimised copy_to_user/copy_from_user using VMX
Implement a POWER7 optimised copy_to_user/copy_from_user using VMX.
For large aligned copies this new loop is over 10% faster, and for
large unaligned copies it is over 200% faster.
If we take a fault we fall back to the old version, this keeps
things relatively simple and easy to verify.
On POWER7 unaligned stores rarely slow down - they only flush when
a store crosses a 4KB page boundary. Furthermore this flush is
handled completely in hardware and should be 20-30 cycles.
Unaligned loads on the other hand flush much more often - whenever
crossing a 128 byte cache line, or a 32 byte sector if either sector
is an L1 miss.
Considering this information we really want to get the loads aligned
and not worry about the alignment of the stores. Microbenchmarks
confirm that this approach is much faster than the current unaligned
copy loop that uses shifts and rotates to ensure both loads and
stores are aligned.
We also want to try and do the stores in cacheline aligned, cacheline
sized chunks. If the store queue is unable to merge an entire
cacheline of stores then the L2 cache will have to do a
read/modify/write. Even worse, we will serialise this with the stores
in the next iteration of the copy loop since both iterations hit
the same cacheline.
Based on this, the new loop does the following things:
1 - 127 bytes
Get the source 8 byte aligned and use 8 byte loads and stores. Pretty
boring and similar to how the current loop works.
128 - 4095 bytes
Get the source 8 byte aligned and use 8 byte loads and stores,
1 cacheline at a time. We aren't doing the stores in cacheline
aligned chunks so we will potentially serialise once per cacheline.
Even so it is much better than the loop we have today.
4096 - bytes
If both source and destination have the same alignment get them both
16 byte aligned, then get the destination cacheline aligned. Do
cacheline sized loads and stores using VMX.
If source and destination do not have the same alignment, we get the
destination cacheline aligned, and use permute to do aligned loads.
In both cases the VMX loop should be optimal - we always do aligned
loads and stores and are always doing stores in cacheline aligned,
cacheline sized chunks.
To be able to use VMX we must be careful about interrupts and
sleeping. We don't use the VMX loop when in an interrupt (which should
be rare anyway) and we wrap the VMX loop in disable/enable_pagefault
and fall back to the existing copy_tofrom_user loop if we do need to
sleep.
The VMX breakpoint of 4096 bytes was chosen using this microbenchmark:
http://ozlabs.org/~anton/junkcode/copy_to_user.c
Since we are using VMX and there is a cost to saving and restoring
the user VMX state there are two broad cases we need to benchmark:
- Best case - userspace never uses VMX
- Worst case - userspace always uses VMX
In reality a userspace process will sit somewhere between these two
extremes. Since we need to test both aligned and unaligned copies we
end up with 4 combinations. The point at which the VMX loop begins to
win is:
0% VMX
aligned 2048 bytes
unaligned 2048 bytes
100% VMX
aligned 16384 bytes
unaligned 8192 bytes
Considering this is a microbenchmark, the data is hot in cache and
the VMX loop has better store queue merging properties we set the
breakpoint to 4096 bytes, a little below the unaligned breakpoints.
Some future optimisations we can look at:
- Looking at the perf data, a significant part of the cost when a
task is always using VMX is the extra exception we take to restore
the VMX state. As such we should do something similar to the x86
optimisation that restores FPU state for heavy users. ie:
/*
* If the task has used fpu the last 5 timeslices, just do a full
* restore of the math state immediately to avoid the trap; the
* chances of needing FPU soon are obviously high now
*/
preload_fpu = tsk_used_math(next_p) && next_p->fpu_counter > 5;
and
/*
* fpu_counter contains the number of consecutive context switches
* that the FPU is used. If this is over a threshold, the lazy fpu
* saving becomes unlazy to save the trap. This is an unsigned char
* so that after 256 times the counter wraps and the behavior turns
* lazy again; this to deal with bursty apps that only use FPU for
* a short time
*/
- We could create a paca bit to mirror the VMX enabled MSR bit and check
that first, avoiding multiple calls to calling enable_kernel_altivec.
That should help with iovec based system calls like readv.
- We could have two VMX breakpoints, one for when we know the user VMX
state is loaded into the registers and one when it isn't. This could
be a second bit in the paca so we can calculate the break points quickly.
- One suggestion from Ben was to save and restore the VSX registers
we use inline instead of using enable_kernel_altivec.
[BenH: Fixed a problem with preempt and fixed build without CONFIG_ALTIVEC]
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-12-08 00:11:45 +04:00
BEGIN_ F T R _ S E C T I O N
nop
FTR_ S E C T I O N _ E L S E
b _ _ c o p y _ t o f r o m _ u s e r _ p o w e r7
ALT_ F T R _ S E C T I O N _ E N D _ I F C L R ( C P U _ F T R _ V M X _ C O P Y )
2018-02-20 22:08:26 +03:00
# endif
powerpc: POWER7 optimised copy_to_user/copy_from_user using VMX
Implement a POWER7 optimised copy_to_user/copy_from_user using VMX.
For large aligned copies this new loop is over 10% faster, and for
large unaligned copies it is over 200% faster.
If we take a fault we fall back to the old version, this keeps
things relatively simple and easy to verify.
On POWER7 unaligned stores rarely slow down - they only flush when
a store crosses a 4KB page boundary. Furthermore this flush is
handled completely in hardware and should be 20-30 cycles.
Unaligned loads on the other hand flush much more often - whenever
crossing a 128 byte cache line, or a 32 byte sector if either sector
is an L1 miss.
Considering this information we really want to get the loads aligned
and not worry about the alignment of the stores. Microbenchmarks
confirm that this approach is much faster than the current unaligned
copy loop that uses shifts and rotates to ensure both loads and
stores are aligned.
We also want to try and do the stores in cacheline aligned, cacheline
sized chunks. If the store queue is unable to merge an entire
cacheline of stores then the L2 cache will have to do a
read/modify/write. Even worse, we will serialise this with the stores
in the next iteration of the copy loop since both iterations hit
the same cacheline.
Based on this, the new loop does the following things:
1 - 127 bytes
Get the source 8 byte aligned and use 8 byte loads and stores. Pretty
boring and similar to how the current loop works.
128 - 4095 bytes
Get the source 8 byte aligned and use 8 byte loads and stores,
1 cacheline at a time. We aren't doing the stores in cacheline
aligned chunks so we will potentially serialise once per cacheline.
Even so it is much better than the loop we have today.
4096 - bytes
If both source and destination have the same alignment get them both
16 byte aligned, then get the destination cacheline aligned. Do
cacheline sized loads and stores using VMX.
If source and destination do not have the same alignment, we get the
destination cacheline aligned, and use permute to do aligned loads.
In both cases the VMX loop should be optimal - we always do aligned
loads and stores and are always doing stores in cacheline aligned,
cacheline sized chunks.
To be able to use VMX we must be careful about interrupts and
sleeping. We don't use the VMX loop when in an interrupt (which should
be rare anyway) and we wrap the VMX loop in disable/enable_pagefault
and fall back to the existing copy_tofrom_user loop if we do need to
sleep.
The VMX breakpoint of 4096 bytes was chosen using this microbenchmark:
http://ozlabs.org/~anton/junkcode/copy_to_user.c
Since we are using VMX and there is a cost to saving and restoring
the user VMX state there are two broad cases we need to benchmark:
- Best case - userspace never uses VMX
- Worst case - userspace always uses VMX
In reality a userspace process will sit somewhere between these two
extremes. Since we need to test both aligned and unaligned copies we
end up with 4 combinations. The point at which the VMX loop begins to
win is:
0% VMX
aligned 2048 bytes
unaligned 2048 bytes
100% VMX
aligned 16384 bytes
unaligned 8192 bytes
Considering this is a microbenchmark, the data is hot in cache and
the VMX loop has better store queue merging properties we set the
breakpoint to 4096 bytes, a little below the unaligned breakpoints.
Some future optimisations we can look at:
- Looking at the perf data, a significant part of the cost when a
task is always using VMX is the extra exception we take to restore
the VMX state. As such we should do something similar to the x86
optimisation that restores FPU state for heavy users. ie:
/*
* If the task has used fpu the last 5 timeslices, just do a full
* restore of the math state immediately to avoid the trap; the
* chances of needing FPU soon are obviously high now
*/
preload_fpu = tsk_used_math(next_p) && next_p->fpu_counter > 5;
and
/*
* fpu_counter contains the number of consecutive context switches
* that the FPU is used. If this is over a threshold, the lazy fpu
* saving becomes unlazy to save the trap. This is an unsigned char
* so that after 256 times the counter wraps and the behavior turns
* lazy again; this to deal with bursty apps that only use FPU for
* a short time
*/
- We could create a paca bit to mirror the VMX enabled MSR bit and check
that first, avoiding multiple calls to calling enable_kernel_altivec.
That should help with iovec based system calls like readv.
- We could have two VMX breakpoints, one for when we know the user VMX
state is loaded into the registers and one when it isn't. This could
be a second bit in the paca so we can calculate the break points quickly.
- One suggestion from Ben was to save and restore the VSX registers
we use inline instead of using enable_kernel_altivec.
[BenH: Fixed a problem with preempt and fixed build without CONFIG_ALTIVEC]
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-12-08 00:11:45 +04:00
_ GLOBAL( _ _ c o p y _ t o f r o m _ u s e r _ b a s e )
2005-09-26 10:04:21 +04:00
/* first check for a whole page copy on a page boundary */
cmpldi c r1 ,r5 ,1 6
cmpdi c r6 ,r5 ,4 0 9 6
or r0 ,r3 ,r4
neg r6 ,r3 / * L S 3 b i t s = # b y t e s t o 8 - b y t e d e s t b d r y * /
andi. r0 ,r0 ,4 0 9 5
std r3 ,- 2 4 ( r1 )
crand c r0 * 4 + 2 ,c r0 * 4 + 2 ,c r6 * 4 + 2
std r4 ,- 1 6 ( r1 )
std r5 ,- 8 ( r1 )
dcbt 0 ,r4
2005-11-07 03:06:55 +03:00
beq . L c o p y _ p a g e _ 4 K
2005-09-26 10:04:21 +04:00
andi. r6 ,r6 ,7
2012-04-18 06:21:52 +04:00
PPC_ M T O C R F ( 0 x01 ,r5 )
2005-09-26 10:04:21 +04:00
blt c r1 ,. L s h o r t _ c o p y
2008-11-11 03:53:34 +03:00
/ * Below w e w a n t t o n o p o u t t h e b n e i f w e ' r e o n a C P U t h a t h a s t h e
* CPU_ F T R _ U N A L I G N E D _ L D _ S T D b i t s e t a n d t h e C P U _ F T R _ C P _ U S E _ D C B T Z b i t
* cleared.
* At t h e t i m e o f w r i t i n g t h e o n l y C P U t h a t h a s t h i s c o m b i n a t i o n o f b i t s
* set i s P o w e r6 .
* /
BEGIN_ F T R _ S E C T I O N
nop
FTR_ S E C T I O N _ E L S E
2005-09-26 10:04:21 +04:00
bne . L d s t _ u n a l i g n e d
2008-11-11 03:53:34 +03:00
ALT_ F T R _ S E C T I O N _ E N D ( C P U _ F T R _ U N A L I G N E D _ L D _ S T D | C P U _ F T R _ C P _ U S E _ D C B T Z , \
CPU_ F T R _ U N A L I G N E D _ L D _ S T D )
2005-09-26 10:04:21 +04:00
.Ldst_aligned :
addi r3 ,r3 ,- 1 6
2008-11-11 03:53:34 +03:00
BEGIN_ F T R _ S E C T I O N
andi. r0 ,r4 ,7
2005-09-26 10:04:21 +04:00
bne . L s r c _ u n a l i g n e d
2008-11-11 03:53:34 +03:00
END_ F T R _ S E C T I O N _ I F C L R ( C P U _ F T R _ U N A L I G N E D _ L D _ S T D )
2010-02-10 17:56:26 +03:00
blt c r1 ,. L d o _ t a i l / * i f < 1 6 b y t e s t o c o p y * /
srdi r0 ,r5 ,5
cmpdi c r1 ,r0 ,0
20 : ld r7 ,0 ( r4 )
220 : ld r6 ,8 ( r4 )
addi r4 ,r4 ,1 6
mtctr r0
andi. r0 ,r5 ,0 x10
beq 2 2 f
addi r3 ,r3 ,1 6
addi r4 ,r4 ,- 1 6
mr r9 ,r7
mr r8 ,r6
beq c r1 ,7 2 f
21 : ld r7 ,1 6 ( r4 )
221 : ld r6 ,2 4 ( r4 )
addi r4 ,r4 ,3 2
70 : std r9 ,0 ( r3 )
270 : std r8 ,8 ( r3 )
22 : ld r9 ,0 ( r4 )
222 : ld r8 ,8 ( r4 )
71 : std r7 ,1 6 ( r3 )
271 : std r6 ,2 4 ( r3 )
addi r3 ,r3 ,3 2
2005-09-26 10:04:21 +04:00
bdnz 2 1 b
2010-02-10 17:56:26 +03:00
72 : std r9 ,0 ( r3 )
272 : std r8 ,8 ( r3 )
andi. r5 ,r5 ,0 x f
2005-09-26 10:04:21 +04:00
beq+ 3 f
2010-02-10 17:56:26 +03:00
addi r4 ,r4 ,1 6
2005-09-26 10:04:21 +04:00
.Ldo_tail :
2010-02-10 17:56:26 +03:00
addi r3 ,r3 ,1 6
bf c r7 * 4 + 0 ,2 4 6 f
244 : ld r9 ,0 ( r4 )
addi r4 ,r4 ,8
245 : std r9 ,0 ( r3 )
addi r3 ,r3 ,8
246 : bf c r7 * 4 + 1 ,1 f
23 : lwz r9 ,0 ( r4 )
2009-02-25 16:46:24 +03:00
addi r4 ,r4 ,4
2005-09-26 10:04:21 +04:00
73 : stw r9 ,0 ( r3 )
addi r3 ,r3 ,4
1 : bf c r7 * 4 + 2 ,2 f
2010-02-10 17:56:26 +03:00
44 : lhz r9 ,0 ( r4 )
2009-02-25 16:46:24 +03:00
addi r4 ,r4 ,2
2005-09-26 10:04:21 +04:00
74 : sth r9 ,0 ( r3 )
addi r3 ,r3 ,2
2 : bf c r7 * 4 + 3 ,3 f
2010-02-10 17:56:26 +03:00
45 : lbz r9 ,0 ( r4 )
2005-09-26 10:04:21 +04:00
75 : stb r9 ,0 ( r3 )
3 : li r3 ,0
blr
.Lsrc_unaligned :
srdi r6 ,r5 ,3
addi r5 ,r5 ,- 1 6
subf r4 ,r0 ,r4
srdi r7 ,r5 ,4
sldi r10 ,r0 ,3
cmpldi c r6 ,r6 ,3
andi. r5 ,r5 ,7
mtctr r7
subfic r11 ,r10 ,6 4
add r5 ,r5 ,r0
bt c r7 * 4 + 0 ,2 8 f
24 : ld r9 ,0 ( r4 ) / * 3 + 2 n l o a d s , 2 + 2 n s t o r e s * /
25 : ld r0 ,8 ( r4 )
2013-12-18 02:29:57 +04:00
sLd r6 ,r9 ,r10
2005-09-26 10:04:21 +04:00
26 : ldu r9 ,1 6 ( r4 )
2013-12-18 02:29:57 +04:00
sHd r7 ,r0 ,r11
sLd r8 ,r0 ,r10
2005-09-26 10:04:21 +04:00
or r7 ,r7 ,r6
blt c r6 ,7 9 f
27 : ld r0 ,8 ( r4 )
b 2 f
28 : ld r0 ,0 ( r4 ) / * 4 + 2 n l o a d s , 3 + 2 n s t o r e s * /
29 : ldu r9 ,8 ( r4 )
2013-12-18 02:29:57 +04:00
sLd r8 ,r0 ,r10
2005-09-26 10:04:21 +04:00
addi r3 ,r3 ,- 8
blt c r6 ,5 f
30 : ld r0 ,8 ( r4 )
2013-12-18 02:29:57 +04:00
sHd r12 ,r9 ,r11
sLd r6 ,r9 ,r10
2005-09-26 10:04:21 +04:00
31 : ldu r9 ,1 6 ( r4 )
or r12 ,r8 ,r12
2013-12-18 02:29:57 +04:00
sHd r7 ,r0 ,r11
sLd r8 ,r0 ,r10
2005-09-26 10:04:21 +04:00
addi r3 ,r3 ,1 6
beq c r6 ,7 8 f
1 : or r7 ,r7 ,r6
32 : ld r0 ,8 ( r4 )
76 : std r12 ,8 ( r3 )
2013-12-18 02:29:57 +04:00
2 : sHd r12 ,r9 ,r11
sLd r6 ,r9 ,r10
2005-09-26 10:04:21 +04:00
33 : ldu r9 ,1 6 ( r4 )
or r12 ,r8 ,r12
77 : stdu r7 ,1 6 ( r3 )
2013-12-18 02:29:57 +04:00
sHd r7 ,r0 ,r11
sLd r8 ,r0 ,r10
2005-09-26 10:04:21 +04:00
bdnz 1 b
78 : std r12 ,8 ( r3 )
or r7 ,r7 ,r6
79 : std r7 ,1 6 ( r3 )
2013-12-18 02:29:57 +04:00
5 : sHd r12 ,r9 ,r11
2005-09-26 10:04:21 +04:00
or r12 ,r8 ,r12
80 : std r12 ,2 4 ( r3 )
bne 6 f
li r3 ,0
blr
6 : cmpwi c r1 ,r5 ,8
addi r3 ,r3 ,3 2
2013-12-18 02:29:57 +04:00
sLd r9 ,r9 ,r10
2009-02-25 16:46:24 +03:00
ble c r1 ,7 f
2005-09-26 10:04:21 +04:00
34 : ld r0 ,8 ( r4 )
2013-12-18 02:29:57 +04:00
sHd r7 ,r0 ,r11
2005-09-26 10:04:21 +04:00
or r9 ,r7 ,r9
2009-02-25 16:46:24 +03:00
7 :
bf c r7 * 4 + 1 ,1 f
2013-12-18 02:29:57 +04:00
# ifdef _ _ B I G _ E N D I A N _ _
2009-02-25 16:46:24 +03:00
rotldi r9 ,r9 ,3 2
2013-12-18 02:29:57 +04:00
# endif
2009-02-25 16:46:24 +03:00
94 : stw r9 ,0 ( r3 )
2013-12-18 02:29:57 +04:00
# ifdef _ _ L I T T L E _ E N D I A N _ _
rotrdi r9 ,r9 ,3 2
# endif
2009-02-25 16:46:24 +03:00
addi r3 ,r3 ,4
1 : bf c r7 * 4 + 2 ,2 f
2013-12-18 02:29:57 +04:00
# ifdef _ _ B I G _ E N D I A N _ _
2009-02-25 16:46:24 +03:00
rotldi r9 ,r9 ,1 6
2013-12-18 02:29:57 +04:00
# endif
2009-02-25 16:46:24 +03:00
95 : sth r9 ,0 ( r3 )
2013-12-18 02:29:57 +04:00
# ifdef _ _ L I T T L E _ E N D I A N _ _
rotrdi r9 ,r9 ,1 6
# endif
2009-02-25 16:46:24 +03:00
addi r3 ,r3 ,2
2 : bf c r7 * 4 + 3 ,3 f
2013-12-18 02:29:57 +04:00
# ifdef _ _ B I G _ E N D I A N _ _
2009-02-25 16:46:24 +03:00
rotldi r9 ,r9 ,8
2013-12-18 02:29:57 +04:00
# endif
2009-02-25 16:46:24 +03:00
96 : stb r9 ,0 ( r3 )
2013-12-18 02:29:57 +04:00
# ifdef _ _ L I T T L E _ E N D I A N _ _
rotrdi r9 ,r9 ,8
# endif
2009-02-25 16:46:24 +03:00
3 : li r3 ,0
blr
2005-09-26 10:04:21 +04:00
.Ldst_unaligned :
2012-04-18 06:21:52 +04:00
PPC_ M T O C R F ( 0 x01 ,r6 ) / * p u t #b y t e s t o 8 B b d r y i n t o c r7 * /
2005-09-26 10:04:21 +04:00
subf r5 ,r6 ,r5
li r7 ,0
2008-11-11 03:53:34 +03:00
cmpldi c r1 ,r5 ,1 6
2005-09-26 10:04:21 +04:00
bf c r7 * 4 + 3 ,1 f
35 : lbz r0 ,0 ( r4 )
81 : stb r0 ,0 ( r3 )
addi r7 ,r7 ,1
1 : bf c r7 * 4 + 2 ,2 f
36 : lhzx r0 ,r7 ,r4
82 : sthx r0 ,r7 ,r3
addi r7 ,r7 ,2
2 : bf c r7 * 4 + 1 ,3 f
37 : lwzx r0 ,r7 ,r4
83 : stwx r0 ,r7 ,r3
2012-04-18 06:21:52 +04:00
3 : PPC_ M T O C R F ( 0 x01 ,r5 )
2005-09-26 10:04:21 +04:00
add r4 ,r6 ,r4
add r3 ,r6 ,r3
b . L d s t _ a l i g n e d
.Lshort_copy :
bf c r7 * 4 + 0 ,1 f
38 : lwz r0 ,0 ( r4 )
39 : lwz r9 ,4 ( r4 )
addi r4 ,r4 ,8
84 : stw r0 ,0 ( r3 )
85 : stw r9 ,4 ( r3 )
addi r3 ,r3 ,8
1 : bf c r7 * 4 + 1 ,2 f
40 : lwz r0 ,0 ( r4 )
addi r4 ,r4 ,4
86 : stw r0 ,0 ( r3 )
addi r3 ,r3 ,4
2 : bf c r7 * 4 + 2 ,3 f
41 : lhz r0 ,0 ( r4 )
addi r4 ,r4 ,2
87 : sth r0 ,0 ( r3 )
addi r3 ,r3 ,2
3 : bf c r7 * 4 + 3 ,4 f
42 : lbz r0 ,0 ( r4 )
88 : stb r0 ,0 ( r3 )
4 : li r3 ,0
blr
/ *
* exception h a n d l e r s f o l l o w
* we h a v e t o r e t u r n t h e n u m b e r o f b y t e s n o t c o p i e d
* for a n e x c e p t i o n o n a l o a d , w e s e t t h e r e s t o f t h e d e s t i n a t i o n t o 0
* /
136 :
137 :
add r3 ,r3 ,r7
b 1 f
130 :
131 :
addi r3 ,r3 ,8
120 :
2010-02-10 17:56:26 +03:00
320 :
2005-09-26 10:04:21 +04:00
122 :
2010-02-10 17:56:26 +03:00
322 :
2005-09-26 10:04:21 +04:00
124 :
125 :
126 :
127 :
128 :
129 :
133 :
addi r3 ,r3 ,8
132 :
addi r3 ,r3 ,8
2010-02-10 17:56:26 +03:00
121 :
321 :
344 :
2005-09-26 10:04:21 +04:00
134 :
135 :
138 :
139 :
140 :
141 :
142 :
2009-02-25 16:46:24 +03:00
123 :
144 :
145 :
2005-09-26 10:04:21 +04:00
/ *
* here w e h a v e h a d a f a u l t o n a l o a d a n d r3 p o i n t s t o t h e f i r s t
* unmodified b y t e o f t h e d e s t i n a t i o n
* /
1 : ld r6 ,- 2 4 ( r1 )
ld r4 ,- 1 6 ( r1 )
ld r5 ,- 8 ( r1 )
subf r6 ,r6 ,r3
add r4 ,r4 ,r6
subf r5 ,r6 ,r5 / * #b y t e s l e f t t o g o * /
/ *
* first s e e i f w e c a n c o p y a n y m o r e b y t e s b e f o r e h i t t i n g a n o t h e r e x c e p t i o n
* /
mtctr r5
43 : lbz r0 ,0 ( r4 )
addi r4 ,r4 ,1
89 : stb r0 ,0 ( r3 )
addi r3 ,r3 ,1
bdnz 4 3 b
li r3 ,0 / * h u h ? a l l c o p i e d s u c c e s s f u l l y t h i s t i m e ? * /
blr
/ *
2017-03-21 23:35:08 +03:00
* here w e h a v e t r a p p e d a g a i n , a m o u n t r e m a i n i n g i s i n c t r .
2005-09-26 10:04:21 +04:00
* /
2017-03-21 23:35:08 +03:00
143 : mfctr r3
2005-09-26 10:04:21 +04:00
blr
/ *
* exception h a n d l e r s f o r s t o r e s : w e j u s t n e e d t o w o r k
* out h o w m a n y b y t e s w e r e n ' t c o p i e d
* /
182 :
183 :
add r3 ,r3 ,r7
b 1 f
2010-02-10 17:56:26 +03:00
371 :
2005-09-26 10:04:21 +04:00
180 :
addi r3 ,r3 ,8
171 :
177 :
2016-10-11 14:25:47 +03:00
179 :
2005-09-26 10:04:21 +04:00
addi r3 ,r3 ,8
2010-02-10 17:56:26 +03:00
370 :
372 :
2005-09-26 10:04:21 +04:00
176 :
178 :
addi r3 ,r3 ,4
185 :
addi r3 ,r3 ,4
2010-02-10 17:56:26 +03:00
170 :
172 :
345 :
2005-09-26 10:04:21 +04:00
173 :
174 :
175 :
181 :
184 :
186 :
187 :
188 :
189 :
2009-02-25 16:46:24 +03:00
194 :
195 :
196 :
2005-09-26 10:04:21 +04:00
1 :
ld r6 ,- 2 4 ( r1 )
ld r5 ,- 8 ( r1 )
add r6 ,r6 ,r5
subf r3 ,r3 ,r6 / * #b y t e s n o t c o p i e d * /
2017-03-21 23:35:08 +03:00
blr
2005-09-26 10:04:21 +04:00
2016-10-13 08:42:53 +03:00
EX_ T A B L E ( 2 0 b ,1 2 0 b )
EX_ T A B L E ( 2 2 0 b ,3 2 0 b )
EX_ T A B L E ( 2 1 b ,1 2 1 b )
EX_ T A B L E ( 2 2 1 b ,3 2 1 b )
EX_ T A B L E ( 7 0 b ,1 7 0 b )
EX_ T A B L E ( 2 7 0 b ,3 7 0 b )
EX_ T A B L E ( 2 2 b ,1 2 2 b )
EX_ T A B L E ( 2 2 2 b ,3 2 2 b )
EX_ T A B L E ( 7 1 b ,1 7 1 b )
EX_ T A B L E ( 2 7 1 b ,3 7 1 b )
EX_ T A B L E ( 7 2 b ,1 7 2 b )
EX_ T A B L E ( 2 7 2 b ,3 7 2 b )
EX_ T A B L E ( 2 4 4 b ,3 4 4 b )
EX_ T A B L E ( 2 4 5 b ,3 4 5 b )
EX_ T A B L E ( 2 3 b ,1 2 3 b )
EX_ T A B L E ( 7 3 b ,1 7 3 b )
EX_ T A B L E ( 4 4 b ,1 4 4 b )
EX_ T A B L E ( 7 4 b ,1 7 4 b )
EX_ T A B L E ( 4 5 b ,1 4 5 b )
EX_ T A B L E ( 7 5 b ,1 7 5 b )
EX_ T A B L E ( 2 4 b ,1 2 4 b )
EX_ T A B L E ( 2 5 b ,1 2 5 b )
EX_ T A B L E ( 2 6 b ,1 2 6 b )
EX_ T A B L E ( 2 7 b ,1 2 7 b )
EX_ T A B L E ( 2 8 b ,1 2 8 b )
EX_ T A B L E ( 2 9 b ,1 2 9 b )
EX_ T A B L E ( 3 0 b ,1 3 0 b )
EX_ T A B L E ( 3 1 b ,1 3 1 b )
EX_ T A B L E ( 3 2 b ,1 3 2 b )
EX_ T A B L E ( 7 6 b ,1 7 6 b )
EX_ T A B L E ( 3 3 b ,1 3 3 b )
EX_ T A B L E ( 7 7 b ,1 7 7 b )
EX_ T A B L E ( 7 8 b ,1 7 8 b )
EX_ T A B L E ( 7 9 b ,1 7 9 b )
EX_ T A B L E ( 8 0 b ,1 8 0 b )
EX_ T A B L E ( 3 4 b ,1 3 4 b )
EX_ T A B L E ( 9 4 b ,1 9 4 b )
EX_ T A B L E ( 9 5 b ,1 9 5 b )
EX_ T A B L E ( 9 6 b ,1 9 6 b )
EX_ T A B L E ( 3 5 b ,1 3 5 b )
EX_ T A B L E ( 8 1 b ,1 8 1 b )
EX_ T A B L E ( 3 6 b ,1 3 6 b )
EX_ T A B L E ( 8 2 b ,1 8 2 b )
EX_ T A B L E ( 3 7 b ,1 3 7 b )
EX_ T A B L E ( 8 3 b ,1 8 3 b )
EX_ T A B L E ( 3 8 b ,1 3 8 b )
EX_ T A B L E ( 3 9 b ,1 3 9 b )
EX_ T A B L E ( 8 4 b ,1 8 4 b )
EX_ T A B L E ( 8 5 b ,1 8 5 b )
EX_ T A B L E ( 4 0 b ,1 4 0 b )
EX_ T A B L E ( 8 6 b ,1 8 6 b )
EX_ T A B L E ( 4 1 b ,1 4 1 b )
EX_ T A B L E ( 8 7 b ,1 8 7 b )
EX_ T A B L E ( 4 2 b ,1 4 2 b )
EX_ T A B L E ( 8 8 b ,1 8 8 b )
EX_ T A B L E ( 4 3 b ,1 4 3 b )
EX_ T A B L E ( 8 9 b ,1 8 9 b )
2005-09-26 10:04:21 +04:00
/ *
* Routine t o c o p y a w h o l e p a g e o f d a t a , o p t i m i z e d f o r P O W E R 4 .
* On P O W E R 4 i t i s m o r e t h a n 5 0 % f a s t e r t h a n t h e s i m p l e l o o p
2014-07-10 06:29:24 +04:00
* above ( f o l l o w i n g t h e . L d s t _ a l i g n e d l a b e l ) .
2005-09-26 10:04:21 +04:00
* /
2005-11-07 03:06:55 +03:00
.Lcopy_page_4K :
2005-09-26 10:04:21 +04:00
std r31 ,- 3 2 ( 1 )
std r30 ,- 4 0 ( 1 )
std r29 ,- 4 8 ( 1 )
std r28 ,- 5 6 ( 1 )
std r27 ,- 6 4 ( 1 )
std r26 ,- 7 2 ( 1 )
std r25 ,- 8 0 ( 1 )
std r24 ,- 8 8 ( 1 )
std r23 ,- 9 6 ( 1 )
std r22 ,- 1 0 4 ( 1 )
std r21 ,- 1 1 2 ( 1 )
std r20 ,- 1 2 0 ( 1 )
li r5 ,4 0 9 6 / 3 2 - 1
addi r3 ,r3 ,- 8
li r0 ,5
0 : addi r5 ,r5 ,- 2 4
mtctr r0
20 : ld r22 ,6 4 0 ( 4 )
21 : ld r21 ,5 1 2 ( 4 )
22 : ld r20 ,3 8 4 ( 4 )
23 : ld r11 ,2 5 6 ( 4 )
24 : ld r9 ,1 2 8 ( 4 )
25 : ld r7 ,0 ( 4 )
26 : ld r25 ,6 4 8 ( 4 )
27 : ld r24 ,5 2 0 ( 4 )
28 : ld r23 ,3 9 2 ( 4 )
29 : ld r10 ,2 6 4 ( 4 )
30 : ld r8 ,1 3 6 ( 4 )
31 : ldu r6 ,8 ( 4 )
cmpwi r5 ,2 4
1 :
32 : std r22 ,6 4 8 ( 3 )
33 : std r21 ,5 2 0 ( 3 )
34 : std r20 ,3 9 2 ( 3 )
35 : std r11 ,2 6 4 ( 3 )
36 : std r9 ,1 3 6 ( 3 )
37 : std r7 ,8 ( 3 )
38 : ld r28 ,6 4 8 ( 4 )
39 : ld r27 ,5 2 0 ( 4 )
40 : ld r26 ,3 9 2 ( 4 )
41 : ld r31 ,2 6 4 ( 4 )
42 : ld r30 ,1 3 6 ( 4 )
43 : ld r29 ,8 ( 4 )
44 : std r25 ,6 5 6 ( 3 )
45 : std r24 ,5 2 8 ( 3 )
46 : std r23 ,4 0 0 ( 3 )
47 : std r10 ,2 7 2 ( 3 )
48 : std r8 ,1 4 4 ( 3 )
49 : std r6 ,1 6 ( 3 )
50 : ld r22 ,6 5 6 ( 4 )
51 : ld r21 ,5 2 8 ( 4 )
52 : ld r20 ,4 0 0 ( 4 )
53 : ld r11 ,2 7 2 ( 4 )
54 : ld r9 ,1 4 4 ( 4 )
55 : ld r7 ,1 6 ( 4 )
56 : std r28 ,6 6 4 ( 3 )
57 : std r27 ,5 3 6 ( 3 )
58 : std r26 ,4 0 8 ( 3 )
59 : std r31 ,2 8 0 ( 3 )
60 : std r30 ,1 5 2 ( 3 )
61 : stdu r29 ,2 4 ( 3 )
62 : ld r25 ,6 6 4 ( 4 )
63 : ld r24 ,5 3 6 ( 4 )
64 : ld r23 ,4 0 8 ( 4 )
65 : ld r10 ,2 8 0 ( 4 )
66 : ld r8 ,1 5 2 ( 4 )
67 : ldu r6 ,2 4 ( 4 )
bdnz 1 b
68 : std r22 ,6 4 8 ( 3 )
69 : std r21 ,5 2 0 ( 3 )
70 : std r20 ,3 9 2 ( 3 )
71 : std r11 ,2 6 4 ( 3 )
72 : std r9 ,1 3 6 ( 3 )
73 : std r7 ,8 ( 3 )
74 : addi r4 ,r4 ,6 4 0
75 : addi r3 ,r3 ,6 4 8
bge 0 b
mtctr r5
76 : ld r7 ,0 ( 4 )
77 : ld r8 ,8 ( 4 )
78 : ldu r9 ,1 6 ( 4 )
3 :
79 : ld r10 ,8 ( 4 )
80 : std r7 ,8 ( 3 )
81 : ld r7 ,1 6 ( 4 )
82 : std r8 ,1 6 ( 3 )
83 : ld r8 ,2 4 ( 4 )
84 : std r9 ,2 4 ( 3 )
85 : ldu r9 ,3 2 ( 4 )
86 : stdu r10 ,3 2 ( 3 )
bdnz 3 b
4 :
87 : ld r10 ,8 ( 4 )
88 : std r7 ,8 ( 3 )
89 : std r8 ,1 6 ( 3 )
90 : std r9 ,2 4 ( 3 )
91 : std r10 ,3 2 ( 3 )
9 : ld r20 ,- 1 2 0 ( 1 )
ld r21 ,- 1 1 2 ( 1 )
ld r22 ,- 1 0 4 ( 1 )
ld r23 ,- 9 6 ( 1 )
ld r24 ,- 8 8 ( 1 )
ld r25 ,- 8 0 ( 1 )
ld r26 ,- 7 2 ( 1 )
ld r27 ,- 6 4 ( 1 )
ld r28 ,- 5 6 ( 1 )
ld r29 ,- 4 8 ( 1 )
ld r30 ,- 4 0 ( 1 )
ld r31 ,- 3 2 ( 1 )
li r3 ,0
blr
/ *
* on a n e x c e p t i o n , r e s e t t o t h e b e g i n n i n g a n d j u m p b a c k i n t o t h e
* standard _ _ c o p y _ t o f r o m _ u s e r
* /
100 : ld r20 ,- 1 2 0 ( 1 )
ld r21 ,- 1 1 2 ( 1 )
ld r22 ,- 1 0 4 ( 1 )
ld r23 ,- 9 6 ( 1 )
ld r24 ,- 8 8 ( 1 )
ld r25 ,- 8 0 ( 1 )
ld r26 ,- 7 2 ( 1 )
ld r27 ,- 6 4 ( 1 )
ld r28 ,- 5 6 ( 1 )
ld r29 ,- 4 8 ( 1 )
ld r30 ,- 4 0 ( 1 )
ld r31 ,- 3 2 ( 1 )
ld r3 ,- 2 4 ( r1 )
ld r4 ,- 1 6 ( r1 )
li r5 ,4 0 9 6
b . L d s t _ a l i g n e d
2016-10-13 08:42:53 +03:00
EX_ T A B L E ( 2 0 b ,1 0 0 b )
EX_ T A B L E ( 2 1 b ,1 0 0 b )
EX_ T A B L E ( 2 2 b ,1 0 0 b )
EX_ T A B L E ( 2 3 b ,1 0 0 b )
EX_ T A B L E ( 2 4 b ,1 0 0 b )
EX_ T A B L E ( 2 5 b ,1 0 0 b )
EX_ T A B L E ( 2 6 b ,1 0 0 b )
EX_ T A B L E ( 2 7 b ,1 0 0 b )
EX_ T A B L E ( 2 8 b ,1 0 0 b )
EX_ T A B L E ( 2 9 b ,1 0 0 b )
EX_ T A B L E ( 3 0 b ,1 0 0 b )
EX_ T A B L E ( 3 1 b ,1 0 0 b )
EX_ T A B L E ( 3 2 b ,1 0 0 b )
EX_ T A B L E ( 3 3 b ,1 0 0 b )
EX_ T A B L E ( 3 4 b ,1 0 0 b )
EX_ T A B L E ( 3 5 b ,1 0 0 b )
EX_ T A B L E ( 3 6 b ,1 0 0 b )
EX_ T A B L E ( 3 7 b ,1 0 0 b )
EX_ T A B L E ( 3 8 b ,1 0 0 b )
EX_ T A B L E ( 3 9 b ,1 0 0 b )
EX_ T A B L E ( 4 0 b ,1 0 0 b )
EX_ T A B L E ( 4 1 b ,1 0 0 b )
EX_ T A B L E ( 4 2 b ,1 0 0 b )
EX_ T A B L E ( 4 3 b ,1 0 0 b )
EX_ T A B L E ( 4 4 b ,1 0 0 b )
EX_ T A B L E ( 4 5 b ,1 0 0 b )
EX_ T A B L E ( 4 6 b ,1 0 0 b )
EX_ T A B L E ( 4 7 b ,1 0 0 b )
EX_ T A B L E ( 4 8 b ,1 0 0 b )
EX_ T A B L E ( 4 9 b ,1 0 0 b )
EX_ T A B L E ( 5 0 b ,1 0 0 b )
EX_ T A B L E ( 5 1 b ,1 0 0 b )
EX_ T A B L E ( 5 2 b ,1 0 0 b )
EX_ T A B L E ( 5 3 b ,1 0 0 b )
EX_ T A B L E ( 5 4 b ,1 0 0 b )
EX_ T A B L E ( 5 5 b ,1 0 0 b )
EX_ T A B L E ( 5 6 b ,1 0 0 b )
EX_ T A B L E ( 5 7 b ,1 0 0 b )
EX_ T A B L E ( 5 8 b ,1 0 0 b )
EX_ T A B L E ( 5 9 b ,1 0 0 b )
EX_ T A B L E ( 6 0 b ,1 0 0 b )
EX_ T A B L E ( 6 1 b ,1 0 0 b )
EX_ T A B L E ( 6 2 b ,1 0 0 b )
EX_ T A B L E ( 6 3 b ,1 0 0 b )
EX_ T A B L E ( 6 4 b ,1 0 0 b )
EX_ T A B L E ( 6 5 b ,1 0 0 b )
EX_ T A B L E ( 6 6 b ,1 0 0 b )
EX_ T A B L E ( 6 7 b ,1 0 0 b )
EX_ T A B L E ( 6 8 b ,1 0 0 b )
EX_ T A B L E ( 6 9 b ,1 0 0 b )
EX_ T A B L E ( 7 0 b ,1 0 0 b )
EX_ T A B L E ( 7 1 b ,1 0 0 b )
EX_ T A B L E ( 7 2 b ,1 0 0 b )
EX_ T A B L E ( 7 3 b ,1 0 0 b )
EX_ T A B L E ( 7 4 b ,1 0 0 b )
EX_ T A B L E ( 7 5 b ,1 0 0 b )
EX_ T A B L E ( 7 6 b ,1 0 0 b )
EX_ T A B L E ( 7 7 b ,1 0 0 b )
EX_ T A B L E ( 7 8 b ,1 0 0 b )
EX_ T A B L E ( 7 9 b ,1 0 0 b )
EX_ T A B L E ( 8 0 b ,1 0 0 b )
EX_ T A B L E ( 8 1 b ,1 0 0 b )
EX_ T A B L E ( 8 2 b ,1 0 0 b )
EX_ T A B L E ( 8 3 b ,1 0 0 b )
EX_ T A B L E ( 8 4 b ,1 0 0 b )
EX_ T A B L E ( 8 5 b ,1 0 0 b )
EX_ T A B L E ( 8 6 b ,1 0 0 b )
EX_ T A B L E ( 8 7 b ,1 0 0 b )
EX_ T A B L E ( 8 8 b ,1 0 0 b )
EX_ T A B L E ( 8 9 b ,1 0 0 b )
EX_ T A B L E ( 9 0 b ,1 0 0 b )
EX_ T A B L E ( 9 1 b ,1 0 0 b )
2016-01-14 07:33:46 +03:00
EXPORT_ S Y M B O L ( _ _ c o p y _ t o f r o m _ u s e r )