2005-04-16 15:20:36 -07:00
/ * U3 m e m c p y . S : U l t r a S p a r c - I I I o p t i m i z e d m e m c p y .
*
* Copyright ( C ) 1 9 9 9 , 2 0 0 0 , 2 0 0 4 D a v i d S . M i l l e r ( d a v e m @redhat.com)
* /
# ifdef _ _ K E R N E L _ _
2016-10-24 21:20:35 -07:00
# include < l i n u x / l i n k a g e . h >
2005-04-16 15:20:36 -07:00
# include < a s m / v i s a s m . h >
# include < a s m / a s i . h >
# define G L O B A L _ S P A R E % g 7
# else
# define A S I _ B L K _ P 0 x f0
# define F P R S _ F E F 0 x04
# ifdef M E M C P Y _ D E B U G
# define V I S E n t r y H a l f r d % f p r s , % o 5 ; wr %g0, FPRS_FEF, %fprs; \
clr % g 1 ; clr %g2; clr %g3; subcc %g0, %g0, %g0;
# define V I S E x i t H a l f a n d % o 5 , F P R S _ F E F , % o 5 ; wr %o5, 0x0, %fprs
# else
# define V I S E n t r y H a l f r d % f p r s , % o 5 ; wr %g0, FPRS_FEF, %fprs
# define V I S E x i t H a l f a n d % o 5 , F P R S _ F E F , % o 5 ; wr %o5, 0x0, %fprs
# endif
# define G L O B A L _ S P A R E % g 5
# endif
# ifndef E X _ L D
2016-10-24 21:20:35 -07:00
# define E X _ L D ( x ,y ) x
2005-04-16 15:20:36 -07:00
# endif
sparc64: fix FP corruption in user copy functions
Short story: Exception handlers used by some copy_to_user() and
copy_from_user() functions do not diligently clean up floating point
register usage, and this can result in a user process seeing invalid
values in floating point registers. This sometimes makes the process
fail.
Long story: Several cpu-specific (NG4, NG2, U1, U3) memcpy functions
use floating point registers and VIS alignaddr/faligndata to
accelerate data copying when source and dest addresses don't align
well. Linux uses a lazy scheme for saving floating point registers; It
is not done upon entering the kernel since it's a very expensive
operation. Rather, it is done only when needed. If the kernel ends up
not using FP regs during the course of some trap or system call, then
it can return to user space without saving or restoring them.
The various memcpy functions begin their FP code with VISEntry (or a
variation thereof), which saves the FP regs. They conclude their FP
code with VISExit (or a variation) which essentially marks the FP regs
"clean", ie, they contain no unsaved values. fprs.FPRS_FEF is turned
off so that a lazy restore will be triggered when/if the user process
accesses floating point regs again.
The bug is that the user copy variants of memcpy, copy_from_user() and
copy_to_user(), employ an exception handling mechanism to detect faults
when accessing user space addresses, and when this handler is invoked,
an immediate return from the function is forced, and VISExit is not
executed, thus leaving the fprs register in an indeterminate state,
but often with fprs.FPRS_FEF set and one or more dirty bits. This
results in a return to user space with invalid values in the FP regs,
and since fprs.FPRS_FEF is on, no lazy restore occurs.
This bug affects copy_to_user() and copy_from_user() for NG4, NG2,
U3, and U1. All are fixed by using a new exception handler for those
loads and stores that are done during the time between VISEnter and
VISExit.
n.b. In NG4memcpy, the problematic code can be triggered by a copy
size greater than 128 bytes and an unaligned source address. This bug
is known to be the cause of random user process memory corruptions
while perf is running with the callgraph option (ie, perf record -g).
This occurs because perf uses copy_from_user() to read user stacks,
and may fault when it follows a stack frame pointer off to an
invalid page. Validation checks on the stack address just obscure
the underlying problem.
Signed-off-by: Rob Gardner <rob.gardner@oracle.com>
Signed-off-by: Dave Aldridge <david.j.aldridge@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-22 23:24:49 -07:00
# ifndef E X _ L D _ F P
2016-10-24 21:20:35 -07:00
# define E X _ L D _ F P ( x ,y ) x
sparc64: fix FP corruption in user copy functions
Short story: Exception handlers used by some copy_to_user() and
copy_from_user() functions do not diligently clean up floating point
register usage, and this can result in a user process seeing invalid
values in floating point registers. This sometimes makes the process
fail.
Long story: Several cpu-specific (NG4, NG2, U1, U3) memcpy functions
use floating point registers and VIS alignaddr/faligndata to
accelerate data copying when source and dest addresses don't align
well. Linux uses a lazy scheme for saving floating point registers; It
is not done upon entering the kernel since it's a very expensive
operation. Rather, it is done only when needed. If the kernel ends up
not using FP regs during the course of some trap or system call, then
it can return to user space without saving or restoring them.
The various memcpy functions begin their FP code with VISEntry (or a
variation thereof), which saves the FP regs. They conclude their FP
code with VISExit (or a variation) which essentially marks the FP regs
"clean", ie, they contain no unsaved values. fprs.FPRS_FEF is turned
off so that a lazy restore will be triggered when/if the user process
accesses floating point regs again.
The bug is that the user copy variants of memcpy, copy_from_user() and
copy_to_user(), employ an exception handling mechanism to detect faults
when accessing user space addresses, and when this handler is invoked,
an immediate return from the function is forced, and VISExit is not
executed, thus leaving the fprs register in an indeterminate state,
but often with fprs.FPRS_FEF set and one or more dirty bits. This
results in a return to user space with invalid values in the FP regs,
and since fprs.FPRS_FEF is on, no lazy restore occurs.
This bug affects copy_to_user() and copy_from_user() for NG4, NG2,
U3, and U1. All are fixed by using a new exception handler for those
loads and stores that are done during the time between VISEnter and
VISExit.
n.b. In NG4memcpy, the problematic code can be triggered by a copy
size greater than 128 bytes and an unaligned source address. This bug
is known to be the cause of random user process memory corruptions
while perf is running with the callgraph option (ie, perf record -g).
This occurs because perf uses copy_from_user() to read user stacks,
and may fault when it follows a stack frame pointer off to an
invalid page. Validation checks on the stack address just obscure
the underlying problem.
Signed-off-by: Rob Gardner <rob.gardner@oracle.com>
Signed-off-by: Dave Aldridge <david.j.aldridge@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-22 23:24:49 -07:00
# endif
2005-04-16 15:20:36 -07:00
# ifndef E X _ S T
2016-10-24 21:20:35 -07:00
# define E X _ S T ( x ,y ) x
2005-04-16 15:20:36 -07:00
# endif
sparc64: fix FP corruption in user copy functions
Short story: Exception handlers used by some copy_to_user() and
copy_from_user() functions do not diligently clean up floating point
register usage, and this can result in a user process seeing invalid
values in floating point registers. This sometimes makes the process
fail.
Long story: Several cpu-specific (NG4, NG2, U1, U3) memcpy functions
use floating point registers and VIS alignaddr/faligndata to
accelerate data copying when source and dest addresses don't align
well. Linux uses a lazy scheme for saving floating point registers; It
is not done upon entering the kernel since it's a very expensive
operation. Rather, it is done only when needed. If the kernel ends up
not using FP regs during the course of some trap or system call, then
it can return to user space without saving or restoring them.
The various memcpy functions begin their FP code with VISEntry (or a
variation thereof), which saves the FP regs. They conclude their FP
code with VISExit (or a variation) which essentially marks the FP regs
"clean", ie, they contain no unsaved values. fprs.FPRS_FEF is turned
off so that a lazy restore will be triggered when/if the user process
accesses floating point regs again.
The bug is that the user copy variants of memcpy, copy_from_user() and
copy_to_user(), employ an exception handling mechanism to detect faults
when accessing user space addresses, and when this handler is invoked,
an immediate return from the function is forced, and VISExit is not
executed, thus leaving the fprs register in an indeterminate state,
but often with fprs.FPRS_FEF set and one or more dirty bits. This
results in a return to user space with invalid values in the FP regs,
and since fprs.FPRS_FEF is on, no lazy restore occurs.
This bug affects copy_to_user() and copy_from_user() for NG4, NG2,
U3, and U1. All are fixed by using a new exception handler for those
loads and stores that are done during the time between VISEnter and
VISExit.
n.b. In NG4memcpy, the problematic code can be triggered by a copy
size greater than 128 bytes and an unaligned source address. This bug
is known to be the cause of random user process memory corruptions
while perf is running with the callgraph option (ie, perf record -g).
This occurs because perf uses copy_from_user() to read user stacks,
and may fault when it follows a stack frame pointer off to an
invalid page. Validation checks on the stack address just obscure
the underlying problem.
Signed-off-by: Rob Gardner <rob.gardner@oracle.com>
Signed-off-by: Dave Aldridge <david.j.aldridge@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-22 23:24:49 -07:00
# ifndef E X _ S T _ F P
2016-10-24 21:20:35 -07:00
# define E X _ S T _ F P ( x ,y ) x
2005-04-16 15:20:36 -07:00
# endif
# ifndef L O A D
# define L O A D ( t y p e ,a d d r ,d e s t ) t y p e [ a d d r ] , d e s t
# endif
# ifndef S T O R E
# define S T O R E ( t y p e ,s r c ,a d d r ) t y p e s r c , [ a d d r ]
# endif
# ifndef S T O R E _ B L K
# define S T O R E _ B L K ( s r c ,a d d r ) s t d a s r c , [ a d d r ] A S I _ B L K _ P
# endif
# ifndef F U N C _ N A M E
# define F U N C _ N A M E U 3 m e m c p y
# endif
# ifndef P R E A M B L E
# define P R E A M B L E
# endif
# ifndef X C C
# define X C C x c c
# endif
.register % g2 ,#s c r a t c h
.register % g3 ,#s c r a t c h
/ * Special/ n o n - t r i v i a l i s s u e s o f t h i s c o d e :
*
* 1 ) % o5 i s p r e s e r v e d f r o m V I S E n t r y H a l f t o V I S E x i t H a l f
* 2 ) Only l o w 3 2 F P U r e g i s t e r s a r e u s e d s o t h a t o n l y t h e
* lower h a l f o f t h e F P U r e g i s t e r s e t i s d i r t i e d b y t h i s
* code. T h i s i s e s p e c i a l l y i m p o r t a n t i n t h e k e r n e l .
* 3 ) This c o d e n e v e r p r e f e t c h e s c a c h e l i n e s p a s t t h e e n d
* of t h e s o u r c e b u f f e r .
* /
.text
2016-10-24 21:20:35 -07:00
# ifndef E X _ R E T V A L
# define E X _ R E T V A L ( x ) x
__restore_fp :
VISExitHalf
retl
nop
ENTRY( U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ p l u s _ g 1 _ p l u s _ 1 _ f p )
add % g 1 , 1 , % g 1
add % g 2 , % g 1 , % g 2
ba,p t % x c c , _ _ r e s t o r e _ f p
add % o 2 , % g 2 , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ p l u s _ g 1 _ p l u s _ 1 _ f p )
ENTRY( U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ f p )
ba,p t % x c c , _ _ r e s t o r e _ f p
add % o 2 , % g 2 , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ f p )
ENTRY( U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ p l u s _ 8 _ f p )
add % g 2 , 8 , % g 2
ba,p t % x c c , _ _ r e s t o r e _ f p
add % o 2 , % g 2 , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ p l u s _ 8 _ f p )
ENTRY( U 3 _ r e t l _ o 2 )
retl
mov % o 2 , % o 0
ENDPROC( U 3 _ r e t l _ o 2 )
ENTRY( U 3 _ r e t l _ o 2 _ p l u s _ 1 )
retl
add % o 2 , 1 , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ p l u s _ 1 )
ENTRY( U 3 _ r e t l _ o 2 _ p l u s _ 4 )
retl
add % o 2 , 4 , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ p l u s _ 4 )
ENTRY( U 3 _ r e t l _ o 2 _ p l u s _ 8 )
retl
add % o 2 , 8 , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ p l u s _ 8 )
ENTRY( U 3 _ r e t l _ o 2 _ p l u s _ g 1 _ p l u s _ 1 )
add % g 1 , 1 , % g 1
retl
add % o 2 , % g 1 , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ p l u s _ g 1 _ p l u s _ 1 )
ENTRY( U 3 _ r e t l _ o 2 _ f p )
ba,p t % x c c , _ _ r e s t o r e _ f p
mov % o 2 , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ f p )
ENTRY( U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x80 _ f p )
sll % o 3 , 6 , % o 3
add % o 3 , 0 x80 , % o 3
ba,p t % x c c , _ _ r e s t o r e _ f p
add % o 2 , % o 3 , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x80 _ f p )
ENTRY( U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 _ f p )
sll % o 3 , 6 , % o 3
add % o 3 , 0 x40 , % o 3
ba,p t % x c c , _ _ r e s t o r e _ f p
add % o 2 , % o 3 , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 _ f p )
ENTRY( U 3 _ r e t l _ o 2 _ p l u s _ G S _ p l u s _ 0 x10 )
add G L O B A L _ S P A R E , 0 x10 , G L O B A L _ S P A R E
retl
add % o 2 , G L O B A L _ S P A R E , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ p l u s _ G S _ p l u s _ 0 x10 )
ENTRY( U 3 _ r e t l _ o 2 _ p l u s _ G S _ p l u s _ 0 x08 )
add G L O B A L _ S P A R E , 0 x08 , G L O B A L _ S P A R E
retl
add % o 2 , G L O B A L _ S P A R E , % o 0
ENDPROC( U 3 _ r e t l _ o 2 _ p l u s _ G S _ p l u s _ 0 x08 )
ENTRY( U 3 _ r e t l _ o 2 _ a n d _ 7 _ p l u s _ G S )
and % o 2 , 7 , % o 2
retl
add % o 2 , G L O B A L _ S P A R E , % o 2
ENDPROC( U 3 _ r e t l _ o 2 _ a n d _ 7 _ p l u s _ G S )
ENTRY( U 3 _ r e t l _ o 2 _ a n d _ 7 _ p l u s _ G S _ p l u s _ 8 )
add G L O B A L _ S P A R E , 8 , G L O B A L _ S P A R E
and % o 2 , 7 , % o 2
retl
add % o 2 , G L O B A L _ S P A R E , % o 2
ENDPROC( U 3 _ r e t l _ o 2 _ a n d _ 7 _ p l u s _ G S _ p l u s _ 8 )
# endif
2005-04-16 15:20:36 -07:00
.align 64
/ * The c h e e t a h ' s f l e x i b l e s p i n e , o v e r s i z e d l i v e r , e n l a r g e d h e a r t ,
* slender m u s c u l a r b o d y , a n d c l a w s m a k e i t t h e s w i f t e s t h u n t e r
* in A f r i c a a n d t h e f a s t e s t a n i m a l o n l a n d . C a n r e a c h s p e e d s
* of u p t o 2 . 4 G B p e r s e c o n d .
* /
.globl FUNC_NAME
.type FUNC_ N A M E ,#f u n c t i o n
FUNC_NAME : /* %o0=dst, %o1=src, %o2=len */
srlx % o 2 , 3 1 , % g 2
cmp % g 2 , 0
tne % x c c , 5
PREAMBLE
mov % o 0 , % o 4
cmp % o 2 , 0
be,p n % X C C , 8 5 f
or % o 0 , % o 1 , % o 3
cmp % o 2 , 1 6
blu,a ,p n % X C C , 8 0 f
or % o 3 , % o 2 , % o 3
cmp % o 2 , ( 3 * 6 4 )
blu,p t % X C C , 7 0 f
andcc % o 3 , 0 x7 , % g 0
/ * Clobbers o 5 / g 1 / g 2 / g 3 / g 7 / i c c / x c c . W e m u s t p r e s e r v e
* o5 f r o m h e r e u n t i l w e h i t V I S E x i t H a l f .
* /
VISEntryHalf
/* Is 'dst' already aligned on an 64-byte boundary? */
andcc % o 0 , 0 x3 f , % g 2
be,p t % X C C , 2 f
/ * Compute a b s ( ( d s t & 0 x3 f ) - 0 x40 ) i n t o % g 2 . T h i s i s t h e n u m b e r
* of b y t e s t o c o p y t o m a k e ' d s t ' 6 4 - b y t e a l i g n e d . W e p r e -
* subtract t h i s f r o m ' l e n ' .
* /
sub % o 0 , % o 1 , G L O B A L _ S P A R E
sub % g 2 , 0 x40 , % g 2
sub % g 0 , % g 2 , % g 2
sub % o 2 , % g 2 , % o 2
andcc % g 2 , 0 x7 , % g 1
be,p t % i c c , 2 f
and % g 2 , 0 x38 , % g 2
1 : subcc % g 1 , 0 x1 , % g 1
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d u b , % o 1 + 0 x00 , % o 3 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ p l u s _ g 1 _ p l u s _ 1 )
EX_ S T _ F P ( S T O R E ( s t b , % o 3 , % o 1 + G L O B A L _ S P A R E ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ p l u s _ g 1 _ p l u s _ 1 )
2005-04-16 15:20:36 -07:00
bgu,p t % X C C , 1 b
add % o 1 , 0 x1 , % o 1
add % o 1 , G L O B A L _ S P A R E , % o 0
2 : cmp % g 2 , 0 x0
and % o 1 , 0 x7 , % g 1
be,p t % i c c , 3 f
alignaddr % o 1 , % g 0 , % o 1
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 , % f4 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 )
1 : EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x8 , % f6 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 )
2005-04-16 15:20:36 -07:00
add % o 1 , 0 x8 , % o 1
subcc % g 2 , 0 x8 , % g 2
faligndata % f4 , % f6 , % f0
2016-10-24 21:20:35 -07:00
EX_ S T _ F P ( S T O R E ( s t d , % f0 , % o 0 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ p l u s _ 8 )
2005-04-16 15:20:36 -07:00
be,p n % i c c , 3 f
add % o 0 , 0 x8 , % o 0
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x8 , % f4 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 )
2005-04-16 15:20:36 -07:00
add % o 1 , 0 x8 , % o 1
subcc % g 2 , 0 x8 , % g 2
faligndata % f6 , % f4 , % f2
2016-10-24 21:20:35 -07:00
EX_ S T _ F P ( S T O R E ( s t d , % f2 , % o 0 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ p l u s _ 8 )
2005-04-16 15:20:36 -07:00
bne,p t % i c c , 1 b
add % o 0 , 0 x8 , % o 0
3 : LOAD( p r e f e t c h , % o 1 + 0 x00 0 , #o n e _ r e a d )
LOAD( p r e f e t c h , % o 1 + 0 x04 0 , #o n e _ r e a d )
andn % o 2 , ( 0 x40 - 1 ) , G L O B A L _ S P A R E
LOAD( p r e f e t c h , % o 1 + 0 x08 0 , #o n e _ r e a d )
LOAD( p r e f e t c h , % o 1 + 0 x0 c0 , #o n e _ r e a d )
LOAD( p r e f e t c h , % o 1 + 0 x10 0 , #o n e _ r e a d )
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x00 0 , % f0 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
LOAD( p r e f e t c h , % o 1 + 0 x14 0 , #o n e _ r e a d )
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x00 8 , % f2 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
LOAD( p r e f e t c h , % o 1 + 0 x18 0 , #o n e _ r e a d )
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x01 0 , % f4 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
LOAD( p r e f e t c h , % o 1 + 0 x1 c0 , #o n e _ r e a d )
faligndata % f0 , % f2 , % f16
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x01 8 , % f6 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
faligndata % f2 , % f4 , % f18
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x02 0 , % f8 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
faligndata % f4 , % f6 , % f20
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x02 8 , % f10 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
faligndata % f6 , % f8 , % f22
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x03 0 , % f12 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
faligndata % f8 , % f10 , % f24
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x03 8 , % f14 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
faligndata % f10 , % f12 , % f26
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x04 0 , % f0 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
subcc G L O B A L _ S P A R E , 0 x80 , G L O B A L _ S P A R E
add % o 1 , 0 x40 , % o 1
bgu,p t % X C C , 1 f
srl G L O B A L _ S P A R E , 6 , % o 3
ba,p t % x c c , 2 f
nop
.align 64
1 :
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x00 8 , % f2 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x80 )
2005-04-16 15:20:36 -07:00
faligndata % f12 , % f14 , % f28
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x01 0 , % f4 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x80 )
2005-04-16 15:20:36 -07:00
faligndata % f14 , % f0 , % f30
2016-10-24 21:20:35 -07:00
EX_ S T _ F P ( S T O R E _ B L K ( % f16 , % o 0 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x80 )
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x01 8 , % f6 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 )
2005-04-16 15:20:36 -07:00
faligndata % f0 , % f2 , % f16
add % o 0 , 0 x40 , % o 0
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x02 0 , % f8 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 )
2005-04-16 15:20:36 -07:00
faligndata % f2 , % f4 , % f18
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x02 8 , % f10 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 )
2005-04-16 15:20:36 -07:00
faligndata % f4 , % f6 , % f20
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x03 0 , % f12 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 )
2005-04-16 15:20:36 -07:00
subcc % o 3 , 0 x01 , % o 3
faligndata % f6 , % f8 , % f22
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x03 8 , % f14 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x80 )
2005-04-16 15:20:36 -07:00
faligndata % f8 , % f10 , % f24
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x04 0 , % f0 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x80 )
2005-04-16 15:20:36 -07:00
LOAD( p r e f e t c h , % o 1 + 0 x1 c0 , #o n e _ r e a d )
faligndata % f10 , % f12 , % f26
bg,p t % X C C , 1 b
add % o 1 , 0 x40 , % o 1
/* Finally we copy the last full 64-byte block. */
2 :
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x00 8 , % f2 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x80 )
2005-04-16 15:20:36 -07:00
faligndata % f12 , % f14 , % f28
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x01 0 , % f4 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x80 )
2005-04-16 15:20:36 -07:00
faligndata % f14 , % f0 , % f30
2016-10-24 21:20:35 -07:00
EX_ S T _ F P ( S T O R E _ B L K ( % f16 , % o 0 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x80 )
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x01 8 , % f6 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 )
2005-04-16 15:20:36 -07:00
faligndata % f0 , % f2 , % f16
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x02 0 , % f8 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 )
2005-04-16 15:20:36 -07:00
faligndata % f2 , % f4 , % f18
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x02 8 , % f10 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 )
2005-04-16 15:20:36 -07:00
faligndata % f4 , % f6 , % f20
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x03 0 , % f12 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 )
2005-04-16 15:20:36 -07:00
faligndata % f6 , % f8 , % f22
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x03 8 , % f14 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 )
2005-04-16 15:20:36 -07:00
faligndata % f8 , % f10 , % f24
cmp % g 1 , 0
be,p t % X C C , 1 f
add % o 0 , 0 x40 , % o 0
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x04 0 , % f0 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 )
2005-04-16 15:20:36 -07:00
1 : faligndata % f10 , % f12 , % f26
faligndata % f12 , % f14 , % f28
faligndata % f14 , % f0 , % f30
2016-10-24 21:20:35 -07:00
EX_ S T _ F P ( S T O R E _ B L K ( % f16 , % o 0 ) , U 3 _ r e t l _ o 2 _ p l u s _ o 3 _ s l l _ 6 _ p l u s _ 0 x40 )
2005-04-16 15:20:36 -07:00
add % o 0 , 0 x40 , % o 0
add % o 1 , 0 x40 , % o 1
membar #S y n c
/ * Now w e c o p y t h e ( l e n m o d u l o 6 4 ) b y t e s a t t h e e n d .
* Note h o w w e b o r r o w t h e % f0 l o a d e d a b o v e .
*
* Also n o t i c e h o w t h i s c o d e i s c a r e f u l n o t t o p e r f o r m a
* load p a s t t h e e n d o f t h e s r c b u f f e r .
* /
and % o 2 , 0 x3 f , % o 2
andcc % o 2 , 0 x38 , % g 2
be,p n % X C C , 2 f
subcc % g 2 , 0 x8 , % g 2
be,p n % X C C , 2 f
cmp % g 1 , 0
sub % o 2 , % g 2 , % o 2
be,a ,p t % X C C , 1 f
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x00 , % f0 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 )
2005-04-16 15:20:36 -07:00
2016-10-24 21:20:35 -07:00
1 : EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x08 , % f2 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 )
2005-04-16 15:20:36 -07:00
add % o 1 , 0 x8 , % o 1
subcc % g 2 , 0 x8 , % g 2
faligndata % f0 , % f2 , % f8
2016-10-24 21:20:35 -07:00
EX_ S T _ F P ( S T O R E ( s t d , % f8 , % o 0 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ p l u s _ 8 )
2005-04-16 15:20:36 -07:00
be,p n % X C C , 2 f
add % o 0 , 0 x8 , % o 0
2016-10-24 21:20:35 -07:00
EX_ L D _ F P ( L O A D ( l d d , % o 1 + 0 x08 , % f0 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 )
2005-04-16 15:20:36 -07:00
add % o 1 , 0 x8 , % o 1
subcc % g 2 , 0 x8 , % g 2
faligndata % f2 , % f0 , % f8
2016-10-24 21:20:35 -07:00
EX_ S T _ F P ( S T O R E ( s t d , % f8 , % o 0 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 2 _ p l u s _ 8 )
2005-04-16 15:20:36 -07:00
bne,p n % X C C , 1 b
add % o 0 , 0 x8 , % o 0
/ * If a n y t h i n g i s l e f t , w e c o p y i t o n e b y t e a t a t i m e .
* Note t h a t % g 1 i s ( s r c & 0 x3 ) s a v e d a b o v e b e f o r e t h e
* alignaddr w a s p e r f o r m e d .
* /
2 :
cmp % o 2 , 0
add % o 1 , % g 1 , % o 1
VISExitHalf
be,p n % X C C , 8 5 f
sub % o 0 , % o 1 , % o 3
andcc % g 1 , 0 x7 , % g 0
bne,p n % i c c , 9 0 f
andcc % o 2 , 0 x8 , % g 0
be,p t % i c c , 1 f
nop
2016-10-24 21:20:35 -07:00
EX_ L D ( L O A D ( l d x , % o 1 , % o 5 ) , U 3 _ r e t l _ o 2 )
EX_ S T ( S T O R E ( s t x , % o 5 , % o 1 + % o 3 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
add % o 1 , 0 x8 , % o 1
2016-10-24 21:20:35 -07:00
sub % o 2 , 8 , % o 2
2005-04-16 15:20:36 -07:00
1 : andcc % o 2 , 0 x4 , % g 0
be,p t % i c c , 1 f
nop
2016-10-24 21:20:35 -07:00
EX_ L D ( L O A D ( l d u w , % o 1 , % o 5 ) , U 3 _ r e t l _ o 2 )
EX_ S T ( S T O R E ( s t w , % o 5 , % o 1 + % o 3 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
add % o 1 , 0 x4 , % o 1
2016-10-24 21:20:35 -07:00
sub % o 2 , 4 , % o 2
2005-04-16 15:20:36 -07:00
1 : andcc % o 2 , 0 x2 , % g 0
be,p t % i c c , 1 f
nop
2016-10-24 21:20:35 -07:00
EX_ L D ( L O A D ( l d u h , % o 1 , % o 5 ) , U 3 _ r e t l _ o 2 )
EX_ S T ( S T O R E ( s t h , % o 5 , % o 1 + % o 3 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
add % o 1 , 0 x2 , % o 1
2016-10-24 21:20:35 -07:00
sub % o 2 , 2 , % o 2
2005-04-16 15:20:36 -07:00
1 : andcc % o 2 , 0 x1 , % g 0
be,p t % i c c , 8 5 f
nop
2016-10-24 21:20:35 -07:00
EX_ L D ( L O A D ( l d u b , % o 1 , % o 5 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
ba,p t % x c c , 8 5 f
2016-10-24 21:20:35 -07:00
EX_ S T ( S T O R E ( s t b , % o 5 , % o 1 + % o 3 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
.align 64
70 : /* 16 < len <= 64 */
bne,p n % X C C , 7 5 f
sub % o 0 , % o 1 , % o 3
72 :
andn % o 2 , 0 x f , G L O B A L _ S P A R E
and % o 2 , 0 x f , % o 2
1 : subcc G L O B A L _ S P A R E , 0 x10 , G L O B A L _ S P A R E
2016-10-24 21:20:35 -07:00
EX_ L D ( L O A D ( l d x , % o 1 + 0 x00 , % o 5 ) , U 3 _ r e t l _ o 2 _ p l u s _ G S _ p l u s _ 0 x10 )
EX_ L D ( L O A D ( l d x , % o 1 + 0 x08 , % g 1 ) , U 3 _ r e t l _ o 2 _ p l u s _ G S _ p l u s _ 0 x10 )
EX_ S T ( S T O R E ( s t x , % o 5 , % o 1 + % o 3 ) , U 3 _ r e t l _ o 2 _ p l u s _ G S _ p l u s _ 0 x10 )
2005-04-16 15:20:36 -07:00
add % o 1 , 0 x8 , % o 1
2016-10-24 21:20:35 -07:00
EX_ S T ( S T O R E ( s t x , % g 1 , % o 1 + % o 3 ) , U 3 _ r e t l _ o 2 _ p l u s _ G S _ p l u s _ 0 x08 )
2005-04-16 15:20:36 -07:00
bgu,p t % X C C , 1 b
add % o 1 , 0 x8 , % o 1
73 : andcc % o 2 , 0 x8 , % g 0
be,p t % X C C , 1 f
nop
sub % o 2 , 0 x8 , % o 2
2016-10-24 21:20:35 -07:00
EX_ L D ( L O A D ( l d x , % o 1 , % o 5 ) , U 3 _ r e t l _ o 2 _ p l u s _ 8 )
EX_ S T ( S T O R E ( s t x , % o 5 , % o 1 + % o 3 ) , U 3 _ r e t l _ o 2 _ p l u s _ 8 )
2005-04-16 15:20:36 -07:00
add % o 1 , 0 x8 , % o 1
1 : andcc % o 2 , 0 x4 , % g 0
be,p t % X C C , 1 f
nop
sub % o 2 , 0 x4 , % o 2
2016-10-24 21:20:35 -07:00
EX_ L D ( L O A D ( l d u w , % o 1 , % o 5 ) , U 3 _ r e t l _ o 2 _ p l u s _ 4 )
EX_ S T ( S T O R E ( s t w , % o 5 , % o 1 + % o 3 ) , U 3 _ r e t l _ o 2 _ p l u s _ 4 )
2005-04-16 15:20:36 -07:00
add % o 1 , 0 x4 , % o 1
1 : cmp % o 2 , 0
be,p t % X C C , 8 5 f
nop
ba,p t % x c c , 9 0 f
nop
75 :
andcc % o 0 , 0 x7 , % g 1
sub % g 1 , 0 x8 , % g 1
be,p n % i c c , 2 f
sub % g 0 , % g 1 , % g 1
sub % o 2 , % g 1 , % o 2
1 : subcc % g 1 , 1 , % g 1
2016-10-24 21:20:35 -07:00
EX_ L D ( L O A D ( l d u b , % o 1 , % o 5 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 1 _ p l u s _ 1 )
EX_ S T ( S T O R E ( s t b , % o 5 , % o 1 + % o 3 ) , U 3 _ r e t l _ o 2 _ p l u s _ g 1 _ p l u s _ 1 )
2005-04-16 15:20:36 -07:00
bgu,p t % i c c , 1 b
add % o 1 , 1 , % o 1
2 : add % o 1 , % o 3 , % o 0
andcc % o 1 , 0 x7 , % g 1
bne,p t % i c c , 8 f
sll % g 1 , 3 , % g 1
cmp % o 2 , 1 6
bgeu,p t % i c c , 7 2 b
nop
ba,a ,p t % x c c , 7 3 b
8 : mov 6 4 , % o 3
andn % o 1 , 0 x7 , % o 1
2016-10-24 21:20:35 -07:00
EX_ L D ( L O A D ( l d x , % o 1 , % g 2 ) , U 3 _ r e t l _ o 2 )
2005-04-16 15:20:36 -07:00
sub % o 3 , % g 1 , % o 3
andn % o 2 , 0 x7 , G L O B A L _ S P A R E
sllx % g 2 , % g 1 , % g 2
2016-10-24 21:20:35 -07:00
1 : EX_ L D ( L O A D ( l d x , % o 1 + 0 x8 , % g 3 ) , U 3 _ r e t l _ o 2 _ a n d _ 7 _ p l u s _ G S )
2005-04-16 15:20:36 -07:00
subcc G L O B A L _ S P A R E , 0 x8 , G L O B A L _ S P A R E
add % o 1 , 0 x8 , % o 1
srlx % g 3 , % o 3 , % o 5
or % o 5 , % g 2 , % o 5
2016-10-24 21:20:35 -07:00
EX_ S T ( S T O R E ( s t x , % o 5 , % o 0 ) , U 3 _ r e t l _ o 2 _ a n d _ 7 _ p l u s _ G S _ p l u s _ 8 )
2005-04-16 15:20:36 -07:00
add % o 0 , 0 x8 , % o 0
bgu,p t % i c c , 1 b
sllx % g 3 , % g 1 , % g 2
srl % g 1 , 3 , % g 1
andcc % o 2 , 0 x7 , % o 2
be,p n % i c c , 8 5 f
add % o 1 , % g 1 , % o 1
ba,p t % x c c , 9 0 f
sub % o 0 , % o 1 , % o 3
.align 64
80 : /* 0 < len <= 16 */
andcc % o 3 , 0 x3 , % g 0
bne,p n % X C C , 9 0 f
sub % o 0 , % o 1 , % o 3
1 :
subcc % o 2 , 4 , % o 2
2016-10-24 21:20:35 -07:00
EX_ L D ( L O A D ( l d u w , % o 1 , % g 1 ) , U 3 _ r e t l _ o 2 _ p l u s _ 4 )
EX_ S T ( S T O R E ( s t w , % g 1 , % o 1 + % o 3 ) , U 3 _ r e t l _ o 2 _ p l u s _ 4 )
2005-04-16 15:20:36 -07:00
bgu,p t % X C C , 1 b
add % o 1 , 4 , % o 1
85 : retl
mov E X _ R E T V A L ( % o 4 ) , % o 0
.align 32
90 :
subcc % o 2 , 1 , % o 2
2016-10-24 21:20:35 -07:00
EX_ L D ( L O A D ( l d u b , % o 1 , % g 1 ) , U 3 _ r e t l _ o 2 _ p l u s _ 1 )
EX_ S T ( S T O R E ( s t b , % g 1 , % o 1 + % o 3 ) , U 3 _ r e t l _ o 2 _ p l u s _ 1 )
2005-04-16 15:20:36 -07:00
bgu,p t % X C C , 9 0 b
add % o 1 , 1 , % o 1
retl
mov E X _ R E T V A L ( % o 4 ) , % o 0
.size FUNC_ N A M E , . - F U N C _ N A M E