2005-04-16 15:20:36 -07:00
/ *
* _ _ get_ u s e r f u n c t i o n s .
*
* ( C) C o p y r i g h t 1 9 9 8 L i n u s T o r v a l d s
* ( C) C o p y r i g h t 2 0 0 5 A n d i K l e e n
2008-06-24 12:05:11 -03:00
* ( C) C o p y r i g h t 2 0 0 8 G l a u b e r C o s t a
2005-04-16 15:20:36 -07:00
*
* 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 .
* /
/ *
* _ _ get_ u s e r _ X
*
2008-06-24 12:05:11 -03:00
* Inputs : % [ r| e ] a x c o n t a i n s t h e a d d r e s s .
2005-04-16 15:20:36 -07:00
* The r e g i s t e r i s m o d i f i e d , b u t a l l c h a n g e s a r e u n d o n e
* before r e t u r n i n g b e c a u s e t h e C c o d e d o e s n ' t k n o w a b o u t i t .
*
2008-06-24 12:05:11 -03:00
* Outputs : % [ r| e ] a x i s e r r o r c o d e ( 0 o r - E F A U L T )
* % [ r| e ] d x c o n t a i n s z e r o - e x t e n d e d v a l u e
*
2005-04-16 15:20:36 -07:00
*
* 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 .
* /
# include < l i n u x / l i n k a g e . h >
2006-09-26 10:52:32 +02:00
# include < a s m / d w a r f2 . h >
2009-02-13 11:14:01 -08:00
# include < a s m / p a g e _ t y p e s . h >
2005-04-16 15:20:36 -07:00
# include < a s m / e r r n o . h >
2005-09-09 21:28:48 +02:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-16 15:20:36 -07:00
# include < a s m / t h r e a d _ i n f o . h >
2008-06-24 11:37:57 -03:00
# include < a s m / a s m . h >
2005-04-16 15:20:36 -07:00
.text
2006-09-26 10:52:32 +02:00
ENTRY( _ _ g e t _ u s e r _ 1 )
CFI_ S T A R T P R O C
2008-06-24 11:37:57 -03:00
GET_ T H R E A D _ I N F O ( % _ A S M _ D X )
cmp T I _ a d d r _ l i m i t ( % _ A S M _ D X ) ,% _ A S M _ A X
2005-04-16 15:20:36 -07:00
jae b a d _ g e t _ u s e r
2008-06-24 11:37:57 -03:00
1 : movzb ( % _ A S M _ A X ) ,% e d x
2008-06-24 11:21:53 -03:00
xor % e a x ,% e a x
2005-04-16 15:20:36 -07:00
ret
2006-09-26 10:52:32 +02:00
CFI_ E N D P R O C
ENDPROC( _ _ g e t _ u s e r _ 1 )
2005-04-16 15:20:36 -07:00
2006-09-26 10:52:32 +02:00
ENTRY( _ _ g e t _ u s e r _ 2 )
CFI_ S T A R T P R O C
2008-06-24 11:37:57 -03:00
add $ 1 ,% _ A S M _ A X
2008-06-24 11:13:16 -03:00
jc b a d _ g e t _ u s e r
2008-06-24 11:37:57 -03:00
GET_ T H R E A D _ I N F O ( % _ A S M _ D X )
cmp T I _ a d d r _ l i m i t ( % _ A S M _ D X ) ,% _ A S M _ A X
2008-06-24 11:13:16 -03:00
jae b a d _ g e t _ u s e r
2008-06-24 11:37:57 -03:00
2 : movzwl - 1 ( % _ A S M _ A X ) ,% e d x
2008-06-24 11:21:53 -03:00
xor % e a x ,% e a x
2005-04-16 15:20:36 -07:00
ret
2006-09-26 10:52:32 +02:00
CFI_ E N D P R O C
ENDPROC( _ _ g e t _ u s e r _ 2 )
2005-04-16 15:20:36 -07:00
2006-09-26 10:52:32 +02:00
ENTRY( _ _ g e t _ u s e r _ 4 )
CFI_ S T A R T P R O C
2008-06-24 11:37:57 -03:00
add $ 3 ,% _ A S M _ A X
2008-06-24 11:13:16 -03:00
jc b a d _ g e t _ u s e r
2008-06-24 11:37:57 -03:00
GET_ T H R E A D _ I N F O ( % _ A S M _ D X )
cmp T I _ a d d r _ l i m i t ( % _ A S M _ D X ) ,% _ A S M _ A X
2008-06-24 11:13:16 -03:00
jae b a d _ g e t _ u s e r
2008-06-24 11:37:57 -03:00
3 : mov - 3 ( % _ A S M _ A X ) ,% e d x
2008-06-24 11:21:53 -03:00
xor % e a x ,% e a x
2005-04-16 15:20:36 -07:00
ret
2006-09-26 10:52:32 +02:00
CFI_ E N D P R O C
ENDPROC( _ _ g e t _ u s e r _ 4 )
2005-04-16 15:20:36 -07:00
2008-06-24 12:05:11 -03:00
# ifdef C O N F I G _ X 8 6 _ 6 4
2006-09-26 10:52:32 +02:00
ENTRY( _ _ g e t _ u s e r _ 8 )
CFI_ S T A R T P R O C
2008-06-24 11:37:57 -03:00
add $ 7 ,% _ A S M _ A X
2008-06-24 11:13:16 -03:00
jc b a d _ g e t _ u s e r
2008-06-24 11:37:57 -03:00
GET_ T H R E A D _ I N F O ( % _ A S M _ D X )
cmp T I _ a d d r _ l i m i t ( % _ A S M _ D X ) ,% _ A S M _ A X
2008-06-24 11:13:16 -03:00
jae b a d _ g e t _ u s e r
2008-06-24 11:37:57 -03:00
4 : movq - 7 ( % _ A S M _ A X ) ,% _ A S M _ D X
2008-06-24 11:21:53 -03:00
xor % e a x ,% e a x
2005-04-16 15:20:36 -07:00
ret
2006-09-26 10:52:32 +02:00
CFI_ E N D P R O C
ENDPROC( _ _ g e t _ u s e r _ 8 )
2008-06-24 12:05:11 -03:00
# endif
2005-04-16 15:20:36 -07:00
bad_get_user :
2006-09-26 10:52:32 +02:00
CFI_ S T A R T P R O C
2008-06-24 11:21:53 -03:00
xor % e d x ,% e d x
2008-06-24 11:37:57 -03:00
mov $ ( - E F A U L T ) ,% _ A S M _ A X
2005-04-16 15:20:36 -07:00
ret
2006-09-26 10:52:32 +02:00
CFI_ E N D P R O C
END( b a d _ g e t _ u s e r )
2005-04-16 15:20:36 -07:00
.section _ _ ex_ t a b l e ," a "
2008-06-24 12:02:44 -03:00
_ ASM_ P T R 1 b ,b a d _ g e t _ u s e r
_ ASM_ P T R 2 b ,b a d _ g e t _ u s e r
_ ASM_ P T R 3 b ,b a d _ g e t _ u s e r
2008-06-24 12:05:11 -03:00
# ifdef C O N F I G _ X 8 6 _ 6 4
2008-06-24 12:02:44 -03:00
_ ASM_ P T R 4 b ,b a d _ g e t _ u s e r
2008-06-24 12:05:11 -03:00
# endif