mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roland McGrath <roland@redhat.com>
To: Andi Kleen <ak@suse.de>
Cc: akpm@osdl.org, torvalds@osdl.org, linux-kernel@vger.kernel.org,
	jparadis@redhat.com, cagney@redhat.com
Subject: Re: [PATCH] x86-64 singlestep through sigreturn system call
Date: Wed, 14 Jul 2004 17:56:26 -0700	[thread overview]
Message-ID: <200407150056.i6F0uQMa010372@magilla.sf.frob.com> (raw)
In-Reply-To: Andi Kleen's message of  Tuesday, 13 July 2004 09:23:44 +0200 <20040713092344.39ea00a3.ak@suse.de>

> > This patch fixes the problem by forcing a fake single-step trap at the end
> > of rt_sigreturn when PTRACE_SINGLESTEP was used to enter the system call.
> 
> I don't like this very much, see previous mail.

The previous mail addressed the subject of changing the behavior of i386
processes, where single-stepping any system call misses a trap.  The native
x86-64 behavior is different, and so this issue is really separate from
that one.  By the way, I would love it if you could explain to me with
references to the x86-64 chip documentation why restoring TF with sysret
seems to trap before executing the next user instruction in 64-bit mode,
while restoring TF with sysexit to 32-bit user mode behaves like native
32-bit mode (as documented) and executes one instruction before taking the
single-step trap.

Anyway, on native x86-64 single-stepping into `syscall' already works like
a user would expect, and takes a single-step trap immediately on return
from the system call before executing the first user instruction.  Only
stepping into an `rt_sigreturn' call behaves otherwise.

> If you really wanted to do it:
> 
> Wouldn't it be simpler to just copy the TF bit from the previous Eflags? 
> This special case looks quite ugly.

I would expect that to work from the behavior I think I see with other
system calls.  But I've tried it and it doesn't work.  Setting TF this way
behaves like the i386 does: it executes one user instruction at the
restored PC and then traps.  I certainly find this confusing, but as I said
above I still haven't explained to myself why it doesn't behave that way
for normal system calls (that don't change the PC being returned to).


Thanks,
Roland

  reply	other threads:[~2004-07-15  1:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-13  0:22 Roland McGrath
2004-07-13  7:23 ` Andi Kleen
2004-07-15  0:56   ` Roland McGrath [this message]
2004-07-15  5:46     ` Andi Kleen
2004-07-15 21:13       ` Roland McGrath
2004-07-15 22:06         ` Andi Kleen
2004-07-15 23:57           ` Roland McGrath
     [not found] <2imAA-4n7-49@gated-at.bofh.it>
     [not found] ` <2iosE-5Kb-17@gated-at.bofh.it>
2004-07-17 11:12   ` Andi Kleen
2004-07-22  2:16     ` Roland McGrath
2004-07-22  6:11       ` Andrew Morton
2004-07-22 22:58         ` Roland McGrath

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=200407150056.i6F0uQMa010372@magilla.sf.frob.com \
    --to=roland@redhat.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=cagney@redhat.com \
    --cc=jparadis@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.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

all inboxes | Powered by JetHome®