2005-04-17 02:20:36 +04: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
*
* 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
*
* Inputs : % rcx c o n t a i n s t h e a d d r e s s .
* 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 .
*
* Outputs : % rax i s e r r o r c o d e ( 0 o r - E F A U L T )
* % rdx 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
*
* % r8 i s d e s t r o y e d .
*
* 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 >
# include < a s m / p a g e . h >
# include < a s m / e r r n o . h >
# include < a s m / o f f s e t . h >
# include < a s m / t h r e a d _ i n f o . h >
.text
.p2align 4
.globl __get_user_1
__get_user_1 :
GET_ T H R E A D _ I N F O ( % r8 )
cmpq t h r e a d i n f o _ a d d r _ l i m i t ( % r8 ) ,% r c x
jae b a d _ g e t _ u s e r
1 : movzb ( % r c x ) ,% e d x
xorl % e a x ,% e a x
ret
.p2align 4
.globl __get_user_2
__get_user_2 :
GET_ T H R E A D _ I N F O ( % r8 )
addq $ 1 ,% r c x
jc 2 0 f
cmpq t h r e a d i n f o _ a d d r _ l i m i t ( % r8 ) ,% r c x
jae 2 0 f
decq % r c x
2 : movzwl ( % r c x ) ,% e d x
xorl % e a x ,% e a x
ret
20 : decq % r c x
jmp b a d _ g e t _ u s e r
.p2align 4
.globl __get_user_4
__get_user_4 :
GET_ T H R E A D _ I N F O ( % r8 )
addq $ 3 ,% r c x
jc 3 0 f
cmpq t h r e a d i n f o _ a d d r _ l i m i t ( % r8 ) ,% r c x
jae 3 0 f
subq $ 3 ,% r c x
3 : movl ( % r c x ) ,% e d x
xorl % e a x ,% e a x
ret
30 : subq $ 3 ,% r c x
jmp b a d _ g e t _ u s e r
.p2align 4
.globl __get_user_8
__get_user_8 :
GET_ T H R E A D _ I N F O ( % r8 )
addq $ 7 ,% r c x
2005-04-21 18:59:51 +04:00
jc 4 0 f
2005-04-17 02:20:36 +04:00
cmpq t h r e a d i n f o _ a d d r _ l i m i t ( % r8 ) ,% r c x
2005-04-21 18:59:51 +04:00
jae 4 0 f
2005-04-17 02:20:36 +04:00
subq $ 7 ,% r c x
4 : movq ( % r c x ) ,% r d x
xorl % e a x ,% e a x
ret
40 : subq $ 7 ,% r c x
jmp b a d _ g e t _ u s e r
bad_get_user :
xorl % e d x ,% e d x
movq $ ( - E F A U L T ) ,% r a x
ret
.section _ _ ex_ t a b l e ," a "
.quad 1 b,b a d _ g e t _ u s e r
.quad 2 b,b a d _ g e t _ u s e r
.quad 3 b,b a d _ g e t _ u s e r
.quad 4 b,b a d _ g e t _ u s e r
.previous