This source file includes following definitions.
- kprobe_ftrace_handler
- arch_prepare_kprobe_ftrace
1
2
3
4
5
6
7 #include <linux/kprobes.h>
8 #include <linux/ptrace.h>
9 #include <linux/hardirq.h>
10 #include <linux/preempt.h>
11 #include <linux/ftrace.h>
12
13 #include "common.h"
14
15
16 void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
17 struct ftrace_ops *ops, struct pt_regs *regs)
18 {
19 struct kprobe *p;
20 struct kprobe_ctlblk *kcb;
21
22
23 p = get_kprobe((kprobe_opcode_t *)ip);
24 if (unlikely(!p) || kprobe_disabled(p))
25 return;
26
27 kcb = get_kprobe_ctlblk();
28 if (kprobe_running()) {
29 kprobes_inc_nmissed_count(p);
30 } else {
31 unsigned long orig_ip = regs->ip;
32
33 regs->ip = ip + sizeof(kprobe_opcode_t);
34
35 __this_cpu_write(current_kprobe, p);
36 kcb->kprobe_status = KPROBE_HIT_ACTIVE;
37 if (!p->pre_handler || !p->pre_handler(p, regs)) {
38
39
40
41
42 regs->ip = (unsigned long)p->addr + MCOUNT_INSN_SIZE;
43 if (unlikely(p->post_handler)) {
44 kcb->kprobe_status = KPROBE_HIT_SSDONE;
45 p->post_handler(p, regs, 0);
46 }
47 regs->ip = orig_ip;
48 }
49
50
51
52
53 __this_cpu_write(current_kprobe, NULL);
54 }
55 }
56 NOKPROBE_SYMBOL(kprobe_ftrace_handler);
57
58 int arch_prepare_kprobe_ftrace(struct kprobe *p)
59 {
60 p->ainsn.insn = NULL;
61 p->ainsn.boostable = false;
62 return 0;
63 }