public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>,
	"K.Prasad" <prasad@linux.vnet.ibm.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org, utrace-devel@redhat.com
Subject: Re: x86: do_debug && PTRACE_SINGLESTEP broken by 08d68323d1f0c34452e614263b212ca556dae47f
Date: Fri, 18 Dec 2009 03:58:09 +0100	[thread overview]
Message-ID: <20091218025806.GA16470@nowhere> (raw)
In-Reply-To: <20091218021042.GA508@redhat.com>

On Fri, Dec 18, 2009 at 03:10:42AM +0100, Oleg Nesterov wrote:
> On 12/17, Roland McGrath wrote:
> >
> > Comparing to the old (2.6.32) logic, I think it might be this (untested).
> > I also note this is the sole use of get_si_code, seems like it should
> > just be rolled in here.
> 
> Well, it is too late for me to even try to read this patch ;)
> 
> but...
> 
> > @@ -569,14 +568,15 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
> >  	 * We already checked v86 mode above, so we can check for kernel mode
> >  	 * by just checking the CPL of CS.
> >  	 */
> > +	dr6 = tsk->thread.debugreg6;
> 
> why? we have "tsk->thread.debugreg6 = dr6" above


Yeah.


 
> >  	if ((dr6 & DR_STEP) && !user_mode(regs)) {
> >  		tsk->thread.debugreg6 &= ~DR_STEP;
> >  		set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
> >  		regs->flags &= ~X86_EFLAGS_TF;
> 
> this looks strange... we set TIF_SINGLESTEP but clear X86_EFLAGS_TF


Yep, I don't understand what happens here either. This logic
was there before the refactoring and the comment indicates we want
to ignore traps from kernel. Why do we set this flag in a random
thread?



> > +	} else if (dr6 & (DR_STEP | DR_TRAP_BITS)) {
> > +		send_sigtrap(tsk, regs, error_code, get_si_code(dr6));
> >  	}
> > -	si_code = get_si_code(tsk->thread.debugreg6);
> > -	if (tsk->thread.debugreg6 & (DR_STEP | DR_TRAP_BITS))
> > -		send_sigtrap(tsk, regs, error_code, si_code);
> > +
> 
> can't understand how this change can fix the problem. We should always
> send SIGTRAP if the task returns to user-mode with X86_EFLAGS_TF?
> 
> OK. I blindly applied this patch, step-simple still fails.


Yep, that doesn't fix your problem but this patch makes sense
in that if we were not in user mode while the step occured,
we shouldn't send the signal.


  reply	other threads:[~2009-12-18  2:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-18  0:56 x86: do_debug && PTRACE_SINGLESTEP broken by 08d68323d1f0c34452e614263b212ca556dae47f Oleg Nesterov
2009-12-18  1:40 ` Roland McGrath
2009-12-18  2:10   ` Oleg Nesterov
2009-12-18  2:58     ` Frederic Weisbecker [this message]
2009-12-18  3:09       ` Frederic Weisbecker
2009-12-18  3:53     ` Roland McGrath
2009-12-18  3:06 ` Frederic Weisbecker
2009-12-18 17:27   ` Oleg Nesterov
2009-12-18 17:58     ` K.Prasad
2009-12-18 18:24       ` Oleg Nesterov
2009-12-18 20:05     ` Roland McGrath
2009-12-18 22:32       ` Oleg Nesterov
2009-12-21 10:22         ` Jan Kiszka
2009-12-21 16:53           ` Oleg Nesterov
2009-12-21 16:48             ` Jan Kiszka
2009-12-18 23:15       ` Frederic Weisbecker
2009-12-20  8:30         ` Avi Kivity
2009-12-18 17:37 ` K.Prasad

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=20091218025806.GA16470@nowhere \
    --to=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    --cc=prasad@linux.vnet.ibm.com \
    --cc=roland@redhat.com \
    --cc=stern@rowland.harvard.edu \
    --cc=utrace-devel@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox