2006-09-26 10:52:29 +02:00
/ *
* Save r e g i s t e r s b e f o r e c a l l i n g a s s e m b l y f u n c t i o n s . T h i s a v o i d s
* disturbance o f r e g i s t e r a l l o c a t i o n i n s o m e i n l i n e a s s e m b l y c o n s t r u c t s .
* Copyright 2 0 0 1 ,2 0 0 2 b y A n d i K l e e n , S u S E L a b s .
2008-05-12 21:20:42 +02:00
* Added t r a c e _ h a r d i r q s c a l l e r s - C o p y r i g h t 2 0 0 7 S t e v e n R o s t e d t , R e d H a t , I n c .
2006-09-26 10:52:29 +02:00
* Subject t o t h e G N U p u b l i c l i c e n s e , v . 2 . N o w a r r a n t y o f a n y k i n d .
* /
2005-04-16 15:20:36 -07: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 >
# include < a s m / c a l l i n g . h >
# include < a s m / r w l o c k . h >
/* rdi: arg1 ... normal C conventions. rax is saved/restored. */
.macro thunk name,f u n c
.globl \ name
\ name :
CFI_ S T A R T P R O C
SAVE_ A R G S
call \ f u n c
jmp r e s t o r e
CFI_ E N D P R O C
.endm
/* rdi: arg1 ... normal C conventions. rax is passed from C. */
.macro thunk_retrax name,f u n c
.globl \ name
\ name :
CFI_ S T A R T P R O C
SAVE_ A R G S
call \ f u n c
jmp r e s t o r e _ n o r a x
CFI_ E N D P R O C
.endm
2008-01-30 13:33:37 +01:00
.section .sched .text , " ax"
2005-04-16 15:20:36 -07:00
# ifdef C O N F I G _ R W S E M _ X C H G A D D _ A L G O R I T H M
thunk r w s e m _ d o w n _ r e a d _ f a i l e d _ t h u n k ,r w s e m _ d o w n _ r e a d _ f a i l e d
thunk r w s e m _ d o w n _ w r i t e _ f a i l e d _ t h u n k ,r w s e m _ d o w n _ w r i t e _ f a i l e d
thunk r w s e m _ w a k e _ t h u n k ,r w s e m _ w a k e
thunk r w s e m _ d o w n g r a d e _ t h u n k ,r w s e m _ d o w n g r a d e _ w a k e
# endif
2006-07-03 00:24:45 -07:00
# ifdef C O N F I G _ T R A C E _ I R Q F L A G S
2008-05-12 21:20:42 +02:00
/* put return address in rdi (arg1) */
.macro thunk_ra name,f u n c
.globl \ name
\ name :
CFI_ S T A R T P R O C
SAVE_ A R G S
/* SAVE_ARGS pushs 9 elements */
/* the next element would be the rip */
movq 9 * 8 ( % r s p ) , % r d i
call \ f u n c
jmp r e s t o r e
CFI_ E N D P R O C
.endm
thunk_ r a t r a c e _ h a r d i r q s _ o n _ t h u n k ,t r a c e _ h a r d i r q s _ o n _ c a l l e r
thunk_ r a t r a c e _ h a r d i r q s _ o f f _ t h u n k ,t r a c e _ h a r d i r q s _ o f f _ c a l l e r
2006-07-03 00:24:45 -07:00
# endif
2007-10-11 22:11:12 +02:00
# ifdef C O N F I G _ D E B U G _ L O C K _ A L L O C
thunk l o c k d e p _ s y s _ e x i t _ t h u n k ,l o c k d e p _ s y s _ e x i t
# endif
2005-04-16 15:20:36 -07:00
/* SAVE_ARGS below is used only for the .cfi directives it contains. */
CFI_ S T A R T P R O C
SAVE_ A R G S
restore :
RESTORE_ A R G S
ret
CFI_ E N D P R O C
CFI_ S T A R T P R O C
SAVE_ A R G S
restore_norax :
RESTORE_ A R G S 1
ret
CFI_ E N D P R O C