Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752789AbbBXAfz (ORCPT ); Mon, 23 Feb 2015 19:35:55 -0500 Received: from mail-qa0-f49.google.com ([209.85.216.49]:41330 "EHLO mail-qa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751959AbbBXAfy (ORCPT ); Mon, 23 Feb 2015 19:35:54 -0500 MIME-Version: 1.0 In-Reply-To: <1424736744-13414-5-git-send-email-dvlasenk@redhat.com> References: <1424736744-13414-1-git-send-email-dvlasenk@redhat.com> <1424736744-13414-5-git-send-email-dvlasenk@redhat.com> From: Andy Lutomirski Date: Mon, 23 Feb 2015 16:35:33 -0800 Message-ID: Subject: Re: [PATCH 5/6] x86: ia32entry.S: fold IA32_ARG_FIXUP macro into its callers To: Denys Vlasenko Cc: Linus Torvalds , Oleg Nesterov , Borislav Petkov , "H. Peter Anvin" , Frederic Weisbecker , X86 ML , Alexei Starovoitov , Will Drewry , Kees Cook , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3730 Lines: 109 On Mon, Feb 23, 2015 at 4:12 PM, Denys Vlasenko wrote: > Use of a small macro - one with conditional expansion - does more harm > than good. It obfuscates code, with minimal code reuse. > > For example, because of obfuscation it's not obvious that > in ia32_sysenter_target, we can optimize loading of r9 - > currently it is loaded with a detour through ebp. > > This patch folds IA32_ARG_FIXUP macro into its callers. > > No code changes. > Applied. > Signed-off-by: Denys Vlasenko > CC: Linus Torvalds > CC: Oleg Nesterov > CC: Borislav Petkov > CC: "H. Peter Anvin" > CC: Andy Lutomirski > CC: Frederic Weisbecker > CC: X86 ML > CC: Alexei Starovoitov > CC: Will Drewry > CC: Kees Cook > CC: linux-kernel@vger.kernel.org > --- > arch/x86/ia32/ia32entry.S | 32 ++++++++++++++++++-------------- > 1 file changed, 18 insertions(+), 14 deletions(-) > > diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S > index b567056..6dcd372 100644 > --- a/arch/x86/ia32/ia32entry.S > +++ b/arch/x86/ia32/ia32entry.S > @@ -30,17 +30,6 @@ > > .section .entry.text, "ax" > > - .macro IA32_ARG_FIXUP noebp=0 > - movl %edi,%r8d > - .if \noebp > - .else > - movl %ebp,%r9d > - .endif > - xchg %ecx,%esi > - movl %ebx,%edi > - movl %edx,%edx /* zero extension */ > - .endm > - > /* clobbers %rax */ > .macro CLEAR_RREGS _r9=rax > xorl %eax,%eax > @@ -178,7 +167,12 @@ sysenter_flags_fixed: > cmpq $(IA32_NR_syscalls-1),%rax > ja ia32_badsys > sysenter_do_call: > - IA32_ARG_FIXUP > + /* 32bit syscall -> 64bit C ABI argument conversion */ > + movl %edi,%r8d /* arg5 */ > + movl %ebp,%r9d /* arg6 */ > + xchg %ecx,%esi /* rsi:arg2, rcx:arg4 */ > + movl %ebx,%edi /* arg1 */ > + movl %edx,%edx /* arg3 (zero extension) */ > sysenter_dispatch: > call *ia32_sys_call_table(,%rax,8) > movq %rax,RAX(%rsp) > @@ -360,7 +354,12 @@ ENTRY(ia32_cstar_target) > cmpq $IA32_NR_syscalls-1,%rax > ja ia32_badsys > cstar_do_call: > - IA32_ARG_FIXUP 1 > + /* 32bit syscall -> 64bit C ABI argument conversion */ > + movl %edi,%r8d /* arg5 */ > + /* r9 already loaded */ /* arg6 */ > + xchg %ecx,%esi /* rsi:arg2, rcx:arg4 */ > + movl %ebx,%edi /* arg1 */ > + movl %edx,%edx /* arg3 (zero extension) */ > cstar_dispatch: > call *ia32_sys_call_table(,%rax,8) > movq %rax,RAX(%rsp) > @@ -477,7 +476,12 @@ ENTRY(ia32_syscall) > cmpq $(IA32_NR_syscalls-1),%rax > ja ia32_badsys > ia32_do_call: > - IA32_ARG_FIXUP > + /* 32bit syscall -> 64bit C ABI argument conversion */ > + movl %edi,%r8d /* arg5 */ > + movl %ebp,%r9d /* arg6 */ > + xchg %ecx,%esi /* rsi:arg2, rcx:arg4 */ > + movl %ebx,%edi /* arg1 */ > + movl %edx,%edx /* arg3 (zero extension) */ > call *ia32_sys_call_table(,%rax,8) # xxx: rip relative > ia32_sysret: > movq %rax,RAX(%rsp) > -- > 1.8.1.4 > -- Andy Lutomirski AMA Capital Management, LLC -- 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/