From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933464AbbFJHL1 (ORCPT ); Wed, 10 Jun 2015 03:11:27 -0400 Received: from terminus.zytor.com ([198.137.202.10]:34102 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933443AbbFJHLL (ORCPT ); Wed, 10 Jun 2015 03:11:11 -0400 Date: Wed, 10 Jun 2015 00:10:10 -0700 From: tip-bot for Denys Vlasenko Message-ID: Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, wad@chromium.org, brgerst@gmail.com, luto@amacapital.net, dvlasenk@redhat.com, mingo@kernel.org, rostedt@goodmis.org, tglx@linutronix.de, keescook@chromium.org, bp@alien8.de, oleg@redhat.com, hpa@zytor.com, torvalds@linux-foundation.org, fweisbec@gmail.com, akpm@linux-foundation.org, ast@plumgrid.com Reply-To: rostedt@goodmis.org, keescook@chromium.org, tglx@linutronix.de, mingo@kernel.org, ast@plumgrid.com, akpm@linux-foundation.org, fweisbec@gmail.com, oleg@redhat.com, hpa@zytor.com, bp@alien8.de, torvalds@linux-foundation.org, wad@chromium.org, linux-kernel@vger.kernel.org, peterz@infradead.org, luto@amacapital.net, dvlasenk@redhat.com, brgerst@gmail.com In-Reply-To: <1433876051-26604-3-git-send-email-dvlasenk@redhat.com> References: <1433876051-26604-3-git-send-email-dvlasenk@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/asm/entry/32: Shorten __audit_syscall_entry() args preparation Git-Commit-ID: a92fde25231a89d7d10895482556260c1b63767d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a92fde25231a89d7d10895482556260c1b63767d Gitweb: http://git.kernel.org/tip/a92fde25231a89d7d10895482556260c1b63767d Author: Denys Vlasenko AuthorDate: Tue, 9 Jun 2015 20:54:09 +0200 Committer: Ingo Molnar CommitDate: Wed, 10 Jun 2015 08:42:13 +0200 x86/asm/entry/32: Shorten __audit_syscall_entry() args preparation 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 Cc: Alexei Starovoitov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Frederic Weisbecker Cc: H. Peter Anvin Cc: Kees Cook Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Thomas Gleixner Cc: Will Drewry Link: http://lkml.kernel.org/r/1433876051-26604-3-git-send-email-dvlasenk@redhat.com [ Expanded the comments some more. ] Signed-off-by: Ingo Molnar --- arch/x86/entry/entry_64_compat.S | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S index 0fa108c..bb187a6 100644 --- a/arch/x86/entry/entry_64_compat.S +++ b/arch/x86/entry/entry_64_compat.S @@ -178,17 +178,26 @@ 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 the 32-bit syscall ABI: + * EAX is syscall number, the 6 args are in EBX,ECX,EDX,ESI,EDI,EBP. + * + * We want to pass them to __audit_syscall_entry(), which is a 64-bit + * C function with 5 parameters, so shuffle them to match what + * the function expects: RDI,RSI,RDX,RCX,R8. + */ + movl %esi, %r8d /* arg5 (R8 ) <= 4th syscall arg (ESI) */ + xchg %ecx, %edx /* arg4 (RCX) <= 3rd syscall arg (EDX) */ + /* arg3 (RDX) <= 2nd syscall arg (ECX) */ + movl %ebx, %esi /* arg2 (RSI) <= 1st syscall arg (EBX) */ + movl %eax, %edi /* arg1 (RDI) <= syscall number (EAX) */ call __audit_syscall_entry + /* - * We are going to jump back to syscall dispatch. - * Prepare syscall args as required by 64-bit C ABI. - * Clobbered registers are loaded from pt_regs on stack. + * We are going to jump back to the syscall dispatch code. + * Prepare syscall args as required by the 64-bit C ABI. + * Registers clobbered by __audit_syscall_entry() are + * loaded from pt_regs on stack: */ movl ORIG_RAX(%rsp), %eax /* syscall number */ movl %ebx, %edi /* arg1 */