Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754024AbbFJGVZ (ORCPT ); Wed, 10 Jun 2015 02:21:25 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:37878 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751744AbbFJGVQ (ORCPT ); Wed, 10 Jun 2015 02:21:16 -0400 Date: Wed, 10 Jun 2015 08:21:10 +0200 From: Ingo Molnar To: Denys Vlasenko Cc: Linus Torvalds , Steven Rostedt , Borislav Petkov , "H. Peter Anvin" , Andy Lutomirski , Oleg Nesterov , Frederic Weisbecker , Alexei Starovoitov , Will Drewry , Kees Cook , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] x86/asm/entry/32: Shorten __audit_syscall_entry args preparation Message-ID: <20150610062110.GA1165@gmail.com> References: <1433876051-26604-1-git-send-email-dvlasenk@redhat.com> <1433876051-26604-3-git-send-email-dvlasenk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433876051-26604-3-git-send-email-dvlasenk@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1969 Lines: 47 * Denys Vlasenko wrote: > 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. > + /* > + * 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 So while we are at it I improved this a bit more, to: /* * At this point, registers hold syscall args in 32-bit syscall ABI: * eax is syscall#, 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 * __audit_syscall_entry() 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 Btw., syscall auditing is not auditing syscall arguments #5 and #6? Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/