2008-07-02 17:53:13 +04:00
/ *
* Copyright 2 0 0 8 V i t a l y M a y a t s k i k h < v m a y a t s k @redhat.com>
* Copyright 2 0 0 2 A n d i K l e e n , S u S E L a b s .
2007-02-13 15:26:19 +03:00
* Subject t o t h e G N U P u b l i c L i c e n s e v2 .
*
* Functions t o c o p y f r o m a n d t o u s e r s p a c e .
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / d w a r f2 . h >
# define F I X _ A L I G N M E N T 1
# include < a s m / c u r r e n t . h >
# include < a s m / a s m - o f f s e t s . h >
# include < a s m / t h r e a d _ i n f o . h >
2008-07-02 17:53:13 +04:00
.macro ALIGN_DESTINATION
2007-02-13 15:26:19 +03:00
# ifdef F I X _ A L I G N M E N T
/* check for bad alignment of destination */
movl % e d i ,% e c x
andl $ 7 ,% e c x
2008-07-02 17:53:13 +04:00
jz 1 0 2 f / * a l r e a d y a l i g n e d * /
subl $ 8 ,% e c x
negl % e c x
subl % e c x ,% e d x
100 : movb ( % r s i ) ,% a l
101 : movb % a l ,( % r d i )
incq % r s i
incq % r d i
decl % e c x
jnz 1 0 0 b
102 :
.section .fixup , " ax"
2008-07-30 15:30:14 +04:00
103 : addl % e c x ,% e d x / * e c x i s z e r o r e s t a l s o * /
2008-07-02 17:53:13 +04:00
jmp c o p y _ u s e r _ h a n d l e _ t a i l
.previous
2007-02-13 15:26:19 +03:00
2008-07-02 17:53:13 +04:00
.section _ _ ex_ t a b l e ," a "
.align 8
.quad 1 0 0 b,1 0 3 b
.quad 1 0 1 b,1 0 3 b
.previous
# endif
.endm
2007-02-13 15:26:19 +03:00
2008-07-02 17:53:13 +04:00
/ *
* copy_ u s e r _ n o c a c h e - U n c a c h e d m e m o r y c o p y w i t h e x c e p t i o n h a n d l i n g
* This w i l l f o r c e d e s t i n a t i o n / s o u r c e o u t o f c a c h e f o r m o r e p e r f o r m a n c e .
* /
ENTRY( _ _ c o p y _ u s e r _ n o c a c h e )
CFI_ S T A R T P R O C
cmpl $ 8 ,% e d x
jb 2 0 f / * l e s s t h e n 8 b y t e s , g o t o b y t e c o p y l o o p * /
ALIGN_ D E S T I N A T I O N
movl % e d x ,% e c x
andl $ 6 3 ,% e d x
shrl $ 6 ,% e c x
jz 1 7 f
1 : movq ( % r s i ) ,% r8
2 : movq 1 * 8 ( % r s i ) ,% r9
3 : movq 2 * 8 ( % r s i ) ,% r10
4 : movq 3 * 8 ( % r s i ) ,% r11
5 : movnti % r8 ,( % r d i )
6 : movnti % r9 ,1 * 8 ( % r d i )
7 : movnti % r10 ,2 * 8 ( % r d i )
8 : movnti % r11 ,3 * 8 ( % r d i )
9 : movq 4 * 8 ( % r s i ) ,% r8
10 : movq 5 * 8 ( % r s i ) ,% r9
11 : movq 6 * 8 ( % r s i ) ,% r10
12 : movq 7 * 8 ( % r s i ) ,% r11
13 : movnti % r8 ,4 * 8 ( % r d i )
14 : movnti % r9 ,5 * 8 ( % r d i )
15 : movnti % r10 ,6 * 8 ( % r d i )
16 : movnti % r11 ,7 * 8 ( % r d i )
2007-02-13 15:26:19 +03:00
leaq 6 4 ( % r s i ) ,% r s i
leaq 6 4 ( % r d i ) ,% r d i
decl % e c x
2008-07-02 17:53:13 +04:00
jnz 1 b
17 : movl % e d x ,% e c x
andl $ 7 ,% e d x
shrl $ 3 ,% e c x
jz 2 0 f
18 : movq ( % r s i ) ,% r8
19 : movnti % r8 ,( % r d i )
2007-02-13 15:26:19 +03:00
leaq 8 ( % r s i ) ,% r s i
2008-07-02 17:53:13 +04:00
leaq 8 ( % r d i ) ,% r d i
decl % e c x
jnz 1 8 b
20 : andl % e d x ,% e d x
jz 2 3 f
2007-02-13 15:26:19 +03:00
movl % e d x ,% e c x
2008-07-02 17:53:13 +04:00
21 : movb ( % r s i ) ,% a l
22 : movb % a l ,( % r d i )
2007-02-13 15:26:19 +03:00
incq % r s i
2008-07-02 17:53:13 +04:00
incq % r d i
2007-02-13 15:26:19 +03:00
decl % e c x
2008-07-02 17:53:13 +04:00
jnz 2 1 b
23 : xorl % e a x ,% e a x
2007-10-13 05:06:00 +04:00
sfence
2007-02-13 15:26:19 +03:00
ret
2008-07-02 17:53:13 +04:00
.section .fixup , " ax"
30 : shll $ 6 ,% e c x
addl % e c x ,% e d x
jmp 6 0 f
2008-07-10 23:52:52 +04:00
40 : lea ( % r d x ,% r c x ,8 ) ,% r d x
2008-07-02 17:53:13 +04:00
jmp 6 0 f
50 : movl % e c x ,% e d x
60 : sfence
jmp c o p y _ u s e r _ h a n d l e _ t a i l
.previous
2007-02-13 15:26:19 +03:00
.section _ _ ex_ t a b l e ," a "
2008-07-02 17:53:13 +04:00
.quad 1 b,3 0 b
.quad 2 b,3 0 b
.quad 3 b,3 0 b
.quad 4 b,3 0 b
.quad 5 b,3 0 b
.quad 6 b,3 0 b
.quad 7 b,3 0 b
.quad 8 b,3 0 b
.quad 9 b,3 0 b
.quad 1 0 b,3 0 b
.quad 1 1 b,3 0 b
.quad 1 2 b,3 0 b
.quad 1 3 b,3 0 b
.quad 1 4 b,3 0 b
.quad 1 5 b,3 0 b
.quad 1 6 b,3 0 b
.quad 1 8 b,4 0 b
.quad 1 9 b,4 0 b
.quad 2 1 b,5 0 b
.quad 2 2 b,5 0 b
2007-02-13 15:26:19 +03:00
.previous
CFI_ E N D P R O C
ENDPROC( _ _ c o p y _ u s e r _ n o c a c h e )