Commit 42cc2060 authored by Prasanna S Panchamukhi's avatar Prasanna S Panchamukhi Committed by Linus Torvalds

[PATCH] kprobes: Temporary disarming of reentrant probe for ppc64

This patch includes ppc64 architecture specific changes to support temporary
disarming on reentrancy of probes.
Signed-of-by: default avatarPrasanna S Panchamukhi <prasanna@in.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent aa3d7e3d
...@@ -36,12 +36,10 @@ ...@@ -36,12 +36,10 @@
#include <asm/kdebug.h> #include <asm/kdebug.h>
#include <asm/sstep.h> #include <asm/sstep.h>
/* kprobe_status settings */
#define KPROBE_HIT_ACTIVE 0x00000001
#define KPROBE_HIT_SS 0x00000002
static struct kprobe *current_kprobe; static struct kprobe *current_kprobe;
static unsigned long kprobe_status, kprobe_saved_msr; static unsigned long kprobe_status, kprobe_saved_msr;
static struct kprobe *kprobe_prev;
static unsigned long kprobe_status_prev, kprobe_saved_msr_prev;
static struct pt_regs jprobe_saved_regs; static struct pt_regs jprobe_saved_regs;
int arch_prepare_kprobe(struct kprobe *p) int arch_prepare_kprobe(struct kprobe *p)
...@@ -93,6 +91,20 @@ static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) ...@@ -93,6 +91,20 @@ static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
regs->nip = (unsigned long)&p->ainsn.insn; regs->nip = (unsigned long)&p->ainsn.insn;
} }
static inline void save_previous_kprobe(void)
{
kprobe_prev = current_kprobe;
kprobe_status_prev = kprobe_status;
kprobe_saved_msr_prev = kprobe_saved_msr;
}
static inline void restore_previous_kprobe(void)
{
current_kprobe = kprobe_prev;
kprobe_status = kprobe_status_prev;
kprobe_saved_msr = kprobe_saved_msr_prev;
}
static inline int kprobe_handler(struct pt_regs *regs) static inline int kprobe_handler(struct pt_regs *regs)
{ {
struct kprobe *p; struct kprobe *p;
...@@ -111,9 +123,19 @@ static inline int kprobe_handler(struct pt_regs *regs) ...@@ -111,9 +123,19 @@ static inline int kprobe_handler(struct pt_regs *regs)
unlock_kprobes(); unlock_kprobes();
goto no_kprobe; goto no_kprobe;
} }
arch_disarm_kprobe(p); /* We have reentered the kprobe_handler(), since
regs->nip = (unsigned long)p->addr; * another probe was hit while within the handler.
ret = 1; * We here save the original kprobes variables and
* just single step on the instruction of the new probe
* without calling any user handlers.
*/
save_previous_kprobe();
current_kprobe = p;
kprobe_saved_msr = regs->msr;
p->nmissed++;
prepare_singlestep(p, regs);
kprobe_status = KPROBE_REENTER;
return 1;
} else { } else {
p = current_kprobe; p = current_kprobe;
if (p->break_handler && p->break_handler(p, regs)) { if (p->break_handler && p->break_handler(p, regs)) {
...@@ -195,13 +217,21 @@ static inline int post_kprobe_handler(struct pt_regs *regs) ...@@ -195,13 +217,21 @@ static inline int post_kprobe_handler(struct pt_regs *regs)
if (!kprobe_running()) if (!kprobe_running())
return 0; return 0;
if (current_kprobe->post_handler) if ((kprobe_status != KPROBE_REENTER) && current_kprobe->post_handler) {
kprobe_status = KPROBE_HIT_SSDONE;
current_kprobe->post_handler(current_kprobe, regs, 0); current_kprobe->post_handler(current_kprobe, regs, 0);
}
resume_execution(current_kprobe, regs); resume_execution(current_kprobe, regs);
regs->msr |= kprobe_saved_msr; regs->msr |= kprobe_saved_msr;
/*Restore back the original saved kprobes variables and continue. */
if (kprobe_status == KPROBE_REENTER) {
restore_previous_kprobe();
goto out;
}
unlock_kprobes(); unlock_kprobes();
out:
preempt_enable_no_resched(); preempt_enable_no_resched();
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment