This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
RE: [PATCH] Kprobes- robust fault handling for i386
- From: "Mao, Bibo" <bibo dot mao at intel dot com>
- To: <prasanna at in dot ibm dot com>
- Cc: <systemtap at sources dot redhat dot com>
- Date: Wed, 22 Feb 2006 18:41:06 +0800
- Subject: RE: [PATCH] Kprobes- robust fault handling for i386
I have one question and I reply between the lines.
>-----Original Message-----
>From: systemtap-owner@sourceware.org [mailto:systemtap-owner@sourceware.org]
>On Behalf Of Prasanna S Panchamukhi
>Sent: 2006年2月22日 15:13
>To: systemtap@sources.redhat.com
>Subject: [PATCH] Kprobes- robust fault handling for i386
>
>Hi,
>
>Below is the prototype for robust fault handling, as of now
>this patch is for i386 architecture and should be easily
>ported to other architectures. Your comments and suggestions
>are welcome. This patch has been tested for page faults that
>occur while accessing user address space data. Support needs
>to be added for cases such as divide by zero, NULL pointer
>dereference, etc. Also as of now we increment the nmissed
>count, instead we can track such instances by having
>independent counters such as nprefault, npostfault.
>
>Thanks
>Prasanna
>@@ -509,9 +554,21 @@ static inline int post_kprobe_handler(st
> if (!cur)
> return 0;
>
>- if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
>+ if ((kcb->kprobe_status != KPROBE_REENTER)
>+ && (kcb->kprobe_status != KPROBE_HIT_FAULT)
>+ && cur->post_handler) {
>+ kcb->handler_regs = regs;
> kcb->kprobe_status = KPROBE_HIT_SSDONE;
>- cur->post_handler(cur, regs, 0);
>+ kprobe_post_handler_trampoline(cur, regs, kcb);
>+ kcb = get_kprobe_ctlblk();
>+ /*
>+ * Check if user defined handler caused the page fault, in
>+ * such a case restore the register pointers, just resets
>+ * the current kprobe and resumes the execution, since we
>+ * have already single stepped on original instruction.
>+ */
>+ if (kcb->kprobe_status == KPROBE_HIT_FAULT)
>+ regs = kcb->handler_regs;
> }
>
> resume_execution(cur, regs, kcb);
>@@ -541,18 +598,55 @@ static inline int kprobe_fault_handler(s
> {
> struct kprobe *cur = kprobe_running();
> struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
>+ unsigned long *sara = (unsigned long *)®s->esp;
What is ®s->esp meaning here? If instruction which causes page fault is not first instruction of called function, then ®s->esp will be local variable's memory address in the called function, but not caller return address.
>........
>+ *sara = kcb->handler_retaddr;
So in this line maybe sometimes it will only change callee function local variant's value, but not change caller return value.
Regards
Bibo,mao