mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* i386 singlestep is borken
@ 2006-02-16 10:58 Chuck Ebbert
  2006-02-16 16:28 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Chuck Ebbert @ 2006-02-16 10:58 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, linux-kernel

Playing around with singlestep on i386, I found this:

1. User sets TF and starts to singlestep through code,
   handling SIGTRAPS as they occur.

2. Makes vsyscall; debug trap occurs in kernel mode and TF
   is cleared.  TIF_SINGLESTEP gets set so kernel will remember
   to re-enable TF on return to user.  But when user eflags
   is saved on the stack, TF has already been cleared.

3. When user gets control back, TF is not re-enabled.

4. Even after user clears TF, TIF_SINGLESTEP remains set
   for that thread.

None of this happens when using int80 because the flag
is cleared and re-enabled by the interrupt handler.
TIF_SINGLESTEP never gets set and doesn't need to be.

-- 
Chuck
"Equations are the Devil's sentences."  --Stephen Colbert


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: i386 singlestep is borken
  2006-02-16 10:58 i386 singlestep is borken Chuck Ebbert
@ 2006-02-16 16:28 ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2006-02-16 16:28 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: Andrew Morton, linux-kernel



On Thu, 16 Feb 2006, Chuck Ebbert wrote:
> 
> 2. Makes vsyscall; debug trap occurs in kernel mode and TF
>    is cleared.  TIF_SINGLESTEP gets set so kernel will remember
>    to re-enable TF on return to user.  But when user eflags
>    is saved on the stack, TF has already been cleared.

This is exactly correct. 

TF should be re-enabled by the "is there work to be done at system call 
return time?" logic, which should mean that we go through 
do_notify_resume() (which will set TF_MASK) and return with an "iret".

We can't return with a sysexit in the TF case, and setting TF on the stack 
is thus useless.

> 3. When user gets control back, TF is not re-enabled.

Sounds like something is broken, but I don't see what.

I did check single-step over sysenter at some point (a long time ago), so 
this has worked.

		Linus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-02-16 16:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-16 10:58 i386 singlestep is borken Chuck Ebbert
2006-02-16 16:28 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®