public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Bunk <bunk@kernel.org>,
	ananth@in.ibm.com, anil.s.keshavamurthy@intel.com,
	davem@davemloft.net, bugme-daemon@bugzilla.kernel.org,
	jean-marc LACROIX <jeanmarc.lacroix@free.Fr>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Arjan van de Ven <arjan@linux.intel.com>
Subject: Re: [Bug 10489] Kprobe smoke test lockdep warning
Date: Tue, 22 Apr 2008 12:18:23 -0400	[thread overview]
Message-ID: <480E0FCF.1030704@redhat.com> (raw)
In-Reply-To: <1208869770.7115.265.camel@twins>

Hi Peter,

Thank you for the patch,

Peter Zijlstra wrote:
> So the below makes it work - but I'm not getting this code; at the time
> I wrote that stuff I CC'ed each and every kprobe maintainer listed in
> the usual places but got no reposonse - can some please explain this
> stuff to me?

Sure, I came to the same decision. It is enough to remove unnecessary
trace_hardirqs_fixup_flags() from post_kprobe_handler. pt_regs->flags is
just a variable on stack -- not effective flags in that time. So we don't
need to change thread's hardirq flag.

> Are the saved flags only for the TF bit or are they made in full effect
> later (and if so, where) ?

The saved flags is for TF and IF bits.
Actually, kprobes does following:

---
do_int3()
 kprobe_exceptions_notify()
  kprobe_handler()
   prepare_singlestep() : save regs->flags, set TF and clear IF on regs->flags
"iret" : pop regs->flags image to EFLAGS reg.

<single step an instruction>

do_debug()
 kprobe_exceptions_notify()
  post_kprobe_handler() : restore regs->flags (clearing TF and restoring IF)
"iret" : pop regs->flags image to EFLAGS reg.
---

While executing a single step, EFLAGS is different from the original EFLAGS.
However, it will be recovered soon by post_kprobe_handler.
NOTE: if the single-stepping instruction is a pushf, kprobes writes saved
     EFLAGS to the top of stack.

> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

I tested it on x86-64/i386.

Acked-by: Masami Hiramatsu <mhiramat@redhat.com>

> ---
> diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
> index 34a5912..fe71e64 100644
> --- a/arch/x86/kernel/kprobes.c
> +++ b/arch/x86/kernel/kprobes.c
> @@ -865,7 +865,6 @@ static int __kprobes post_kprobe_handler(struct pt_regs *regs)
>  
>         resume_execution(cur, regs, kcb);
>         regs->flags |= kcb->kprobe_saved_flags;
> -       trace_hardirqs_fixup_flags(regs->flags);
>  
>         /* Restore back the original saved kprobes variables and continue. */
>         if (kcb->kprobe_status == KPROBE_REENTER) {
> 
> 
> 

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com


  parent reply	other threads:[~2008-04-22 16:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-21 15:06 [Bug 10489] Kprobe smoke test lockdep warning Adrian Bunk
2008-04-21 15:13 ` Vegard Nossum
2008-04-21 22:54 ` Masami Hiramatsu
2008-04-22 13:09   ` Peter Zijlstra
2008-04-22 13:26     ` Peter Zijlstra
2008-04-22 15:25       ` Masami Hiramatsu
2008-04-22 16:05         ` Peter Zijlstra
2008-04-22 16:23           ` Masami Hiramatsu
2008-04-22 19:51             ` Masami Hiramatsu
2008-04-22 16:18     ` Masami Hiramatsu [this message]
2008-07-15  9:19       ` Ingo Molnar

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=480E0FCF.1030704@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=ananth@in.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=arjan@linux.intel.com \
    --cc=bugme-daemon@bugzilla.kernel.org \
    --cc=bunk@kernel.org \
    --cc=davem@davemloft.net \
    --cc=jeanmarc.lacroix@free.Fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox