Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e6349a958b3577da6e5c5eacda85c07f9a364cb5
Commit:     e6349a958b3577da6e5c5eacda85c07f9a364cb5
Parent:     6888199f7fe5ea496f48bb6de67b9b7f05b8071b
Author:     Ananth N Mavinakayanahalli <[EMAIL PROTECTED]>
AuthorDate: Wed Apr 18 15:57:51 2007 +1000
Committer:  Paul Mackerras <[EMAIL PROTECTED]>
CommitDate: Tue Apr 24 21:31:58 2007 +1000

    [POWERPC] kprobes: Eliminate sstep exception if instruction can be emulated
    
    For cases when probes are placed on instructions that can be emulated,
    don't take the single-step exception.
    
    Signed-off-by: Ananth N Mavinakayanahalli <[EMAIL PROTECTED]>
    Signed-off-by: Paul Mackerras <[EMAIL PROTECTED]>
---
 arch/powerpc/kernel/kprobes.c |   36 +++++++++++++++++++++++++++++++++++-
 include/asm-powerpc/kprobes.h |    5 +++++
 2 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index dd2886f..ef647e7 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -59,12 +59,14 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
        }
 
        if (!ret) {
-               memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * 
sizeof(kprobe_opcode_t));
+               memcpy(p->ainsn.insn, p->addr,
+                               MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
                p->opcode = *p->addr;
                flush_icache_range((unsigned long)p->ainsn.insn,
                        (unsigned long)p->ainsn.insn + sizeof(kprobe_opcode_t));
        }
 
+       p->ainsn.boostable = 0;
        return ret;
 }
 
@@ -232,6 +234,38 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
                return 1;
 
 ss_probe:
+       if (p->ainsn.boostable >= 0) {
+               unsigned int insn = *p->ainsn.insn;
+
+               /* regs->nip is also adjusted if emulate_step returns 1 */
+               ret = emulate_step(regs, insn);
+               if (ret > 0) {
+                       /*
+                        * Once this instruction has been boosted
+                        * successfully, set the boostable flag
+                        */
+                       if (unlikely(p->ainsn.boostable == 0))
+                               p->ainsn.boostable = 1;
+
+                       if (p->post_handler)
+                               p->post_handler(p, regs, 0);
+
+                       kcb->kprobe_status = KPROBE_HIT_SSDONE;
+                       reset_current_kprobe();
+                       preempt_enable_no_resched();
+                       return 1;
+               } else if (ret < 0) {
+                       /*
+                        * We don't allow kprobes on mtmsr(d)/rfi(d), etc.
+                        * So, we should never get here... but, its still
+                        * good to catch them, just in case...
+                        */
+                       printk("Can't step on instruction %x\n", insn);
+                       BUG();
+               } else if (ret == 0)
+                       /* This instruction can't be boosted */
+                       p->ainsn.boostable = -1;
+       }
        prepare_singlestep(p, regs);
        kcb->kprobe_status = KPROBE_HIT_SS;
        return 1;
diff --git a/include/asm-powerpc/kprobes.h b/include/asm-powerpc/kprobes.h
index 3a5dd49..f850ca7 100644
--- a/include/asm-powerpc/kprobes.h
+++ b/include/asm-powerpc/kprobes.h
@@ -87,6 +87,11 @@ extern void arch_remove_kprobe(struct kprobe *p);
 struct arch_specific_insn {
        /* copy of original instruction */
        kprobe_opcode_t *insn;
+       /*
+        * Set in kprobes code, initially to 0. If the instruction can be
+        * eumulated, this is set to 1, if not, to -1.
+        */
+       int boostable;
 };
 
 struct prev_kprobe {
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to