2009-08-31 09:50:09 +02:00
# include < l i n u x / l i n k a g e . h >
# include < l i n u x / e r r n o . h >
2009-08-31 13:59:53 -07:00
# include < a s m / d w a r f2 . h >
2009-08-31 09:50:09 +02:00
# include < a s m / a s m . h >
# include < a s m / m s r . h >
# ifdef C O N F I G _ X 8 6 _ 6 4
/ *
* int n a t i v e _ { r d m s r ,w r m s r } _ s a f e _ r e g s ( u 3 2 g p r s [ 8 ] ) ;
*
* reg l a y o u t : u 3 2 g p r s [ e a x , e c x , e d x , e b x , e s p , e b p , e s i , e d i ]
*
* /
2009-09-01 13:31:52 -07:00
.macro op_safe_regs op
2009-08-31 09:50:09 +02:00
ENTRY( n a t i v e _ \ o p \ ( ) _ s a f e _ r e g s )
2009-08-31 13:59:53 -07:00
CFI_ S T A R T P R O C
pushq_ c f i % r b x
pushq_ c f i % r b p
movq % r d i , % r10 / * S a v e p o i n t e r * /
xorl % r11 d , % r11 d / * R e t u r n v a l u e * /
2009-08-31 09:50:09 +02:00
movl ( % r d i ) , % e a x
movl 4 ( % r d i ) , % e c x
movl 8 ( % r d i ) , % e d x
movl 1 2 ( % r d i ) , % e b x
movl 2 0 ( % r d i ) , % e b p
movl 2 4 ( % r d i ) , % e s i
movl 2 8 ( % r d i ) , % e d i
2009-08-31 13:59:53 -07:00
CFI_ R E M E M B E R _ S T A T E
2009-08-31 09:50:09 +02:00
1 : \ op
2009-08-31 13:59:53 -07:00
2 : movl % e a x , ( % r10 )
movl % r11 d , % e a x / * R e t u r n v a l u e * /
movl % e c x , 4 ( % r10 )
movl % e d x , 8 ( % r10 )
movl % e b x , 1 2 ( % r10 )
movl % e b p , 2 0 ( % r10 )
movl % e s i , 2 4 ( % r10 )
movl % e d i , 2 8 ( % r10 )
popq_ c f i % r b p
popq_ c f i % r b x
2009-08-31 09:50:09 +02:00
ret
3 :
2009-08-31 13:59:53 -07:00
CFI_ R E S T O R E _ S T A T E
movl $ - E I O , % r11 d
2009-08-31 09:50:09 +02:00
jmp 2 b
2009-08-31 13:59:53 -07:00
_ ASM_ E X T A B L E ( 1 b , 3 b )
CFI_ E N D P R O C
2009-08-31 09:50:09 +02:00
ENDPROC( n a t i v e _ \ o p \ ( ) _ s a f e _ r e g s )
.endm
# else / * X 8 6 _ 3 2 * /
2009-09-03 21:26:34 +02:00
.macro op_safe_regs op
2009-08-31 09:50:09 +02:00
ENTRY( n a t i v e _ \ o p \ ( ) _ s a f e _ r e g s )
2009-08-31 13:59:53 -07:00
CFI_ S T A R T P R O C
pushl_ c f i % e b x
pushl_ c f i % e b p
pushl_ c f i % e s i
pushl_ c f i % e d i
pushl_ c f i $ 0 / * R e t u r n v a l u e * /
pushl_ c f i % e a x
2009-08-31 09:50:09 +02:00
movl 4 ( % e a x ) , % e c x
movl 8 ( % e a x ) , % e d x
movl 1 2 ( % e a x ) , % e b x
movl 2 0 ( % e a x ) , % e b p
movl 2 4 ( % e a x ) , % e s i
movl 2 8 ( % e a x ) , % e d i
movl ( % e a x ) , % e a x
2009-08-31 13:59:53 -07:00
CFI_ R E M E M B E R _ S T A T E
2009-08-31 09:50:09 +02:00
1 : \ op
2009-08-31 13:59:53 -07:00
2 : pushl_ c f i % e a x
2009-08-31 09:50:09 +02:00
movl 4 ( % e s p ) , % e a x
2009-08-31 13:59:53 -07:00
popl_ c f i ( % e a x )
2009-08-31 09:50:09 +02:00
addl $ 4 , % e s p
2009-08-31 13:59:53 -07:00
CFI_ A D J U S T _ C F A _ O F F S E T - 4
2009-08-31 09:50:09 +02:00
movl % e c x , 4 ( % e a x )
movl % e d x , 8 ( % e a x )
movl % e b x , 1 2 ( % e a x )
movl % e b p , 2 0 ( % e a x )
movl % e s i , 2 4 ( % e a x )
movl % e d i , 2 8 ( % e a x )
2009-08-31 13:59:53 -07:00
popl_ c f i % e a x
popl_ c f i % e d i
popl_ c f i % e s i
popl_ c f i % e b p
popl_ c f i % e b x
2009-08-31 09:50:09 +02:00
ret
3 :
2009-08-31 13:59:53 -07:00
CFI_ R E S T O R E _ S T A T E
2009-08-31 09:50:09 +02:00
movl $ - E I O , 4 ( % e s p )
jmp 2 b
2009-08-31 13:59:53 -07:00
_ ASM_ E X T A B L E ( 1 b , 3 b )
CFI_ E N D P R O C
2009-08-31 09:50:09 +02:00
ENDPROC( n a t i v e _ \ o p \ ( ) _ s a f e _ r e g s )
.endm
# endif
op_ s a f e _ r e g s r d m s r
op_ s a f e _ r e g s w r m s r