mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Denys Vlasenko <dvlasenk@redhat.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: Denys Vlasenko <dvlasenk@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
	Andy Lutomirski <luto@amacapital.net>,
	Oleg Nesterov <oleg@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Alexei Starovoitov <ast@plumgrid.com>,
	Will Drewry <wad@chromium.org>, Kees Cook <keescook@chromium.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] x86/asm/entry/32: Shorten __audit_syscall_entry args preparation
Date: Tue,  9 Jun 2015 15:52:55 +0200	[thread overview]
Message-ID: <1433857975-8656-2-git-send-email-dvlasenk@redhat.com> (raw)
In-Reply-To: <1433857975-8656-1-git-send-email-dvlasenk@redhat.com>

We use three MOVs to swap edx and ecx. We can use one XCHG instead.

Expand the comments. It's difficult to keep track which arg# every register
corresponds to, so spell it out.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
CC: Linus Torvalds <torvalds@linux-foundation.org>
CC: Steven Rostedt <rostedt@goodmis.org>
CC: Ingo Molnar <mingo@kernel.org>
CC: Borislav Petkov <bp@alien8.de>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Andy Lutomirski <luto@amacapital.net>
CC: Oleg Nesterov <oleg@redhat.com>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Alexei Starovoitov <ast@plumgrid.com>
CC: Will Drewry <wad@chromium.org>
CC: Kees Cook <keescook@chromium.org>
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org
---
 arch/x86/entry/entry_64_compat.S | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
index 411407a..d0b6494 100644
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -178,12 +178,16 @@ sysexit_from_sys_call:
 
 #ifdef CONFIG_AUDITSYSCALL
 	.macro auditsys_entry_common
-	movl	%esi, %r8d		/* 5th arg: 4th syscall arg */
-	movl	%ecx, %r9d		/* swap with edx */
-	movl	%edx, %ecx		/* 4th arg: 3rd syscall arg */
-	movl	%r9d, %edx		/* 3rd arg: 2nd syscall arg */
-	movl	%ebx, %esi		/* 2nd arg: 1st syscall arg */
-	movl	%eax, %edi		/* 1st arg: syscall number */
+	/*
+	 * At this point, registers hold syscall args in 32-bit ABI:
+	 * eax is syscall#, args are in ebx,ecx,edx,esi,edi,ebp.
+	 * Shuffle them to match what __audit_syscall_entry() wants.
+	 */
+	movl	%esi, %r8d		/* arg5 (r8): 4th syscall arg */
+	xchg	%ecx, %edx		/* arg4 (rcx): 3rd syscall arg (edx) */
+					/* arg3 (rdx): 2nd syscall arg (ecx) */
+	movl	%ebx, %esi		/* arg2 (rsi): 1st syscall arg */
+	movl	%eax, %edi		/* arg1 (rdi): syscall number */
 	call	__audit_syscall_entry
 	/*
 	 * We are going to jump back to syscall dispatch.
-- 
1.8.1.4


      reply	other threads:[~2015-06-09 13:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09 13:52 [PATCH 1/2] x86/asm/entry/32: Explain reloading of registers after __audit_syscall_entry Denys Vlasenko
2015-06-09 13:52 ` Denys Vlasenko [this message]

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=1433857975-8656-2-git-send-email-dvlasenk@redhat.com \
    --to=dvlasenk@redhat.com \
    --cc=ast@plumgrid.com \
    --cc=bp@alien8.de \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    --cc=wad@chromium.org \
    --cc=x86@kernel.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®