Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp20635729ybl; Sun, 5 Jan 2020 07:20:41 -0800 (PST) X-Google-Smtp-Source: APXvYqzDKhwELJRfaXxc4jPzQBpH1InSOBUgZsEwipQyZnwBcotCtxD5R5x6kCnBwPxDpGUR5m1k X-Received: by 2002:a05:6830:1401:: with SMTP id v1mr79183582otp.360.1578237641268; Sun, 05 Jan 2020 07:20:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578237641; cv=none; d=google.com; s=arc-20160816; b=SJdlAfy27dtynXBtWPbKDOI2gjEezn5kVMbqYMkKn7fje1CJNnke1UeT6Xjcgs4SYL SeFJzbGrnliqgXjZz2xwf6890rKp/zZknQYMmZJO+JECLCdx81vmug2iA7WT0bOSbY3k YLGiclriTXLANmsUPm6f03Dv4C4PqMs0HN5SOIjzCaNZHlD2XasuTxgYUhwanr9h3+1k QsofQCGyTJaEQujjzUVvajXlj6JnAdcq3oIo7UTbGu8GTrWnPp2QRPO3ATPcLgAoXr1L y4DKZQieRwsllQH9XjKxFm5QjP0SpcrtLOyt1sdrsmF18ksiGQ47gk1HtXuEr0ijA9QQ DieQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=H0Vfv9CDb25+M2QoUJ3yOx5zy9byqh1i0+p+H7hkwl0=; b=1KG7UeixzJJ+4BYiovuVn0ubeXtmgztBUzCPr7bGGxP3a7iGryEvrLXh6ReBo4Lbnp IPQv+jLMHIzzOWHNdG1WAwTpzLgPus90kc85GfF5y/YDHr052f0+oOtTy39X1KZBY8Zc KAg+EVhnux1b7E1EkdzjzcDDv/2mYJL93WF8pDSRJqJgIp9GXrOUIDvNLyJseqsvmezV i++gExFpmiBoG+OZ3IPXkPoCHB0McsL1mFuZb5ZQTOdvfZEsDMDRe66tlvfB+9qNSDy1 rI8DVy4DLtzM8V94jJiq2073GDX3fMNZzAx1WBiDr9IIu9Ul7uNE2XBJb4LpSueySRp3 VhXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si34972844otq.217.2020.01.05.07.20.27; Sun, 05 Jan 2020 07:20:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726422AbgAEPTn (ORCPT + 99 others); Sun, 5 Jan 2020 10:19:43 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:48434 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726212AbgAEPTm (ORCPT ); Sun, 5 Jan 2020 10:19:42 -0500 Received: from [172.58.27.182] (helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1io7gm-0007Dg-Hn; Sun, 05 Jan 2020 15:19:37 +0000 Date: Sun, 5 Jan 2020 16:19:30 +0100 From: Christian Brauner To: Amanieu d'Antras , Jeff Dike , Richard Weinberger , Anton Ivanov Cc: linux-kernel@vger.kernel.org, Christian Brauner , linux-um@lists.infradead.org, stable@vger.kernel.org Subject: Re: [PATCH] um: Implement copy_thread_tls Message-ID: <20200105151928.qrmhnwer3r5ffc77@wittgenstein> References: <20200102172413.654385-1-amanieu@gmail.com> <20200104123928.1048822-1-amanieu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200104123928.1048822-1-amanieu@gmail.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 04, 2020 at 01:39:30PM +0100, Amanieu d'Antras wrote: > This is required for clone3 which passes the TLS value through a > struct rather than a register. > > Signed-off-by: Amanieu d'Antras > Cc: linux-um@lists.infradead.org > Cc: # 5.3.x Thanks. I'm picking this up as part of the copy_thread_tls() series. (Leaving the patch in tact so people can Ack right here if they want to.) If I could get an Ack from one of the maintainers that would be great; see https://lore.kernel.org/lkml/20200102172413.654385-1-amanieu@gmail.com for more context. Acked-by: Christian Brauner > --- > arch/um/Kconfig | 1 + > arch/um/include/asm/ptrace-generic.h | 2 +- > arch/um/kernel/process.c | 6 +++--- > arch/x86/um/tls_32.c | 6 ++---- > arch/x86/um/tls_64.c | 7 +++---- > 5 files changed, 10 insertions(+), 12 deletions(-) > > diff --git a/arch/um/Kconfig b/arch/um/Kconfig > index 2a6d04fcb3e9..6f0edd0c0220 100644 > --- a/arch/um/Kconfig > +++ b/arch/um/Kconfig > @@ -14,6 +14,7 @@ config UML > select HAVE_FUTEX_CMPXCHG if FUTEX > select HAVE_DEBUG_KMEMLEAK > select HAVE_DEBUG_BUGVERBOSE > + select HAVE_COPY_THREAD_TLS > select GENERIC_IRQ_SHOW > select GENERIC_CPU_DEVICES > select GENERIC_CLOCKEVENTS > diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h > index 81c647ef9c6c..adf91ef553ae 100644 > --- a/arch/um/include/asm/ptrace-generic.h > +++ b/arch/um/include/asm/ptrace-generic.h > @@ -36,7 +36,7 @@ extern long subarch_ptrace(struct task_struct *child, long request, > extern unsigned long getreg(struct task_struct *child, int regno); > extern int putreg(struct task_struct *child, int regno, unsigned long value); > > -extern int arch_copy_tls(struct task_struct *new); > +extern int arch_set_tls(struct task_struct *new, unsigned long tls); > extern void clear_flushed_tls(struct task_struct *task); > extern int syscall_trace_enter(struct pt_regs *regs); > extern void syscall_trace_leave(struct pt_regs *regs); > diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c > index 263a8f069133..17045e7211bf 100644 > --- a/arch/um/kernel/process.c > +++ b/arch/um/kernel/process.c > @@ -153,8 +153,8 @@ void fork_handler(void) > userspace(¤t->thread.regs.regs, current_thread_info()->aux_fp_regs); > } > > -int copy_thread(unsigned long clone_flags, unsigned long sp, > - unsigned long arg, struct task_struct * p) > +int copy_thread_tls(unsigned long clone_flags, unsigned long sp, > + unsigned long arg, struct task_struct * p, unsigned long tls) > { > void (*handler)(void); > int kthread = current->flags & PF_KTHREAD; > @@ -188,7 +188,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, > * Set a new TLS for the child thread? > */ > if (clone_flags & CLONE_SETTLS) > - ret = arch_copy_tls(p); > + ret = arch_set_tls(p, tls); > } > > return ret; > diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c > index 5bd949da7a4a..ac8eee093f9c 100644 > --- a/arch/x86/um/tls_32.c > +++ b/arch/x86/um/tls_32.c > @@ -215,14 +215,12 @@ static int set_tls_entry(struct task_struct* task, struct user_desc *info, > return 0; > } > > -int arch_copy_tls(struct task_struct *new) > +int arch_set_tls(struct task_struct *new, unsigned long tls) > { > struct user_desc info; > int idx, ret = -EFAULT; > > - if (copy_from_user(&info, > - (void __user *) UPT_SI(&new->thread.regs.regs), > - sizeof(info))) > + if (copy_from_user(&info, (void __user *) tls, sizeof(info))) > goto out; > > ret = -EINVAL; > diff --git a/arch/x86/um/tls_64.c b/arch/x86/um/tls_64.c > index 3a621e0d3925..ebd3855d9b13 100644 > --- a/arch/x86/um/tls_64.c > +++ b/arch/x86/um/tls_64.c > @@ -6,14 +6,13 @@ void clear_flushed_tls(struct task_struct *task) > { > } > > -int arch_copy_tls(struct task_struct *t) > +int arch_set_tls(struct task_struct *t, unsigned long tls) > { > /* > * If CLONE_SETTLS is set, we need to save the thread id > - * (which is argument 5, child_tid, of clone) so it can be set > - * during context switches. > + * so it can be set during context switches. > */ > - t->thread.arch.fs = t->thread.regs.regs.gp[R8 / sizeof(long)]; > + t->thread.arch.fs = tls; > > return 0; > } > -- > 2.24.1 >