public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Denys Vlasenko <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, brgerst@gmail.com,
	linux-kernel@vger.kernel.org, fweisbec@gmail.com,
	ast@plumgrid.com, keescook@chromium.org,
	akpm@linux-foundation.org, rostedt@goodmis.org, hpa@zytor.com,
	luto@amacapital.net, peterz@infradead.org,
	torvalds@linux-foundation.org, oleg@redhat.com, wad@chromium.org,
	dvlasenk@redhat.com, bp@alien8.de, mingo@kernel.org
Subject: [tip:x86/asm] x86/asm/entry/32: Open-code LOAD_ARGS32
Date: Sun, 7 Jun 2015 01:31:37 -0700	[thread overview]
Message-ID: <tip-73cbf687914fd5f4ef88a42a55784fd28b7450cf@git.kernel.org> (raw)
In-Reply-To: <1433271842-9139-2-git-send-email-dvlasenk@redhat.com>

Commit-ID:  73cbf687914fd5f4ef88a42a55784fd28b7450cf
Gitweb:     http://git.kernel.org/tip/73cbf687914fd5f4ef88a42a55784fd28b7450cf
Author:     Denys Vlasenko <dvlasenk@redhat.com>
AuthorDate: Tue, 2 Jun 2015 21:04:02 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 5 Jun 2015 13:22:22 +0200

x86/asm/entry/32: Open-code LOAD_ARGS32

This macro is small, has only three callsites, and one of them
is slightly different using a conditional parameter.

A few saved lines aren't worth the resulting obfuscation.

Generated machine code is identical.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1433271842-9139-2-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/entry/ia32entry.S | 54 +++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/arch/x86/entry/ia32entry.S b/arch/x86/entry/ia32entry.S
index 8a45d2c..56f819e 100644
--- a/arch/x86/entry/ia32entry.S
+++ b/arch/x86/entry/ia32entry.S
@@ -29,28 +29,6 @@
 
 	.section .entry.text, "ax"
 
-	/*
-	 * Reload arg registers from stack in case ptrace changed them.
-	 * We don't reload %eax because syscall_trace_enter() returned
-	 * the %rax value we should see.  Instead, we just truncate that
-	 * value to 32 bits again as we did on entry from user mode.
-	 * If it's a new value set by user_regset during entry tracing,
-	 * this matches the normal truncation of the user-mode value.
-	 * If it's -1 to make us punt the syscall, then (u32)-1 is still
-	 * an appropriately invalid value.
-	 */
-	.macro LOAD_ARGS32 _r9=0
-	.if \_r9
-	movl R9(%rsp),%r9d
-	.endif
-	movl RCX(%rsp),%ecx
-	movl RDX(%rsp),%edx
-	movl RSI(%rsp),%esi
-	movl RDI(%rsp),%edi
-	movl %eax,%eax			/* zero extension */
-	.endm
-	
-
 #ifdef CONFIG_PARAVIRT
 ENTRY(native_usergs_sysret32)
 	swapgs
@@ -269,7 +247,14 @@ sysenter_tracesys:
 	movq	%rax, R8(%rsp)
 	movq	%rsp,%rdi        /* &pt_regs -> arg1 */
 	call	syscall_trace_enter
-	LOAD_ARGS32  /* reload args from stack in case ptrace changed it */
+
+	/* Reload arg registers from stack. (see sysenter_tracesys) */
+	movl	RCX(%rsp), %ecx
+	movl	RDX(%rsp), %edx
+	movl	RSI(%rsp), %esi
+	movl	RDI(%rsp), %edi
+	movl	%eax, %eax	/* zero extension */
+
 	RESTORE_EXTRA_REGS
 	jmp	sysenter_do_call
 ENDPROC(ia32_sysenter_target)
@@ -413,7 +398,15 @@ cstar_tracesys:
 	movq	%rax, R8(%rsp)
 	movq %rsp,%rdi        /* &pt_regs -> arg1 */
 	call syscall_trace_enter
-	LOAD_ARGS32 1	/* reload args from stack in case ptrace changed it */
+	movl	R9(%rsp),%r9d
+
+	/* Reload arg registers from stack. (see sysenter_tracesys) */
+	movl	RCX(%rsp), %ecx
+	movl	RDX(%rsp), %edx
+	movl	RSI(%rsp), %esi
+	movl	RDI(%rsp), %edi
+	movl	%eax, %eax	/* zero extension */
+
 	RESTORE_EXTRA_REGS
 	xchgl %ebp,%r9d
 	jmp cstar_do_call
@@ -502,7 +495,18 @@ ia32_tracesys:
 	SAVE_EXTRA_REGS
 	movq %rsp,%rdi        /* &pt_regs -> arg1 */
 	call syscall_trace_enter
-	LOAD_ARGS32	/* reload args from stack in case ptrace changed it */
+	/*
+	 * Reload arg registers from stack in case ptrace changed them.
+	 * Don't reload %eax because syscall_trace_enter() returned
+	 * the %rax value we should see.  But do truncate it to 32 bits.
+	 * If it's -1 to make us punt the syscall, then (u32)-1 is still
+	 * an appropriately invalid value.
+	 */
+	movl	RCX(%rsp), %ecx
+	movl	RDX(%rsp), %edx
+	movl	RSI(%rsp), %esi
+	movl	RDI(%rsp), %edi
+	movl	%eax, %eax	/* zero extension */
 	RESTORE_EXTRA_REGS
 	jmp ia32_do_call
 END(ia32_syscall)

  parent reply	other threads:[~2015-06-07  8:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 19:04 [PATCH 1/2] x86/asm/entry/32: Open-code CLEAR_RREGS. No code changes Denys Vlasenko
2015-06-02 19:04 ` [PATCH 2/2] x86/asm/entry/32: Open-code LOAD_ARGS32. " Denys Vlasenko
2015-06-02 19:27   ` Borislav Petkov
2015-06-07  8:31   ` tip-bot for Denys Vlasenko [this message]
2015-06-02 19:34 ` [PATCH 1/2] x86/asm/entry/32: Open-code CLEAR_RREGS. " Steven Rostedt
2015-06-02 20:25   ` Denys Vlasenko
2015-06-03  7:04   ` Ingo Molnar
2015-06-07  8:31 ` [tip:x86/asm] x86/asm/entry/32: Open-code CLEAR_RREGS tip-bot for Denys Vlasenko

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=tip-73cbf687914fd5f4ef88a42a55784fd28b7450cf@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=ast@plumgrid.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=wad@chromium.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