2005-04-16 15:20:36 -07:00
/ *
* _ _ put_ u s e r f u n c t i o n s .
*
* ( C) C o p y r i g h t 2 0 0 5 L i n u s T o r v a l d s
*
* These f u n c t i o n s h a v e a n o n - s t a n d a r d c a l l i n t e r f a c e
* to m a k e t h e m m o r e e f f i c i e n t , e s p e c i a l l y a s t h e y
* return a n e r r o r v a l u e i n a d d i t i o n t o t h e " r e a l "
* return v a l u e .
* /
2007-05-02 19:27:05 +02:00
# include < l i n u x / l i n k a g e . h >
# include < a s m / d w a r f2 . h >
2005-04-16 15:20:36 -07:00
# include < a s m / t h r e a d _ i n f o . h >
/ *
* _ _ put_ u s e r _ X
*
* Inputs : % eax[ : % e d x ] c o n t a i n s t h e d a t a
* % ecx c o n t a i n s t h e a d d r e s s
*
* Outputs : % eax i s e r r o r c o d e ( 0 o r - E F A U L T )
*
* These f u n c t i o n s s h o u l d n o t m o d i f y a n y o t h e r r e g i s t e r s ,
* as t h e y g e t c a l l e d f r o m w i t h i n i n l i n e a s s e m b l y .
* /
2007-05-02 19:27:05 +02:00
# define E N T E R C F I _ S T A R T P R O C ; \
pushl % e b x ; \
CFI_ A D J U S T _ C F A _ O F F S E T 4 ; \
CFI_ R E L _ O F F S E T e b x , 0 ; \
GET_ T H R E A D _ I N F O ( % e b x )
# define E X I T p o p l % e b x ; \
CFI_ A D J U S T _ C F A _ O F F S E T - 4 ; \
CFI_ R E S T O R E e b x ; \
ret ; \
CFI_ E N D P R O C
2005-04-16 15:20:36 -07:00
.text
2007-05-02 19:27:05 +02:00
ENTRY( _ _ p u t _ u s e r _ 1 )
2005-04-16 15:20:36 -07:00
ENTER
cmpl T I _ a d d r _ l i m i t ( % e b x ) ,% e c x
jae b a d _ p u t _ u s e r
1 : movb % a l ,( % e c x )
xorl % e a x ,% e a x
EXIT
2007-05-02 19:27:05 +02:00
ENDPROC( _ _ p u t _ u s e r _ 1 )
2005-04-16 15:20:36 -07:00
2007-05-02 19:27:05 +02:00
ENTRY( _ _ p u t _ u s e r _ 2 )
2005-04-16 15:20:36 -07:00
ENTER
movl T I _ a d d r _ l i m i t ( % e b x ) ,% e b x
subl $ 1 ,% e b x
cmpl % e b x ,% e c x
jae b a d _ p u t _ u s e r
2 : movw % a x ,( % e c x )
xorl % e a x ,% e a x
EXIT
2007-05-02 19:27:05 +02:00
ENDPROC( _ _ p u t _ u s e r _ 2 )
2005-04-16 15:20:36 -07:00
2007-05-02 19:27:05 +02:00
ENTRY( _ _ p u t _ u s e r _ 4 )
2005-04-16 15:20:36 -07:00
ENTER
movl T I _ a d d r _ l i m i t ( % e b x ) ,% e b x
subl $ 3 ,% e b x
cmpl % e b x ,% e c x
jae b a d _ p u t _ u s e r
3 : movl % e a x ,( % e c x )
xorl % e a x ,% e a x
EXIT
2007-05-02 19:27:05 +02:00
ENDPROC( _ _ p u t _ u s e r _ 4 )
2005-04-16 15:20:36 -07:00
2007-05-02 19:27:05 +02:00
ENTRY( _ _ p u t _ u s e r _ 8 )
2005-04-16 15:20:36 -07:00
ENTER
movl T I _ a d d r _ l i m i t ( % e b x ) ,% e b x
subl $ 7 ,% e b x
cmpl % e b x ,% e c x
jae b a d _ p u t _ u s e r
4 : movl % e a x ,( % e c x )
5 : movl % e d x ,4 ( % e c x )
xorl % e a x ,% e a x
EXIT
2007-05-02 19:27:05 +02:00
ENDPROC( _ _ p u t _ u s e r _ 8 )
2005-04-16 15:20:36 -07:00
bad_put_user :
2007-05-02 19:27:05 +02:00
CFI_ S T A R T P R O C s i m p l e
CFI_ D E F _ C F A e s p , 2 * 4
CFI_ O F F S E T e i p , - 1 * 4
CFI_ O F F S E T e b x , - 2 * 4
2005-04-16 15:20:36 -07:00
movl $ - 1 4 ,% e a x
EXIT
2007-05-02 19:27:05 +02:00
END( b a d _ p u t _ u s e r )
2005-04-16 15:20:36 -07:00
.section _ _ ex_ t a b l e ," a "
.long 1 b,b a d _ p u t _ u s e r
.long 2 b,b a d _ p u t _ u s e r
.long 3 b,b a d _ p u t _ u s e r
.long 4 b,b a d _ p u t _ u s e r
.long 5 b,b a d _ p u t _ u s e r
.previous