blob: dd6306c51bd645cb579c20d820197874ece9ad98 [file] [log] [blame]
Michael Grundy4ba069b2006-09-20 15:58:39 +02001/*
2 * Kernel Probes (KProbes)
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 *
Heiko Carstensa53c8fa2012-07-20 11:15:04 +020018 * Copyright IBM Corp. 2002, 2006
Michael Grundy4ba069b2006-09-20 15:58:39 +020019 *
20 * s390 port, used ppc64 as template. Mike Grundy <grundym@us.ibm.com>
21 */
22
Michael Grundy4ba069b2006-09-20 15:58:39 +020023#include <linux/kprobes.h>
24#include <linux/ptrace.h>
25#include <linux/preempt.h>
26#include <linux/stop_machine.h>
Christoph Hellwig1eeb66a2007-05-08 00:27:03 -070027#include <linux/kdebug.h>
Heiko Carstensa2b53672009-06-12 10:26:43 +020028#include <linux/uaccess.h>
Michael Grundy4ba069b2006-09-20 15:58:39 +020029#include <linux/module.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090030#include <linux/slab.h>
Martin Schwidefskyadb45832010-11-10 10:05:57 +010031#include <linux/hardirq.h>
Heiko Carstensc9331462014-10-15 12:17:38 +020032#include <linux/ftrace.h>
Heiko Carstensa882b3b2013-09-13 13:59:26 +020033#include <asm/cacheflush.h>
34#include <asm/sections.h>
35#include <asm/dis.h>
Michael Grundy4ba069b2006-09-20 15:58:39 +020036
Martin Schwidefsky4a188632011-01-05 12:47:24 +010037DEFINE_PER_CPU(struct kprobe *, current_kprobe);
Michael Grundy4ba069b2006-09-20 15:58:39 +020038DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
39
Martin Schwidefsky4a188632011-01-05 12:47:24 +010040struct kretprobe_blackpoint kretprobe_blacklist[] = { };
Masami Hiramatsuf438d912007-10-16 01:27:49 -070041
Heiko Carstens63c40432013-09-11 14:24:14 -070042DEFINE_INSN_CACHE_OPS(dmainsn);
43
44static void *alloc_dmainsn_page(void)
45{
46 return (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
47}
48
49static void free_dmainsn_page(void *page)
50{
51 free_page((unsigned long)page);
52}
53
54struct kprobe_insn_cache kprobe_dmainsn_slots = {
55 .mutex = __MUTEX_INITIALIZER(kprobe_dmainsn_slots.mutex),
56 .alloc = alloc_dmainsn_page,
57 .free = free_dmainsn_page,
58 .pages = LIST_HEAD_INIT(kprobe_dmainsn_slots.pages),
59 .insn_size = MAX_INSN_SIZE,
60};
61
Heiko Carstens7a5388d2014-10-22 12:42:38 +020062static void copy_instruction(struct kprobe *p)
Heiko Carstens63c40432013-09-11 14:24:14 -070063{
Heiko Carstensc9331462014-10-15 12:17:38 +020064 unsigned long ip = (unsigned long) p->addr;
Heiko Carstens63c40432013-09-11 14:24:14 -070065 s64 disp, new_disp;
66 u64 addr, new_addr;
67
Heiko Carstensc9331462014-10-15 12:17:38 +020068 if (ftrace_location(ip) == ip) {
69 /*
70 * If kprobes patches the instruction that is morphed by
71 * ftrace make sure that kprobes always sees the branch
Heiko Carstense6d60b32015-01-09 13:08:28 +010072 * "jg .+24" that skips the mcount block or the "brcl 0,0"
73 * in case of hotpatch.
Heiko Carstensc9331462014-10-15 12:17:38 +020074 */
75 ftrace_generate_nop_insn((struct ftrace_insn *)p->ainsn.insn);
76 p->ainsn.is_ftrace_insn = 1;
77 } else
Heiko Carstensed7d56e2014-11-28 12:36:48 +010078 memcpy(p->ainsn.insn, p->addr, insn_length(*p->addr >> 8));
Heiko Carstensc9331462014-10-15 12:17:38 +020079 p->opcode = p->ainsn.insn[0];
Jan Willeke975fab12014-09-22 16:37:27 +020080 if (!probe_is_insn_relative_long(p->ainsn.insn))
Heiko Carstens63c40432013-09-11 14:24:14 -070081 return;
82 /*
83 * For pc-relative instructions in RIL-b or RIL-c format patch the
84 * RI2 displacement field. We have already made sure that the insn
85 * slot for the patched instruction is within the same 2GB area
86 * as the original instruction (either kernel image or module area).
87 * Therefore the new displacement will always fit.
88 */
89 disp = *(s32 *)&p->ainsn.insn[1];
90 addr = (u64)(unsigned long)p->addr;
91 new_addr = (u64)(unsigned long)p->ainsn.insn;
92 new_disp = ((addr + (disp * 2)) - new_addr) / 2;
93 *(s32 *)&p->ainsn.insn[1] = new_disp;
94}
Heiko Carstens7a5388d2014-10-22 12:42:38 +020095NOKPROBE_SYMBOL(copy_instruction);
Heiko Carstens63c40432013-09-11 14:24:14 -070096
97static inline int is_kernel_addr(void *addr)
98{
99 return addr < (void *)_end;
100}
101
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200102static int s390_get_insn_slot(struct kprobe *p)
Heiko Carstens63c40432013-09-11 14:24:14 -0700103{
104 /*
105 * Get an insn slot that is within the same 2GB area like the original
106 * instruction. That way instructions with a 32bit signed displacement
107 * field can be patched and executed within the insn slot.
108 */
109 p->ainsn.insn = NULL;
110 if (is_kernel_addr(p->addr))
111 p->ainsn.insn = get_dmainsn_slot();
Heiko Carstensfcd05b52013-09-02 10:31:11 +0200112 else if (is_module_addr(p->addr))
Heiko Carstens63c40432013-09-11 14:24:14 -0700113 p->ainsn.insn = get_insn_slot();
114 return p->ainsn.insn ? 0 : -ENOMEM;
115}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200116NOKPROBE_SYMBOL(s390_get_insn_slot);
Heiko Carstens63c40432013-09-11 14:24:14 -0700117
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200118static void s390_free_insn_slot(struct kprobe *p)
Heiko Carstens63c40432013-09-11 14:24:14 -0700119{
120 if (!p->ainsn.insn)
121 return;
122 if (is_kernel_addr(p->addr))
123 free_dmainsn_slot(p->ainsn.insn, 0);
124 else
125 free_insn_slot(p->ainsn.insn, 0);
126 p->ainsn.insn = NULL;
127}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200128NOKPROBE_SYMBOL(s390_free_insn_slot);
Heiko Carstens63c40432013-09-11 14:24:14 -0700129
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200130int arch_prepare_kprobe(struct kprobe *p)
Martin Schwidefskyba640a52011-01-05 12:47:19 +0100131{
132 if ((unsigned long) p->addr & 0x01)
133 return -EINVAL;
Martin Schwidefskyba640a52011-01-05 12:47:19 +0100134 /* Make sure the probe isn't going on a difficult instruction */
Jan Willeke975fab12014-09-22 16:37:27 +0200135 if (probe_is_prohibited_opcode(p->addr))
Martin Schwidefskyba640a52011-01-05 12:47:19 +0100136 return -EINVAL;
Heiko Carstens63c40432013-09-11 14:24:14 -0700137 if (s390_get_insn_slot(p))
138 return -ENOMEM;
Heiko Carstens63c40432013-09-11 14:24:14 -0700139 copy_instruction(p);
Martin Schwidefskyba640a52011-01-05 12:47:19 +0100140 return 0;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200141}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200142NOKPROBE_SYMBOL(arch_prepare_kprobe);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200143
Heiko Carstensc9331462014-10-15 12:17:38 +0200144int arch_check_ftrace_location(struct kprobe *p)
145{
146 return 0;
147}
148
149struct swap_insn_args {
150 struct kprobe *p;
151 unsigned int arm_kprobe : 1;
Martin Schwidefsky5a8b5892011-01-05 12:47:18 +0100152};
153
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200154static int swap_instruction(void *data)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200155{
Heiko Carstensacf01802009-06-22 12:08:23 +0200156 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
157 unsigned long status = kcb->kprobe_status;
Heiko Carstensc9331462014-10-15 12:17:38 +0200158 struct swap_insn_args *args = data;
159 struct ftrace_insn new_insn, *insn;
160 struct kprobe *p = args->p;
161 size_t len;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200162
Heiko Carstensc9331462014-10-15 12:17:38 +0200163 new_insn.opc = args->arm_kprobe ? BREAKPOINT_INSTRUCTION : p->opcode;
164 len = sizeof(new_insn.opc);
165 if (!p->ainsn.is_ftrace_insn)
166 goto skip_ftrace;
167 len = sizeof(new_insn);
168 insn = (struct ftrace_insn *) p->addr;
169 if (args->arm_kprobe) {
170 if (is_ftrace_nop(insn))
171 new_insn.disp = KPROBE_ON_FTRACE_NOP;
172 else
173 new_insn.disp = KPROBE_ON_FTRACE_CALL;
174 } else {
175 ftrace_generate_call_insn(&new_insn, (unsigned long)p->addr);
176 if (insn->disp == KPROBE_ON_FTRACE_NOP)
177 ftrace_generate_nop_insn(&new_insn);
178 }
179skip_ftrace:
Heiko Carstensacf01802009-06-22 12:08:23 +0200180 kcb->kprobe_status = KPROBE_SWAP_INST;
Heiko Carstens8a5d8472015-03-13 12:55:56 +0100181 s390_kernel_write(p->addr, &new_insn, len);
Heiko Carstensacf01802009-06-22 12:08:23 +0200182 kcb->kprobe_status = status;
Martin Schwidefsky5a8b5892011-01-05 12:47:18 +0100183 return 0;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200184}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200185NOKPROBE_SYMBOL(swap_instruction);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200186
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200187void arch_arm_kprobe(struct kprobe *p)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200188{
Heiko Carstensc9331462014-10-15 12:17:38 +0200189 struct swap_insn_args args = {.p = p, .arm_kprobe = 1};
Michael Grundy4ba069b2006-09-20 15:58:39 +0200190
Rusty Russell9b1a4d32008-07-28 12:16:30 -0500191 stop_machine(swap_instruction, &args, NULL);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200192}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200193NOKPROBE_SYMBOL(arch_arm_kprobe);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200194
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200195void arch_disarm_kprobe(struct kprobe *p)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200196{
Heiko Carstensc9331462014-10-15 12:17:38 +0200197 struct swap_insn_args args = {.p = p, .arm_kprobe = 0};
Michael Grundy4ba069b2006-09-20 15:58:39 +0200198
Rusty Russell9b1a4d32008-07-28 12:16:30 -0500199 stop_machine(swap_instruction, &args, NULL);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200200}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200201NOKPROBE_SYMBOL(arch_disarm_kprobe);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200202
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200203void arch_remove_kprobe(struct kprobe *p)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200204{
Heiko Carstens63c40432013-09-11 14:24:14 -0700205 s390_free_insn_slot(p);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200206}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200207NOKPROBE_SYMBOL(arch_remove_kprobe);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200208
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200209static void enable_singlestep(struct kprobe_ctlblk *kcb,
210 struct pt_regs *regs,
211 unsigned long ip)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200212{
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100213 struct per_regs per_kprobe;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200214
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100215 /* Set up the PER control registers %cr9-%cr11 */
216 per_kprobe.control = PER_EVENT_IFETCH;
217 per_kprobe.start = ip;
218 per_kprobe.end = ip;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200219
Martin Schwidefskyfc0a1fe2011-01-05 12:47:17 +0100220 /* Save control regs and psw mask */
221 __ctl_store(kcb->kprobe_saved_ctl, 9, 11);
222 kcb->kprobe_saved_imask = regs->psw.mask &
223 (PSW_MASK_PER | PSW_MASK_IO | PSW_MASK_EXT);
224
225 /* Set PER control regs, turns on single step for the given address */
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100226 __ctl_load(per_kprobe, 9, 11);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200227 regs->psw.mask |= PSW_MASK_PER;
Martin Schwidefskyadb45832010-11-10 10:05:57 +0100228 regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT);
Heiko Carstensfecc8682016-01-18 12:49:44 +0100229 regs->psw.addr = ip;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200230}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200231NOKPROBE_SYMBOL(enable_singlestep);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200232
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200233static void disable_singlestep(struct kprobe_ctlblk *kcb,
234 struct pt_regs *regs,
235 unsigned long ip)
Martin Schwidefskyfc0a1fe2011-01-05 12:47:17 +0100236{
237 /* Restore control regs and psw mask, set new psw address */
238 __ctl_load(kcb->kprobe_saved_ctl, 9, 11);
239 regs->psw.mask &= ~PSW_MASK_PER;
240 regs->psw.mask |= kcb->kprobe_saved_imask;
Heiko Carstensfecc8682016-01-18 12:49:44 +0100241 regs->psw.addr = ip;
Martin Schwidefskyfc0a1fe2011-01-05 12:47:17 +0100242}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200243NOKPROBE_SYMBOL(disable_singlestep);
Martin Schwidefskyfc0a1fe2011-01-05 12:47:17 +0100244
Martin Schwidefskyb9599792011-01-05 12:47:20 +0100245/*
246 * Activate a kprobe by storing its pointer to current_kprobe. The
247 * previous kprobe is stored in kcb->prev_kprobe. A stack of up to
248 * two kprobes can be active, see KPROBE_REENTER.
249 */
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200250static void push_kprobe(struct kprobe_ctlblk *kcb, struct kprobe *p)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200251{
Christoph Lametereb7e7d72014-08-17 12:30:45 -0500252 kcb->prev_kprobe.kp = __this_cpu_read(current_kprobe);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200253 kcb->prev_kprobe.status = kcb->kprobe_status;
Christoph Lametereb7e7d72014-08-17 12:30:45 -0500254 __this_cpu_write(current_kprobe, p);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200255}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200256NOKPROBE_SYMBOL(push_kprobe);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200257
Martin Schwidefskyb9599792011-01-05 12:47:20 +0100258/*
259 * Deactivate a kprobe by backing up to the previous state. If the
260 * current state is KPROBE_REENTER prev_kprobe.kp will be non-NULL,
261 * for any other state prev_kprobe.kp will be NULL.
262 */
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200263static void pop_kprobe(struct kprobe_ctlblk *kcb)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200264{
Christoph Lametereb7e7d72014-08-17 12:30:45 -0500265 __this_cpu_write(current_kprobe, kcb->prev_kprobe.kp);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200266 kcb->kprobe_status = kcb->prev_kprobe.status;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200267}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200268NOKPROBE_SYMBOL(pop_kprobe);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200269
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200270void arch_prepare_kretprobe(struct kretprobe_instance *ri, struct pt_regs *regs)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200271{
Christoph Hellwig4c4308c2007-05-08 00:34:14 -0700272 ri->ret_addr = (kprobe_opcode_t *) regs->gprs[14];
Michael Grundy4ba069b2006-09-20 15:58:39 +0200273
Christoph Hellwig4c4308c2007-05-08 00:34:14 -0700274 /* Replace the return addr with trampoline addr */
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100275 regs->gprs[14] = (unsigned long) &kretprobe_trampoline;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200276}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200277NOKPROBE_SYMBOL(arch_prepare_kretprobe);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200278
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200279static void kprobe_reenter_check(struct kprobe_ctlblk *kcb, struct kprobe *p)
Martin Schwidefsky0e917cc2011-01-05 12:47:23 +0100280{
281 switch (kcb->kprobe_status) {
282 case KPROBE_HIT_SSDONE:
283 case KPROBE_HIT_ACTIVE:
284 kprobes_inc_nmissed_count(p);
285 break;
286 case KPROBE_HIT_SS:
287 case KPROBE_REENTER:
288 default:
289 /*
290 * A kprobe on the code path to single step an instruction
291 * is a BUG. The code path resides in the .kprobes.text
292 * section and is executed with interrupts disabled.
293 */
294 printk(KERN_EMERG "Invalid kprobe detected at %p.\n", p->addr);
295 dump_kprobe(p);
296 BUG();
297 }
298}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200299NOKPROBE_SYMBOL(kprobe_reenter_check);
Martin Schwidefsky0e917cc2011-01-05 12:47:23 +0100300
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200301static int kprobe_handler(struct pt_regs *regs)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200302{
Michael Grundy4ba069b2006-09-20 15:58:39 +0200303 struct kprobe_ctlblk *kcb;
Martin Schwidefsky0e917cc2011-01-05 12:47:23 +0100304 struct kprobe *p;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200305
306 /*
Martin Schwidefsky0e917cc2011-01-05 12:47:23 +0100307 * We want to disable preemption for the entire duration of kprobe
308 * processing. That includes the calls to the pre/post handlers
309 * and single stepping the kprobe instruction.
Michael Grundy4ba069b2006-09-20 15:58:39 +0200310 */
311 preempt_disable();
312 kcb = get_kprobe_ctlblk();
Heiko Carstens9cb1cce2016-01-18 13:12:19 +0100313 p = get_kprobe((void *)(regs->psw.addr - 2));
Michael Grundy4ba069b2006-09-20 15:58:39 +0200314
Martin Schwidefsky0e917cc2011-01-05 12:47:23 +0100315 if (p) {
316 if (kprobe_running()) {
Martin Schwidefskyb9599792011-01-05 12:47:20 +0100317 /*
318 * We have hit a kprobe while another is still
319 * active. This can happen in the pre and post
320 * handler. Single step the instruction of the
321 * new probe but do not call any handler function
322 * of this secondary kprobe.
323 * push_kprobe and pop_kprobe saves and restores
324 * the currently active kprobe.
Michael Grundy4ba069b2006-09-20 15:58:39 +0200325 */
Martin Schwidefsky0e917cc2011-01-05 12:47:23 +0100326 kprobe_reenter_check(kcb, p);
Martin Schwidefskyb9599792011-01-05 12:47:20 +0100327 push_kprobe(kcb, p);
Martin Schwidefsky0e917cc2011-01-05 12:47:23 +0100328 kcb->kprobe_status = KPROBE_REENTER;
329 } else {
330 /*
331 * If we have no pre-handler or it returned 0, we
332 * continue with single stepping. If we have a
333 * pre-handler and it returned non-zero, it prepped
334 * for calling the break_handler below on re-entry
335 * for jprobe processing, so get out doing nothing
336 * more here.
337 */
338 push_kprobe(kcb, p);
339 kcb->kprobe_status = KPROBE_HIT_ACTIVE;
340 if (p->pre_handler && p->pre_handler(p, regs))
341 return 1;
342 kcb->kprobe_status = KPROBE_HIT_SS;
343 }
344 enable_singlestep(kcb, regs, (unsigned long) p->ainsn.insn);
345 return 1;
346 } else if (kprobe_running()) {
Christoph Lametereb7e7d72014-08-17 12:30:45 -0500347 p = __this_cpu_read(current_kprobe);
Martin Schwidefsky0e917cc2011-01-05 12:47:23 +0100348 if (p->break_handler && p->break_handler(p, regs)) {
349 /*
350 * Continuation after the jprobe completed and
351 * caused the jprobe_return trap. The jprobe
352 * break_handler "returns" to the original
353 * function that still has the kprobe breakpoint
354 * installed. We continue with single stepping.
355 */
356 kcb->kprobe_status = KPROBE_HIT_SS;
Martin Schwidefskyfc0a1fe2011-01-05 12:47:17 +0100357 enable_singlestep(kcb, regs,
358 (unsigned long) p->ainsn.insn);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200359 return 1;
Martin Schwidefsky0e917cc2011-01-05 12:47:23 +0100360 } /* else:
361 * No kprobe at this address and the current kprobe
362 * has no break handler (no jprobe!). The kernel just
363 * exploded, let the standard trap handler pick up the
364 * pieces.
365 */
366 } /* else:
367 * No kprobe at this address and no active kprobe. The trap has
368 * not been caused by a kprobe breakpoint. The race of breakpoint
369 * vs. kprobe remove does not exist because on s390 as we use
370 * stop_machine to arm/disarm the breakpoints.
371 */
Michael Grundy4ba069b2006-09-20 15:58:39 +0200372 preempt_enable_no_resched();
Martin Schwidefsky0e917cc2011-01-05 12:47:23 +0100373 return 0;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200374}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200375NOKPROBE_SYMBOL(kprobe_handler);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200376
377/*
378 * Function return probe trampoline:
379 * - init_kprobes() establishes a probepoint here
380 * - When the probed function returns, this probe
381 * causes the handlers to fire
382 */
Heiko Carstensa8061702008-04-17 07:46:26 +0200383static void __used kretprobe_trampoline_holder(void)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200384{
385 asm volatile(".global kretprobe_trampoline\n"
386 "kretprobe_trampoline: bcr 0,0\n");
387}
388
389/*
390 * Called when the probe at kretprobe trampoline is hit
391 */
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200392static int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200393{
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100394 struct kretprobe_instance *ri;
bibo,mao99219a32006-10-02 02:17:35 -0700395 struct hlist_head *head, empty_rp;
Sasha Levinb67bfe02013-02-27 17:06:00 -0800396 struct hlist_node *tmp;
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100397 unsigned long flags, orig_ret_address;
398 unsigned long trampoline_address;
399 kprobe_opcode_t *correct_ret_addr;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200400
bibo,mao99219a32006-10-02 02:17:35 -0700401 INIT_HLIST_HEAD(&empty_rp);
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700402 kretprobe_hash_lock(current, &head, &flags);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200403
404 /*
405 * It is possible to have multiple instances associated with a given
406 * task either because an multiple functions in the call path
Frederik Schwarzer025dfda2008-10-16 19:02:37 +0200407 * have a return probe installed on them, and/or more than one return
Michael Grundy4ba069b2006-09-20 15:58:39 +0200408 * return probe was registered for a target function.
409 *
410 * We can handle this because:
411 * - instances are always inserted at the head of the list
412 * - when multiple return probes are registered for the same
413 * function, the first instance's ret_addr will point to the
414 * real return address, and all the rest will point to
415 * kretprobe_trampoline
416 */
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100417 ri = NULL;
418 orig_ret_address = 0;
419 correct_ret_addr = NULL;
420 trampoline_address = (unsigned long) &kretprobe_trampoline;
Sasha Levinb67bfe02013-02-27 17:06:00 -0800421 hlist_for_each_entry_safe(ri, tmp, head, hlist) {
Michael Grundy4ba069b2006-09-20 15:58:39 +0200422 if (ri->task != current)
423 /* another task is sharing our hash bucket */
424 continue;
425
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100426 orig_ret_address = (unsigned long) ri->ret_addr;
Martin Schwidefsky89480802010-11-10 10:05:58 +0100427
428 if (orig_ret_address != trampoline_address)
429 /*
430 * This is the real return address. Any other
431 * instances associated with this task are for
432 * other calls deeper on the call stack
433 */
434 break;
435 }
436
437 kretprobe_assert(ri, orig_ret_address, trampoline_address);
438
439 correct_ret_addr = ri->ret_addr;
Sasha Levinb67bfe02013-02-27 17:06:00 -0800440 hlist_for_each_entry_safe(ri, tmp, head, hlist) {
Martin Schwidefsky89480802010-11-10 10:05:58 +0100441 if (ri->task != current)
442 /* another task is sharing our hash bucket */
443 continue;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200444
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100445 orig_ret_address = (unsigned long) ri->ret_addr;
Martin Schwidefsky89480802010-11-10 10:05:58 +0100446
447 if (ri->rp && ri->rp->handler) {
448 ri->ret_addr = correct_ret_addr;
449 ri->rp->handler(ri, regs);
450 }
451
bibo,mao99219a32006-10-02 02:17:35 -0700452 recycle_rp_inst(ri, &empty_rp);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200453
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100454 if (orig_ret_address != trampoline_address)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200455 /*
456 * This is the real return address. Any other
457 * instances associated with this task are for
458 * other calls deeper on the call stack
459 */
460 break;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200461 }
Martin Schwidefsky89480802010-11-10 10:05:58 +0100462
Heiko Carstensfecc8682016-01-18 12:49:44 +0100463 regs->psw.addr = orig_ret_address;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200464
Martin Schwidefskyb9599792011-01-05 12:47:20 +0100465 pop_kprobe(get_kprobe_ctlblk());
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700466 kretprobe_hash_unlock(current, &flags);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200467 preempt_enable_no_resched();
468
Sasha Levinb67bfe02013-02-27 17:06:00 -0800469 hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
bibo,mao99219a32006-10-02 02:17:35 -0700470 hlist_del(&ri->hlist);
471 kfree(ri);
472 }
Michael Grundy4ba069b2006-09-20 15:58:39 +0200473 /*
474 * By returning a non-zero value, we are telling
475 * kprobe_handler() that we don't want the post_handler
476 * to run (and have re-enabled preemption)
477 */
478 return 1;
479}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200480NOKPROBE_SYMBOL(trampoline_probe_handler);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200481
482/*
483 * Called after single-stepping. p->addr is the address of the
484 * instruction whose first byte has been replaced by the "breakpoint"
485 * instruction. To avoid the SMP problems that can occur when we
486 * temporarily put back the original opcode to single-step, we
487 * single-stepped a copy of the instruction. The address of this
488 * copy is p->ainsn.insn.
489 */
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200490static void resume_execution(struct kprobe *p, struct pt_regs *regs)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200491{
492 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
Heiko Carstens9cb1cce2016-01-18 13:12:19 +0100493 unsigned long ip = regs->psw.addr;
Jan Willeke975fab12014-09-22 16:37:27 +0200494 int fixup = probe_get_fixup_type(p->ainsn.insn);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200495
Heiko Carstensc9331462014-10-15 12:17:38 +0200496 /* Check if the kprobes location is an enabled ftrace caller */
497 if (p->ainsn.is_ftrace_insn) {
498 struct ftrace_insn *insn = (struct ftrace_insn *) p->addr;
499 struct ftrace_insn call_insn;
500
501 ftrace_generate_call_insn(&call_insn, (unsigned long) p->addr);
502 /*
503 * A kprobe on an enabled ftrace call site actually single
504 * stepped an unconditional branch (ftrace nop equivalent).
505 * Now we need to fixup things and pretend that a brasl r0,...
506 * was executed instead.
507 */
508 if (insn->disp == KPROBE_ON_FTRACE_CALL) {
509 ip += call_insn.disp * 2 - MCOUNT_INSN_SIZE;
510 regs->gprs[0] = (unsigned long)p->addr + sizeof(*insn);
511 }
512 }
513
Martin Schwidefskyba640a52011-01-05 12:47:19 +0100514 if (fixup & FIXUP_PSW_NORMAL)
Martin Schwidefskyfc0a1fe2011-01-05 12:47:17 +0100515 ip += (unsigned long) p->addr - (unsigned long) p->ainsn.insn;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200516
Martin Schwidefskyba640a52011-01-05 12:47:19 +0100517 if (fixup & FIXUP_BRANCH_NOT_TAKEN) {
Heiko Carstensa882b3b2013-09-13 13:59:26 +0200518 int ilen = insn_length(p->ainsn.insn[0] >> 8);
Martin Schwidefskyba640a52011-01-05 12:47:19 +0100519 if (ip - (unsigned long) p->ainsn.insn == ilen)
520 ip = (unsigned long) p->addr + ilen;
521 }
Michael Grundy4ba069b2006-09-20 15:58:39 +0200522
Martin Schwidefskyba640a52011-01-05 12:47:19 +0100523 if (fixup & FIXUP_RETURN_REGISTER) {
524 int reg = (p->ainsn.insn[0] & 0xf0) >> 4;
525 regs->gprs[reg] += (unsigned long) p->addr -
526 (unsigned long) p->ainsn.insn;
527 }
Michael Grundy4ba069b2006-09-20 15:58:39 +0200528
Martin Schwidefskyfc0a1fe2011-01-05 12:47:17 +0100529 disable_singlestep(kcb, regs, ip);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200530}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200531NOKPROBE_SYMBOL(resume_execution);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200532
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200533static int post_kprobe_handler(struct pt_regs *regs)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200534{
Michael Grundy4ba069b2006-09-20 15:58:39 +0200535 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100536 struct kprobe *p = kprobe_running();
Michael Grundy4ba069b2006-09-20 15:58:39 +0200537
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100538 if (!p)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200539 return 0;
540
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100541 if (kcb->kprobe_status != KPROBE_REENTER && p->post_handler) {
Michael Grundy4ba069b2006-09-20 15:58:39 +0200542 kcb->kprobe_status = KPROBE_HIT_SSDONE;
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100543 p->post_handler(p, regs, 0);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200544 }
545
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100546 resume_execution(p, regs);
Martin Schwidefskyb9599792011-01-05 12:47:20 +0100547 pop_kprobe(kcb);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200548 preempt_enable_no_resched();
549
550 /*
551 * if somebody else is singlestepping across a probe point, psw mask
552 * will have PER set, in which case, continue the remaining processing
553 * of do_single_step, as if this is not a probe hit.
554 */
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100555 if (regs->psw.mask & PSW_MASK_PER)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200556 return 0;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200557
558 return 1;
559}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200560NOKPROBE_SYMBOL(post_kprobe_handler);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200561
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200562static int kprobe_trap_handler(struct pt_regs *regs, int trapnr)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200563{
Michael Grundy4ba069b2006-09-20 15:58:39 +0200564 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100565 struct kprobe *p = kprobe_running();
Michael Grundy4ba069b2006-09-20 15:58:39 +0200566 const struct exception_table_entry *entry;
567
568 switch(kcb->kprobe_status) {
569 case KPROBE_SWAP_INST:
570 /* We are here because the instruction replacement failed */
571 return 0;
572 case KPROBE_HIT_SS:
573 case KPROBE_REENTER:
574 /*
575 * We are here because the instruction being single
576 * stepped caused a page fault. We reset the current
577 * kprobe and the nip points back to the probe address
578 * and allow the page fault handler to continue as a
579 * normal page fault.
580 */
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100581 disable_singlestep(kcb, regs, (unsigned long) p->addr);
Martin Schwidefskyb9599792011-01-05 12:47:20 +0100582 pop_kprobe(kcb);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200583 preempt_enable_no_resched();
584 break;
585 case KPROBE_HIT_ACTIVE:
586 case KPROBE_HIT_SSDONE:
587 /*
588 * We increment the nmissed count for accounting,
Anoop Thomas Mathew23d6d3d2013-09-20 09:25:41 +0530589 * we can also use npre/npostfault count for accounting
Michael Grundy4ba069b2006-09-20 15:58:39 +0200590 * these specific fault cases.
591 */
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100592 kprobes_inc_nmissed_count(p);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200593
594 /*
595 * We come here because instructions in the pre/post
596 * handler caused the page_fault, this could happen
597 * if handler tries to access user space by
598 * copy_from_user(), get_user() etc. Let the
599 * user-specified handler try to fix it first.
600 */
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100601 if (p->fault_handler && p->fault_handler(p, regs, trapnr))
Michael Grundy4ba069b2006-09-20 15:58:39 +0200602 return 1;
603
604 /*
605 * In case the user-specified fault handler returned
606 * zero, try to fix up.
607 */
Heiko Carstens9cb1cce2016-01-18 13:12:19 +0100608 entry = search_exception_tables(regs->psw.addr);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200609 if (entry) {
Heiko Carstensfecc8682016-01-18 12:49:44 +0100610 regs->psw.addr = extable_fixup(entry);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200611 return 1;
612 }
613
614 /*
615 * fixup_exception() could not handle it,
616 * Let do_page_fault() fix it.
617 */
618 break;
619 default:
620 break;
621 }
622 return 0;
623}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200624NOKPROBE_SYMBOL(kprobe_trap_handler);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200625
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200626int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
Martin Schwidefskyadb45832010-11-10 10:05:57 +0100627{
628 int ret;
629
630 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT))
631 local_irq_disable();
632 ret = kprobe_trap_handler(regs, trapnr);
633 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT))
634 local_irq_restore(regs->psw.mask & ~PSW_MASK_PER);
635 return ret;
636}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200637NOKPROBE_SYMBOL(kprobe_fault_handler);
Martin Schwidefskyadb45832010-11-10 10:05:57 +0100638
Michael Grundy4ba069b2006-09-20 15:58:39 +0200639/*
640 * Wrapper routine to for handling exceptions.
641 */
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200642int kprobe_exceptions_notify(struct notifier_block *self,
643 unsigned long val, void *data)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200644{
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100645 struct die_args *args = (struct die_args *) data;
Martin Schwidefskyadb45832010-11-10 10:05:57 +0100646 struct pt_regs *regs = args->regs;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200647 int ret = NOTIFY_DONE;
648
Martin Schwidefskyadb45832010-11-10 10:05:57 +0100649 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT))
650 local_irq_disable();
651
Michael Grundy4ba069b2006-09-20 15:58:39 +0200652 switch (val) {
653 case DIE_BPT:
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100654 if (kprobe_handler(regs))
Michael Grundy4ba069b2006-09-20 15:58:39 +0200655 ret = NOTIFY_STOP;
656 break;
657 case DIE_SSTEP:
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100658 if (post_kprobe_handler(regs))
Michael Grundy4ba069b2006-09-20 15:58:39 +0200659 ret = NOTIFY_STOP;
660 break;
661 case DIE_TRAP:
Martin Schwidefskyadb45832010-11-10 10:05:57 +0100662 if (!preemptible() && kprobe_running() &&
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100663 kprobe_trap_handler(regs, args->trapnr))
Michael Grundy4ba069b2006-09-20 15:58:39 +0200664 ret = NOTIFY_STOP;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200665 break;
666 default:
667 break;
668 }
Martin Schwidefskyadb45832010-11-10 10:05:57 +0100669
670 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT))
671 local_irq_restore(regs->psw.mask & ~PSW_MASK_PER);
672
Michael Grundy4ba069b2006-09-20 15:58:39 +0200673 return ret;
674}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200675NOKPROBE_SYMBOL(kprobe_exceptions_notify);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200676
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200677int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200678{
679 struct jprobe *jp = container_of(p, struct jprobe, kp);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200680 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
Martin Schwidefsky92b8cbf2011-01-05 12:47:22 +0100681 unsigned long stack;
Michael Grundy4ba069b2006-09-20 15:58:39 +0200682
683 memcpy(&kcb->jprobe_saved_regs, regs, sizeof(struct pt_regs));
684
685 /* setup return addr to the jprobe handler routine */
Heiko Carstensfecc8682016-01-18 12:49:44 +0100686 regs->psw.addr = (unsigned long) jp->entry;
Martin Schwidefskyadb45832010-11-10 10:05:57 +0100687 regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200688
Michael Grundy4ba069b2006-09-20 15:58:39 +0200689 /* r15 is the stack pointer */
Martin Schwidefsky92b8cbf2011-01-05 12:47:22 +0100690 stack = (unsigned long) regs->gprs[15];
Michael Grundy4ba069b2006-09-20 15:58:39 +0200691
Martin Schwidefsky92b8cbf2011-01-05 12:47:22 +0100692 memcpy(kcb->jprobes_stack, (void *) stack, MIN_STACK_SIZE(stack));
Jiri Olsae64a5472016-07-31 14:52:53 +0200693
694 /*
695 * jprobes use jprobe_return() which skips the normal return
696 * path of the function, and this messes up the accounting of the
697 * function graph tracer to get messed up.
698 *
699 * Pause function graph tracing while performing the jprobe function.
700 */
701 pause_graph_tracing();
Michael Grundy4ba069b2006-09-20 15:58:39 +0200702 return 1;
703}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200704NOKPROBE_SYMBOL(setjmp_pre_handler);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200705
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200706void jprobe_return(void)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200707{
708 asm volatile(".word 0x0002");
709}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200710NOKPROBE_SYMBOL(jprobe_return);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200711
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200712int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200713{
714 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
Martin Schwidefsky92b8cbf2011-01-05 12:47:22 +0100715 unsigned long stack;
716
Jiri Olsae64a5472016-07-31 14:52:53 +0200717 /* It's OK to start function graph tracing again */
718 unpause_graph_tracing();
719
Martin Schwidefsky92b8cbf2011-01-05 12:47:22 +0100720 stack = (unsigned long) kcb->jprobe_saved_regs.gprs[15];
Michael Grundy4ba069b2006-09-20 15:58:39 +0200721
722 /* Put the regs back */
723 memcpy(regs, &kcb->jprobe_saved_regs, sizeof(struct pt_regs));
724 /* put the stack back */
Martin Schwidefsky92b8cbf2011-01-05 12:47:22 +0100725 memcpy((void *) stack, kcb->jprobes_stack, MIN_STACK_SIZE(stack));
Michael Grundy4ba069b2006-09-20 15:58:39 +0200726 preempt_enable_no_resched();
727 return 1;
728}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200729NOKPROBE_SYMBOL(longjmp_break_handler);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200730
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100731static struct kprobe trampoline = {
732 .addr = (kprobe_opcode_t *) &kretprobe_trampoline,
Michael Grundy4ba069b2006-09-20 15:58:39 +0200733 .pre_handler = trampoline_probe_handler
734};
735
736int __init arch_init_kprobes(void)
737{
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100738 return register_kprobe(&trampoline);
Michael Grundy4ba069b2006-09-20 15:58:39 +0200739}
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -0700740
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200741int arch_trampoline_kprobe(struct kprobe *p)
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -0700742{
Martin Schwidefsky4a188632011-01-05 12:47:24 +0100743 return p->addr == (kprobe_opcode_t *) &kretprobe_trampoline;
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -0700744}
Heiko Carstens7a5388d2014-10-22 12:42:38 +0200745NOKPROBE_SYMBOL(arch_trampoline_kprobe);