| Anil S Keshavamurthy | b2761dc | 2005-06-23 00:09:28 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Jprobe specific operations | 
|  | 3 | * | 
|  | 4 | * This program is free software; you can redistribute it and/or modify | 
|  | 5 | * it under the terms of the GNU General Public License as published by | 
|  | 6 | * the Free Software Foundation; either version 2 of the License, or | 
|  | 7 | * (at your option) any later version. | 
|  | 8 | * | 
|  | 9 | * This program is distributed in the hope that it will be useful, | 
|  | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 12 | * GNU General Public License for more details. | 
|  | 13 | * | 
|  | 14 | * You should have received a copy of the GNU General Public License | 
|  | 15 | * along with this program; if not, write to the Free Software | 
|  | 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 
|  | 17 | * | 
|  | 18 | * Copyright (C) Intel Corporation, 2005 | 
|  | 19 | * | 
|  | 20 | * 2005-May     Rusty Lynch <rusty.lynch@intel.com> and Anil S Keshavamurthy | 
|  | 21 | *              <anil.s.keshavamurthy@intel.com> initial implementation | 
|  | 22 | * | 
|  | 23 | * Jprobes (a.k.a. "jump probes" which is built on-top of kprobes) allow a | 
|  | 24 | * probe to be inserted into the beginning of a function call.  The fundamental | 
|  | 25 | * difference between a jprobe and a kprobe is the jprobe handler is executed | 
|  | 26 | * in the same context as the target function, while the kprobe handlers | 
|  | 27 | * are executed in interrupt context. | 
|  | 28 | * | 
|  | 29 | * For jprobes we initially gain control by placing a break point in the | 
|  | 30 | * first instruction of the targeted function.  When we catch that specific | 
|  | 31 | * break, we: | 
|  | 32 | *        * set the return address to our jprobe_inst_return() function | 
|  | 33 | *        * jump to the jprobe handler function | 
|  | 34 | * | 
|  | 35 | * Since we fixed up the return address, the jprobe handler will return to our | 
|  | 36 | * jprobe_inst_return() function, giving us control again.  At this point we | 
|  | 37 | * are back in the parents frame marker, so we do yet another call to our | 
|  | 38 | * jprobe_break() function to fix up the frame marker as it would normally | 
|  | 39 | * exist in the target function. | 
|  | 40 | * | 
|  | 41 | * Our jprobe_return function then transfers control back to kprobes.c by | 
|  | 42 | * executing a break instruction using one of our reserved numbers.  When we | 
|  | 43 | * catch that break in kprobes.c, we continue like we do for a normal kprobe | 
|  | 44 | * by single stepping the emulated instruction, and then returning execution | 
|  | 45 | * to the correct location. | 
|  | 46 | */ | 
|  | 47 | #include <asm/asmmacro.h> | 
|  | 48 |  | 
|  | 49 | /* | 
|  | 50 | * void jprobe_break(void) | 
|  | 51 | */ | 
| Prasanna S Panchamukhi | 1f7ad57 | 2005-09-06 15:19:30 -0700 | [diff] [blame] | 52 | .section .kprobes.text, "ax" | 
| Anil S Keshavamurthy | b2761dc | 2005-06-23 00:09:28 -0700 | [diff] [blame] | 53 | ENTRY(jprobe_break) | 
|  | 54 | break.m 0x80300 | 
|  | 55 | END(jprobe_break) | 
|  | 56 |  | 
|  | 57 | /* | 
|  | 58 | * void jprobe_inst_return(void) | 
|  | 59 | */ | 
|  | 60 | GLOBAL_ENTRY(jprobe_inst_return) | 
|  | 61 | br.call.sptk.many b0=jprobe_break | 
|  | 62 | END(jprobe_inst_return) |