24 #include <linux/ptrace.h>
29 #include <asm/cacheflush.h>
30 #include <asm/sections.h>
31 #include <linux/module.h>
32 #include <linux/slab.h>
42 switch (insn[0] >> 8) {
69 switch (insn[0] >> 8) {
74 if ((insn[0] & 0x0f) == 0)
95 if ((insn[0] & 0xff) == 0xb2)
99 if ((insn[0] & 0x0f) == 0x05)
103 if ((insn[0] & 0x0f) == 0x00 ||
104 (insn[0] & 0x0f) == 0x05)
108 if ((insn[2] & 0xff) == 0x44 ||
109 (insn[2] & 0xff) == 0x45)
113 if ((insn[2] & 0xff) == 0x46)
122 if ((
unsigned long) p->
addr & 0x01)
126 if (is_prohibited_opcode(p->
addr))
140 static int __kprobes swap_instruction(
void *aref)
158 stop_machine(swap_instruction, &args,
NULL);
167 stop_machine(swap_instruction, &args,
NULL);
182 per_kprobe.start =
ip;
244 case KPROBE_HIT_SSDONE:
273 kcb = get_kprobe_ctlblk();
277 if (kprobe_running()) {
287 kprobe_reenter_check(kcb, p);
305 enable_singlestep(kcb, regs, (
unsigned long) p->
ainsn.insn);
307 }
else if (kprobe_running()) {
318 enable_singlestep(kcb, regs,
319 (
unsigned long) p->
ainsn.insn);
345 asm volatile(
".global kretprobe_trampoline\n"
346 "kretprobe_trampoline: bcr 0,0\n");
358 unsigned long flags, orig_ret_address;
359 unsigned long trampoline_address;
379 orig_ret_address = 0;
380 correct_ret_addr =
NULL;
389 if (orig_ret_address != trampoline_address)
398 kretprobe_assert(ri, orig_ret_address, trampoline_address);
408 if (ri->
rp && ri->
rp->handler) {
410 ri->
rp->handler(ri, regs);
415 if (orig_ret_address != trampoline_address)
426 pop_kprobe(get_kprobe_ctlblk());
431 hlist_del(&ri->
hlist);
454 int fixup = get_fixup_type(p->
ainsn.insn);
457 ip += (
unsigned long) p->
addr - (
unsigned long) p->
ainsn.insn;
460 int ilen = ((p->
ainsn.insn[0] >> 14) + 3) & -2;
461 if (ip - (
unsigned long) p->
ainsn.insn == ilen)
462 ip = (
unsigned long) p->
addr + ilen;
466 int reg = (p->
ainsn.insn[0] & 0xf0) >> 4;
468 (
unsigned long) p->
ainsn.insn;
471 disable_singlestep(kcb, regs, ip);
477 struct kprobe *p = kprobe_running();
487 resume_execution(p, regs);
505 struct kprobe *p = kprobe_running();
521 disable_singlestep(kcb, regs, (
unsigned long) p->
addr);
526 case KPROBE_HIT_SSDONE:
571 ret = kprobe_trap_handler(regs, trapnr);
585 int ret = NOTIFY_DONE;
596 if (post_kprobe_handler(regs))
601 kprobe_trap_handler(regs, args->
trapnr))
627 stack = (
unsigned long) regs->
gprs[15];
635 asm volatile(
".word 0x0002");
640 asm volatile(
"bcr 0,0");
658 static struct kprobe trampoline = {