12 #include <linux/module.h>
13 #include <linux/ptrace.h>
16 #include <linux/slab.h>
17 #include <asm/cacheflush.h>
18 #include <asm/uaccess.h>
27 #define OPCODE_JMP(x) (((x) & 0xF0FF) == 0x402b)
28 #define OPCODE_JSR(x) (((x) & 0xF0FF) == 0x400b)
29 #define OPCODE_BRA(x) (((x) & 0xF000) == 0xa000)
30 #define OPCODE_BRAF(x) (((x) & 0xF0FF) == 0x0023)
31 #define OPCODE_BSR(x) (((x) & 0xF000) == 0xb000)
32 #define OPCODE_BSRF(x) (((x) & 0xF0FF) == 0x0003)
34 #define OPCODE_BF_S(x) (((x) & 0xFF00) == 0x8f00)
35 #define OPCODE_BT_S(x) (((x) & 0xFF00) == 0x8d00)
37 #define OPCODE_BF(x) (((x) & 0xFF00) == 0x8b00)
38 #define OPCODE_BT(x) (((x) & 0xFF00) == 0x8900)
40 #define OPCODE_RTS(x) (((x) & 0x000F) == 0x000b)
41 #define OPCODE_RTE(x) (((x) & 0xFFFF) == 0x002b)
94 printk(
"Warning: removing kprobe from delay slot: 0x%.8x\n",
95 (
unsigned int)pc + 2);
160 unsigned int reg_nr = ((p->
opcode >> 8) & 0x000F);
163 unsigned long disp = (p->
opcode & 0x0FFF);
168 unsigned int reg_nr = ((p->
opcode >> 8) & 0x000F);
177 unsigned long disp = (p->
opcode & 0x00FF);
187 unsigned long disp = (p->
opcode & 0x00FF);
227 kcb = get_kprobe_ctlblk();
232 if (kprobe_running()) {
245 save_previous_kprobe(kcb);
246 set_current_kprobe(p, regs, kcb);
248 prepare_singlestep(p, regs);
277 set_current_kprobe(p, regs, kcb);
285 prepare_singlestep(p, regs);
301 asm volatile (
".globl kretprobe_trampoline\n"
302 "kretprobe_trampoline:\n\t"
314 unsigned long flags, orig_ret_address = 0;
338 if (ri->
rp && ri->
rp->handler) {
340 ri->
rp->handler(ri, regs);
347 if (orig_ret_address != trampoline_address)
356 kretprobe_assert(ri, orig_ret_address, trampoline_address);
358 regs->
pc = orig_ret_address;
364 hlist_del(&ri->
hlist);
368 return orig_ret_address;
408 restore_previous_kprobe(kcb);
412 reset_current_kprobe();
422 struct kprobe *cur = kprobe_running();
438 restore_previous_kprobe(kcb);
440 reset_current_kprobe();
444 case KPROBE_HIT_SSDONE:
491 int ret = NOTIFY_DONE;
497 if (!kprobe_running()) {
508 if (post_kprobe_handler(args->
regs))
533 kcb->jprobe_saved_r15 = regs->
regs[15];
534 addr = kcb->jprobe_saved_r15;
553 asm volatile (
"trapa #0x3a\n\t" "jprobe_return_end:\n\t" "nop\n\t");
559 unsigned long stack_addr = kcb->jprobe_saved_r15;
560 u8 *addr = (
u8 *)regs->
pc;
577 static struct kprobe trampoline_p = {