2005-06-23 11:09:28 +04:00
/ *
* Jprobe s p e c i f i c o p e r a t i o n s
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e a s p u b l i s h e d b y
* the F r e e S o f t w a r e F o u n d a t i o n ; either version 2 of the License, or
* ( at y o u r o p t i o n ) a n y l a t e r v e r s i o n .
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l ,
* but W I T H O U T A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY o r F I T N E S S F O R A P A R T I C U L A R P U R P O S E . S e e t h e
* GNU G e n e r a l P u b l i c L i c e n s e f o r m o r e d e t a i l s .
*
* You s h o u l d h a v e r e c e i v e d a c o p y o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* along w i t h t h i s p r o g r a m ; if not, write to the Free Software
* Foundation, I n c . , 5 9 T e m p l e P l a c e - S u i t e 3 3 0 , B o s t o n , M A 0 2 1 1 1 - 1 3 0 7 , U S A .
*
* Copyright ( C ) I n t e l C o r p o r a t i o n , 2 0 0 5
*
* 2 0 0 5 - May R u s t y L y n c h < r u s t y . l y n c h @intel.com> and Anil S Keshavamurthy
* < anil. s . k e s h a v a m u r t h y @intel.com> initial implementation
*
* Jprobes ( a . k . a . " j u m p p r o b e s " w h i c h i s b u i l t o n - t o p o f k p r o b e s ) a l l o w a
* probe t o b e i n s e r t e d i n t o t h e b e g i n n i n g o f a f u n c t i o n c a l l . T h e f u n d a m e n t a l
* difference b e t w e e n a j p r o b e a n d a k p r o b e i s t h e j p r o b e h a n d l e r i s e x e c u t e d
* in t h e s a m e c o n t e x t a s t h e t a r g e t f u n c t i o n , w h i l e t h e k p r o b e h a n d l e r s
* are e x e c u t e d i n i n t e r r u p t c o n t e x t .
*
* For j p r o b e s w e i n i t i a l l y g a i n c o n t r o l b y p l a c i n g a b r e a k p o i n t i n t h e
* first i n s t r u c t i o n o f t h e t a r g e t e d f u n c t i o n . W h e n w e c a t c h t h a t s p e c i f i c
* break, w e :
* * set t h e r e t u r n a d d r e s s t o o u r j p r o b e _ i n s t _ r e t u r n ( ) f u n c t i o n
* * jump t o t h e j p r o b e h a n d l e r f u n c t i o n
*
* Since w e f i x e d u p t h e r e t u r n a d d r e s s , t h e j p r o b e h a n d l e r w i l l r e t u r n t o o u r
* jprobe_ i n s t _ r e t u r n ( ) f u n c t i o n , g i v i n g u s c o n t r o l a g a i n . A t t h i s p o i n t w e
* are b a c k i n t h e p a r e n t s f r a m e m a r k e r , s o w e d o y e t a n o t h e r c a l l t o o u r
* jprobe_ b r e a k ( ) f u n c t i o n t o f i x u p t h e f r a m e m a r k e r a s i t w o u l d n o r m a l l y
* exist i n t h e t a r g e t f u n c t i o n .
*
* Our j p r o b e _ r e t u r n f u n c t i o n t h e n t r a n s f e r s c o n t r o l b a c k t o k p r o b e s . c b y
* executing a b r e a k i n s t r u c t i o n u s i n g o n e o f o u r r e s e r v e d n u m b e r s . W h e n w e
* catch t h a t b r e a k i n k p r o b e s . c , w e c o n t i n u e l i k e w e d o f o r a n o r m a l k p r o b e
* by s i n g l e s t e p p i n g t h e e m u l a t e d i n s t r u c t i o n , a n d t h e n r e t u r n i n g e x e c u t i o n
* to t h e c o r r e c t l o c a t i o n .
* /
# include < a s m / a s m m a c r o . h >
2008-08-01 21:13:32 +04:00
# include < a s m / b r e a k . h >
2005-06-23 11:09:28 +04:00
/ *
* void j p r o b e _ b r e a k ( v o i d )
* /
2005-09-07 02:19:30 +04:00
.section .kprobes .text , " ax"
2005-06-23 11:09:28 +04:00
ENTRY( j p r o b e _ b r e a k )
2006-11-14 20:33:38 +03:00
break. m _ _ I A 6 4 _ B R E A K _ J P R O B E
2005-06-23 11:09:28 +04:00
END( j p r o b e _ b r e a k )
/ *
* void j p r o b e _ i n s t _ r e t u r n ( v o i d )
* /
GLOBAL_ E N T R Y ( j p r o b e _ i n s t _ r e t u r n )
br. c a l l . s p t k . m a n y b0 =jprobe_break
END( j p r o b e _ i n s t _ r e t u r n )
2006-01-14 01:45:21 +03:00
GLOBAL_ E N T R Y ( i n v a l i d a t e _ s t a c k e d _ r e g s )
movl r16 =invalidate_restore_cfm
;;
mov b6 =r16
;;
br. r e t . s p t k . m a n y b6
;;
invalidate_restore_cfm :
mov r16 =ar . r s c
;;
mov a r . r s c =r0
;;
loadrs
;;
mov a r . r s c =r16
;;
br. c o n d . s p t k . m a n y r p
END( i n v a l i d a t e _ s t a c k e d _ r e g s )
GLOBAL_ E N T R Y ( f l u s h _ r e g i s t e r _ s t a c k )
/ / flush d i r t y r e g s t o b a c k i n g s t o r e ( m u s t b e f i r s t i n i n s n g r o u p )
flushrs
;;
br. r e t . s p t k . m a n y r p
END( f l u s h _ r e g i s t e r _ s t a c k )