]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - arch/ppc64/kernel/kprobes.c
[PATCH] Move kprobe [dis]arming into arch specific code
[linux-2.6.git] / arch / ppc64 / kernel / kprobes.c
index e950a2058a1994fc9a9e8531465813f9de3ff09c..8c0920a6d03e277d36c8f3d2767db8f363eb6e4e 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/ptrace.h>
 #include <linux/spinlock.h>
 #include <linux/preempt.h>
+#include <asm/cacheflush.h>
 #include <asm/kdebug.h>
 #include <asm/sstep.h>
 
@@ -61,16 +62,25 @@ int arch_prepare_kprobe(struct kprobe *p)
 void arch_copy_kprobe(struct kprobe *p)
 {
        memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
+       p->opcode = *p->addr;
 }
 
-void arch_remove_kprobe(struct kprobe *p)
+void arch_arm_kprobe(struct kprobe *p)
 {
+       *p->addr = BREAKPOINT_INSTRUCTION;
+       flush_icache_range((unsigned long) p->addr,
+                          (unsigned long) p->addr + sizeof(kprobe_opcode_t));
 }
 
-static inline void disarm_kprobe(struct kprobe *p, struct pt_regs *regs)
+void arch_disarm_kprobe(struct kprobe *p)
 {
        *p->addr = p->opcode;
-       regs->nip = (unsigned long)p->addr;
+       flush_icache_range((unsigned long) p->addr,
+                          (unsigned long) p->addr + sizeof(kprobe_opcode_t));
+}
+
+void arch_remove_kprobe(struct kprobe *p)
+{
 }
 
 static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
@@ -101,7 +111,8 @@ static inline int kprobe_handler(struct pt_regs *regs)
                                unlock_kprobes();
                                goto no_kprobe;
                        }
-                       disarm_kprobe(p, regs);
+                       arch_disarm_kprobe(p);
+                       regs->nip = (unsigned long)p->addr;
                        ret = 1;
                } else {
                        p = current_kprobe;