30 #include <linux/slab.h>
32 #include <asm/ptrace.h>
34 #include <asm/break.h>
103 #ifdef CONFIG_CPU_CAVIUM_OCTEON
149 if (insn_has_ll_or_sc(insn)) {
150 pr_notice(
"Kprobes for ll and sc instructions are not"
158 insn_has_delayslot(prev_insn)) {
159 pr_notice(
"Kprobes for branch delayslot are not supported\n");
165 p->
ainsn.insn = get_insn_slot();
166 if (!p->
ainsn.insn) {
184 if (insn_has_delayslot(insn))
189 p->
ainsn.insn[1] = breakpoint2_insn;
198 *p->
addr = breakpoint_insn;
210 free_insn_slot(p->
ainsn.insn, 0);
222 static void restore_previous_kprobe(
struct kprobe_ctlblk *kcb)
263 if (p->
ainsn.insn->word == 0)
286 static void prepare_singlestep(
struct kprobe *p,
struct pt_regs *regs,
297 else if (insn_has_delayslot(p->
opcode)) {
298 ret = evaluate_branch_instruction(p, regs, kcb);
300 pr_notice(
"Kprobes: Error in evaluating branch\n");
323 if (insn_has_delayslot(p->
opcode))
345 kcb = get_kprobe_ctlblk();
348 if (kprobe_running()) {
352 p->
ainsn.insn->word == breakpoint_insn.
word) {
364 save_previous_kprobe(kcb);
365 set_current_kprobe(p, regs, kcb);
367 prepare_singlestep(p, regs, kcb);
370 resume_execution(p, regs, kcb);
371 restore_previous_kprobe(kcb);
376 if (addr->word != breakpoint_insn.
word) {
394 if (addr->word != breakpoint_insn.
word) {
408 set_current_kprobe(p, regs, kcb);
417 prepare_singlestep(p, regs, kcb);
422 resume_execution(p, regs, kcb);
435 static inline int post_kprobe_handler(
struct pt_regs *regs)
448 resume_execution(cur, regs, kcb);
454 restore_previous_kprobe(kcb);
457 reset_current_kprobe();
466 struct kprobe *cur = kprobe_running();
473 resume_execution(cur, regs, kcb);
476 reset_current_kprobe();
490 int ret = NOTIFY_DONE;
498 if (post_kprobe_handler(args->
regs))
541 ".globl jprobe_return_end\n"
542 "jprobe_return_end:\n"
575 ".global kretprobe_trampoline\n"
576 "kretprobe_trampoline:\n\t"
602 unsigned long flags, orig_ret_address = 0;
626 if (ri->
rp && ri->
rp->handler)
627 ri->
rp->handler(ri, regs);
632 if (orig_ret_address != trampoline_address)
641 kretprobe_assert(ri, orig_ret_address, trampoline_address);
644 reset_current_kprobe();
649 hlist_del(&ri->
hlist);
668 static struct kprobe trampoline_p = {