LKML Archive on
help / color / mirror / Atom feed
From: Roland McGrath <>
To: Ingo Molnar <>, Thomas Gleixner <>
Cc: Andrew Morton <>,
Subject: [PATCH 2/2] x86_64 ptrace vs -ENOSYS
Date: Sun, 16 Mar 2008 21:59:11 -0700 (PDT)	[thread overview]
Message-ID: <20080317045911.D241E26F995@magilla.localdomain> (raw)
In-Reply-To: Roland McGrath's message of  Sunday, 16 March 2008 21:57:41 -0700 <20080317045741.2F6A526F995@magilla.localdomain>

When we're stopped at syscall entry tracing, ptrace can change the %rax
value from -ENOSYS to something else.  If no system call is actually made
because the syscall number (now in orig_rax) is bad, then we now always
reset %rax to -ENOSYS again.

This changes it to leave the return value alone after entry tracing.
That way, the %rax value set by ptrace is there to be seen in user mode
(or in syscall exit tracing).  This is consistent with what the 32-bit
kernel does.

Signed-off-by: Roland McGrath <>
 arch/x86/kernel/entry_64.S |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index c20c9e7..556a8df 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -319,19 +319,17 @@ badsys:
 	/* Do syscall tracing */
-	movq $-ENOSYS,RAX(%rsp)
+	movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
 	movq %rsp,%rdi
 	call syscall_trace_enter
 	LOAD_ARGS ARGOFFSET  /* reload args from stack in case ptrace changed it */
 	cmpq $__NR_syscall_max,%rax
-	movq $-ENOSYS,%rcx
-	cmova %rcx,%rax
-	ja  1f
+	ja   int_ret_from_sys_call	/* RAX(%rsp) set to -ENOSYS above */
 	movq %r10,%rcx	/* fixup for C */
 	call *sys_call_table(,%rax,8)
-1:	movq %rax,RAX-ARGOFFSET(%rsp)
+	movq %rax,RAX-ARGOFFSET(%rsp)
 	/* Use IRET because user could have changed frame */

  reply	other threads:[~2008-03-17  4:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17  4:57 [PATCH 1/2] x86_64 ia32 " Roland McGrath
2008-03-17  4:59 ` Roland McGrath [this message]
2008-03-19  1:23 ` [PATCH] x86_64 ia32 ptrace vs -ENOSYS sysenter/syscall Roland McGrath
2008-03-19 22:17 ` [PATCH 1/2] x86_64 ia32 ptrace vs -ENOSYS Andrew Morton
2008-03-19 23:36   ` Roland McGrath
2008-03-21 10:33     ` 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080317045911.D241E26F995@magilla.localdomain \ \ \ \ \ \
    --subject='Re: [PATCH 2/2] x86_64 ptrace vs -ENOSYS' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).