From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756764AbbCMWBm (ORCPT ); Fri, 13 Mar 2015 18:01:42 -0400 Received: from mail-lb0-f169.google.com ([209.85.217.169]:44851 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751437AbbCMWBi (ORCPT ); Fri, 13 Mar 2015 18:01:38 -0400 MIME-Version: 1.0 In-Reply-To: References: From: Andy Lutomirski Date: Fri, 13 Mar 2015 15:01:16 -0700 Message-ID: Subject: Re: [PATCH 2/6] x86: Opt into HAVE_COPY_THREAD_TLS, for both 32-bit and 64-bit To: Josh Triplett Cc: Al Viro , Andrew Morton , Ingo Molnar , Kees Cook , Oleg Nesterov , "Paul E. McKenney" , "H. Peter Anvin" , Rik van Riel , Thomas Gleixner , Thiago Macieira , Michael Kerrisk , "linux-kernel@vger.kernel.org" , Linux API , Linux FS Devel , X86 ML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 12, 2015 at 6:40 PM, Josh Triplett wrote: > For 32-bit userspace on a 64-bit kernel, this requires modifying > stub32_clone to actually swap the appropriate arguments to match > CONFIG_CLONE_BACKWARDS, rather than just leaving the C argument for tls > broken. > > Signed-off-by: Josh Triplett > Signed-off-by: Thiago Macieira > --- > arch/x86/Kconfig | 1 + > arch/x86/ia32/ia32entry.S | 2 +- > arch/x86/kernel/process_32.c | 6 +++--- > arch/x86/kernel/process_64.c | 8 ++++---- > 4 files changed, 9 insertions(+), 8 deletions(-) > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index b7d31ca..4960b0d 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -124,6 +124,7 @@ config X86 > select MODULES_USE_ELF_REL if X86_32 > select MODULES_USE_ELF_RELA if X86_64 > select CLONE_BACKWARDS if X86_32 > + select HAVE_COPY_THREAD_TLS > select ARCH_USE_BUILTIN_BSWAP > select ARCH_USE_QUEUE_RWLOCK > select OLD_SIGSUSPEND3 if X86_32 || IA32_EMULATION > diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S > index 156ebca..0286735 100644 > --- a/arch/x86/ia32/ia32entry.S > +++ b/arch/x86/ia32/ia32entry.S > @@ -487,7 +487,7 @@ GLOBAL(\label) > ALIGN > GLOBAL(stub32_clone) > leaq sys_clone(%rip),%rax > - mov %r8, %rcx > + xchg %r8, %rcx > jmp ia32_ptregs_common Do I understand correct that whatever function this is a stub for just takes its arguments in the wrong order? If so, can we just fix it instead of using xchg here? In general, I much prefer C code to new asm where it makes sense to make this tradeoff. Other than that, this is a huge improvement. You'll have minor conflicts against -tip, though. --Andy From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Lutomirski Subject: Re: [PATCH 2/6] x86: Opt into HAVE_COPY_THREAD_TLS, for both 32-bit and 64-bit Date: Fri, 13 Mar 2015 15:01:16 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: Al Viro , Andrew Morton , Ingo Molnar , Kees Cook , Oleg Nesterov , "Paul E. McKenney" , "H. Peter Anvin" , Rik van Riel , Thomas Gleixner , Thiago Macieira , Michael Kerrisk , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Linux API , Linux FS Devel , X86 ML To: Josh Triplett Return-path: In-Reply-To: Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org On Thu, Mar 12, 2015 at 6:40 PM, Josh Triplett wrote: > For 32-bit userspace on a 64-bit kernel, this requires modifying > stub32_clone to actually swap the appropriate arguments to match > CONFIG_CLONE_BACKWARDS, rather than just leaving the C argument for tls > broken. > > Signed-off-by: Josh Triplett > Signed-off-by: Thiago Macieira > --- > arch/x86/Kconfig | 1 + > arch/x86/ia32/ia32entry.S | 2 +- > arch/x86/kernel/process_32.c | 6 +++--- > arch/x86/kernel/process_64.c | 8 ++++---- > 4 files changed, 9 insertions(+), 8 deletions(-) > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index b7d31ca..4960b0d 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -124,6 +124,7 @@ config X86 > select MODULES_USE_ELF_REL if X86_32 > select MODULES_USE_ELF_RELA if X86_64 > select CLONE_BACKWARDS if X86_32 > + select HAVE_COPY_THREAD_TLS > select ARCH_USE_BUILTIN_BSWAP > select ARCH_USE_QUEUE_RWLOCK > select OLD_SIGSUSPEND3 if X86_32 || IA32_EMULATION > diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S > index 156ebca..0286735 100644 > --- a/arch/x86/ia32/ia32entry.S > +++ b/arch/x86/ia32/ia32entry.S > @@ -487,7 +487,7 @@ GLOBAL(\label) > ALIGN > GLOBAL(stub32_clone) > leaq sys_clone(%rip),%rax > - mov %r8, %rcx > + xchg %r8, %rcx > jmp ia32_ptregs_common Do I understand correct that whatever function this is a stub for just takes its arguments in the wrong order? If so, can we just fix it instead of using xchg here? In general, I much prefer C code to new asm where it makes sense to make this tradeoff. Other than that, this is a huge improvement. You'll have minor conflicts against -tip, though. --Andy