From: Rusty Russell <rusty@rustcorp.com.au>
To: vamsi@in.ibm.com
Cc: Linus Torvalds <torvalds@transmeta.com>,
"David S. Miller" <davem@redhat.com>,
linux-kernel@vger.kernel.org, vamsi_krishna@in.ibm.com
Subject: Re: [PATCH] kprobes for 2.5.30
Date: Wed, 07 Aug 2002 10:55:04 +1000 [thread overview]
Message-ID: <20020807020259.70602418A@lists.samba.org> (raw)
In-Reply-To: Your message of "Tue, 06 Aug 2002 16:42:42 +0530." <20020806164242.B22164@in.ibm.com>
In message <20020806164242.B22164@in.ibm.com> you write:
> - move trap1 and trap3 interrupt gates only under CONFIG_KPROBES. Please
> note that if we don't do this, we need to call restore_interrupts()
> from the dummy (post_)kprobe_handler() in include/asm-i386/kprobes.h
> when CONFIG_KPROBES is off. I didn't like this subtle side effect. hence
> the #ifdef CONFIG_KPROBES around _set_trap_gate. Still, the calling
> conventions of do_debug and do_int3 remain independent of CONFIG_KPROBES.
Hmm, I thought about this but then decided against it. Your way is
pretty subtle too: I think I prefer the restore_interrupts()
explicitly after the (failed) call to kprobe_handler, ie (on top of
your patch, which looks excellent):
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal working-2.5.30-kprobes-vamsi/arch/i386/kernel/traps.c working-2.5.30-kprobes/arch/i386/kernel/traps.c
--- working-2.5.30-kprobes-vamsi/arch/i386/kernel/traps.c 2002-08-07 10:45:26.000000000 +1000
+++ working-2.5.30-kprobes/arch/i386/kernel/traps.c 2002-08-07 10:51:28.000000000 +1000
@@ -517,6 +517,9 @@ asmlinkage int do_int3(struct pt_regs *r
{
if (kprobe_handler(regs))
return 1;
+ /* This is an interrupt gate, because kprobes wants interrupts
+ disabled. Normal trap handlers don't. */
+ restore_interrupts(regs);
do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL);
return 0;
}
@@ -554,6 +557,9 @@ asmlinkage int do_debug(struct pt_regs *
if (post_kprobe_handler(regs))
return 1;
+ /* Interrupts not disabled for normal trap handling. */
+ restore_interrupts(regs);
+
/* Mask out spurious debug traps due to lazy DR7 setting */
if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
if (!tsk->thread.debugreg[7])
@@ -961,14 +967,9 @@ void __init trap_init(void)
#endif
set_trap_gate(0,÷_error);
+ _set_gate(idt_table+1,14,3,&debug); /* debug trap for kprobes */
set_intr_gate(2,&nmi);
-#ifdef CONFIG_KPROBES
- _set_gate(idt_table+1,14,3,&debug);
- _set_gate(idt_table+3,14,3,&int3);
-#else
- set_trap_gate(1,&debug);
- set_system_gate(3,&int3); /* int3-5 can be called from all */
-#endif
+ _set_gate(idt_table+3,14,3,&int3); /* int3-5 can be called from all */
set_system_gate(4,&overflow);
set_system_gate(5,&bounds);
set_trap_gate(6,&invalid_op);
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal working-2.5.30-kprobes-vamsi/arch/i386/kernel/kprobes.c working-2.5.30-kprobes/arch/i386/kernel/kprobes.c
--- working-2.5.30-kprobes-vamsi/arch/i386/kernel/kprobes.c 2002-08-07 10:45:25.000000000 +1000
+++ working-2.5.30-kprobes/arch/i386/kernel/kprobes.c 2002-08-07 10:52:15.000000000 +1000
@@ -102,7 +102,6 @@ int kprobe_handler(struct pt_regs *regs)
no_kprobe:
preempt_enable_no_resched();
- restore_interrupts(regs);
return ret;
}
@@ -119,7 +118,7 @@ static void rearm_kprobe(struct kprobe *
int post_kprobe_handler(struct pt_regs *regs)
{
if (!kprobe_running())
- goto no_kprobe;
+ return 0;
if (current_kprobe->post_handler)
current_kprobe->post_handler(current_kprobe, regs, 0);
@@ -145,13 +144,9 @@ int post_kprobe_handler(struct pt_regs *
* of do_debug, as if this is not a probe hit.
*/
if (regs->eflags & TF_MASK)
- goto no_kprobe;
+ return 0;
return 1;
-
-no_kprobe:
- restore_interrupts(regs);
- return 0;
}
/* Interrupts disabled, kprobe_lock held. */
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next prev parent reply other threads:[~2002-08-07 1:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-02 2:11 [PATCH] kprobes for 2.5.30 Rusty Russell
2002-08-02 2:14 ` David S. Miller
2002-08-02 14:00 ` Vamsi Krishna S .
2002-08-05 4:14 ` Rusty Russell
2002-08-05 4:24 ` Linus Torvalds
2002-08-05 6:37 ` Rusty Russell
2002-08-05 16:10 ` Linus Torvalds
2002-08-06 2:18 ` Rusty Russell
2002-08-06 5:48 ` Linus Torvalds
2002-08-06 7:22 ` Rusty Russell
2002-08-06 7:59 ` Christoph Hellwig
2002-08-06 10:59 ` Vamsi Krishna S .
2002-08-06 11:12 ` Vamsi Krishna S .
2002-08-07 0:55 ` Rusty Russell [this message]
2002-08-07 4:59 ` Vamsi Krishna S .
2002-08-06 16:35 ` Linus Torvalds
2002-08-05 5:34 ` David S. Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020807020259.70602418A@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=davem@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
--cc=vamsi@in.ibm.com \
--cc=vamsi_krishna@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.