Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Datoda <datoda@yahoo.com>, Andi Kleen <ak@suse.de>
Cc: gdb-patches@sourceware.org
Subject: Re: [rfa] Handle amd64-linux %orig_rax
Date: Tue, 31 Oct 2006 18:22:00 -0000	[thread overview]
Message-ID: <20061031182209.GA29639@nevyn.them.org> (raw)
In-Reply-To: <20061031181702.73135.qmail@web53714.mail.yahoo.com>

Andi, have you got any opinion on this?  The problem arises when GDB
sets %orig_rax to -1 to indicate that the interrupted syscall should
not be resumed, and then sets %rip to some other address; the kernel is
still changing %rcx on the way out to userspace.  I think this sounds
like a kernel bug.

On Tue, Oct 31, 2006 at 10:17:01AM -0800, Datoda wrote:
> Here's my explanation of the cause of this problem: According to the
> AMD64 ABI, Section A.2, Item 2., the kernel destroys %rcx in a
> syscall. Meanwhile, the calling convention uses %rcx to pass in the
> fourth argument to the function being called. Therefore, the kernel
> may trash the fourth argument to an inferior call even when it's not
> restarting the interrupted system call (i.e., when %orig_rax is set
> to a negative value) because the kernel is still in the "syscall
> mode".
> 
> A repeat inferior call returns the correct value because the kernel
> has left that syscall mode when doing the first inferior call.
> 
> It appears to me that instead of telling the kernel not to restart a
> syscall by setting %orig_rax to -1, gdb should be telling the kernel
> to forget about the syscall all together when initiating an inferior
> call, and restoring the kernel's memory about the interrupted syscall
> when the inferior call finishes. I don't know how that can be
> achieved, though.

We don't need to restore it; we can just restart the syscall from
scratch.

> Alternatively, the kernel can be made to suppress trashing %rcx when
> the process is being debugged and %orig_rax is -1. But I don't know
> the ramification/implication of this change.
> 
> Or perhaps it's just a kernel bug that needs to be fixed....
> 
> Any other insight on this?

-- 
Daniel Jacobowitz
CodeSourcery


  reply	other threads:[~2006-10-31 18:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-31 18:17 Datoda
2006-10-31 18:22 ` Daniel Jacobowitz [this message]
2006-10-31 18:40   ` [rfa] " Andi Kleen
2006-10-31 18:49     ` Daniel Jacobowitz
2006-10-31 19:11       ` Andi Kleen
2006-10-31 19:30         ` Daniel Jacobowitz
2006-10-31 19:33           ` Daniel Jacobowitz
  -- strict thread matches above, loose matches on Subject: below --
2006-11-01 15:10 Datoda
2006-11-01 15:15 ` Daniel Jacobowitz
2006-10-31 20:10 Datoda
2006-10-31 20:17 ` Andi Kleen
2006-08-19 15:34 Daniel Jacobowitz
2006-08-19 15:46 ` Mark Kettenis
2006-08-19 15:57   ` Daniel Jacobowitz

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=20061031182209.GA29639@nevyn.them.org \
    --to=drow@false.org \
    --cc=ak@suse.de \
    --cc=datoda@yahoo.com \
    --cc=gdb-patches@sourceware.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