Blame view

arch/ia64/kernel/jprobes.S 2.94 KB
b2761dc26   Anil S Keshavamurthy   [PATCH] Kprobes/I...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  /*
   * Jprobe specific operations
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   *
   * Copyright (C) Intel Corporation, 2005
   *
   * 2005-May     Rusty Lynch <rusty.lynch@intel.com> and Anil S Keshavamurthy
   *              <anil.s.keshavamurthy@intel.com> initial implementation
   *
   * Jprobes (a.k.a. "jump probes" which is built on-top of kprobes) allow a
   * probe to be inserted into the beginning of a function call.  The fundamental
   * difference between a jprobe and a kprobe is the jprobe handler is executed
   * in the same context as the target function, while the kprobe handlers
   * are executed in interrupt context.
   *
   * For jprobes we initially gain control by placing a break point in the
   * first instruction of the targeted function.  When we catch that specific
   * break, we:
   *        * set the return address to our jprobe_inst_return() function
   *        * jump to the jprobe handler function
   *
   * Since we fixed up the return address, the jprobe handler will return to our
   * jprobe_inst_return() function, giving us control again.  At this point we
   * are back in the parents frame marker, so we do yet another call to our
   * jprobe_break() function to fix up the frame marker as it would normally
   * exist in the target function.
   *
   * Our jprobe_return function then transfers control back to kprobes.c by
   * executing a break instruction using one of our reserved numbers.  When we
   * catch that break in kprobes.c, we continue like we do for a normal kprobe
   * by single stepping the emulated instruction, and then returning execution
   * to the correct location.
   */
  #include <asm/asmmacro.h>
7f30491cc   Tony Luck   [IA64] Move inclu...
48
  #include <asm/break.h>
b2761dc26   Anil S Keshavamurthy   [PATCH] Kprobes/I...
49
50
51
52
  
  	/*
  	 * void jprobe_break(void)
  	 */
1f7ad57b7   Prasanna S Panchamukhi   [PATCH] Kprobes: ...
53
  	.section .kprobes.text, "ax"
b2761dc26   Anil S Keshavamurthy   [PATCH] Kprobes/I...
54
  ENTRY(jprobe_break)
08ed38b68   Tony Luck   [IA64] enable tra...
55
  	break.m __IA64_BREAK_JPROBE
b2761dc26   Anil S Keshavamurthy   [PATCH] Kprobes/I...
56
57
58
59
60
61
62
63
  END(jprobe_break)
  
  	/*
  	 * void jprobe_inst_return(void)
  	 */
  GLOBAL_ENTRY(jprobe_inst_return)
  	br.call.sptk.many b0=jprobe_break
  END(jprobe_inst_return)
d3ef1f5aa   Zhang Yanmin   [IA64] prevent ac...
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
  
  GLOBAL_ENTRY(invalidate_stacked_regs)
  	movl r16=invalidate_restore_cfm
  	;;
  	mov b6=r16
  	;;
  	br.ret.sptk.many b6
  	;;
  invalidate_restore_cfm:
  	mov r16=ar.rsc
  	;;
  	mov ar.rsc=r0
  	;;
  	loadrs
  	;;
  	mov ar.rsc=r16
  	;;
  	br.cond.sptk.many rp
  END(invalidate_stacked_regs)
  
  GLOBAL_ENTRY(flush_register_stack)
  	// flush dirty regs to backing store (must be first in insn group)
  	flushrs
  	;;
  	br.ret.sptk.many rp
  END(flush_register_stack)