Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4709646ybl; Mon, 13 Jan 2020 19:11:56 -0800 (PST) X-Google-Smtp-Source: APXvYqw6rVnXDeKawiCMsVWkgW3DbtHOat1IevjWNJ0gh4zp7RK+4uAzA6Re0bhi5vQY3Qs8EANT X-Received: by 2002:aca:a949:: with SMTP id s70mr15667559oie.80.1578971516818; Mon, 13 Jan 2020 19:11:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578971516; cv=none; d=google.com; s=arc-20160816; b=qQtjQhSlTVWVVyT065fVoBe2Y0F0dVGHOMx4DNZUoo4Fied4Cjv68AZLugr3NApzeQ DjxK+rVzu8mtq5ddxPvxMgYZHe+fyQ/WOBhuzE3BGLjPWhiOxYCu7hNw4El9KRpK8FNn CcRwaFksDsnS1QF4Oh0JW3gq/fKPV5hHsin8RnFBK1IhPJWbsh527cYH2a/lT5alJWAT hT7m/Y65WzG4KkmqgdCNxR1XbAoi8cjCh9656gFkPKbBHP19P05lJ0eeqaU6S/SkNcBN qd8FSMKy6hRWPFyfZCDVndldbKpItqATGkL5WCD290lF1smWTyKGxYaaJSee7lo6Mjkd F3KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=S4BoKwKIt+FizHYS8F8+R4gJezWrtDXRzBE82zngl54=; b=w+1PCdur+9fB3InrNRarUijGn3499cFdOcGZw04bUjMLGroMNliYaum9oLOe3LTkIl BA4Fik1xM2xMY7gBIwc5qqTjVeFe52nxoa+WjOywYE8eMvmcUhOK1xu2g/pNFYcRFayV mOSg2epj1Yn2SiqRDwivOUE1P3/Fu7w6yyA/vXjfgox5xXdYE+VR7MW47aELfe+cc2Xl T+YdEYRZ0le1mhS6vE2SWkDapQYlcd5bwz6ENRV+jMXzYbsg6v85avTOnPkfq0wg5NJv SxLJNW2WMhUB8iwV6/5osuo/a2YWmEbrj7MTo6iDtvUqNa8YRs5/0ZmIvmfaEVUySXsT zw8A== 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 l204si6679002oif.261.2020.01.13.19.11.45; Mon, 13 Jan 2020 19:11:56 -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 S1729375AbgANBzO (ORCPT + 99 others); Mon, 13 Jan 2020 20:55:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:47478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728838AbgANBzM (ORCPT ); Mon, 13 Jan 2020 20:55:12 -0500 Received: from [10.44.0.22] (unknown [103.48.210.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B5259207FF; Tue, 14 Jan 2020 01:55:09 +0000 (UTC) Subject: Re: [PATCH] m68k: Implement copy_thread_tls() To: Geert Uytterhoeven Cc: Amanieu d'Antras , Christian Brauner , Kars de Jong , Al Viro , linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org, linux-next@vger.kernel.org References: <20200113103040.23661-1-geert@linux-m68k.org> From: Greg Ungerer Message-ID: Date: Tue, 14 Jan 2020 11:55:06 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20200113103040.23661-1-geert@linux-m68k.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Geert, On 13/1/20 8:30 pm, Geert Uytterhoeven wrote: > This is required for clone3(), which passes the TLS value through a > struct rather than a register. > > As do_fork() is only available if CONFIG_HAVE_COPY_THREAD_TLS is set, > m68k_clone() must be changed to call _do_fork() directly. > > Signed-off-by: Geert Uytterhoeven Looks good for ColdFire too. I compiled for both MMU and non-MMU targets and no regressions (I did not test clone3() itself though). Acked-by: Greg Ungerer Regards Greg > --- > This is a dependency for the combination of commits > e8bb2a2a1d51511e ("m68k: Wire up clone3() syscall") in m68k/for-next, > dd499f7a7e342702 ("clone3: ensure copy_thread_tls is implemented") in > v5.5-rc6. > --- > arch/m68k/Kconfig | 1 + > arch/m68k/kernel/process.c | 31 ++++++++++++++++++++++--------- > 2 files changed, 23 insertions(+), 9 deletions(-) > > diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig > index 6663f1741798e83f..6ad6cdac74b3dc42 100644 > --- a/arch/m68k/Kconfig > +++ b/arch/m68k/Kconfig > @@ -14,6 +14,7 @@ config M68K > select HAVE_AOUT if MMU > select HAVE_ASM_MODVERSIONS > select HAVE_DEBUG_BUGVERBOSE > + select HAVE_COPY_THREAD_TLS > select GENERIC_IRQ_SHOW > select GENERIC_ATOMIC64 > select HAVE_UID16 > diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c > index 22e6b8f4f9582aa4..8f0d9140700f09ad 100644 > --- a/arch/m68k/kernel/process.c > +++ b/arch/m68k/kernel/process.c > @@ -108,16 +108,28 @@ void flush_thread(void) > * on top of pt_regs, which means that sys_clone() arguments would be > * buried. We could, of course, copy them, but it's too costly for no > * good reason - generic clone() would have to copy them *again* for > - * do_fork() anyway. So in this case it's actually better to pass pt_regs * > - * and extract arguments for do_fork() from there. Eventually we might > - * go for calling do_fork() directly from the wrapper, but only after we > - * are finished with do_fork() prototype conversion. > + * _do_fork() anyway. So in this case it's actually better to pass pt_regs * > + * and extract arguments for _do_fork() from there. Eventually we might > + * go for calling _do_fork() directly from the wrapper, but only after we > + * are finished with _do_fork() prototype conversion. > */ > asmlinkage int m68k_clone(struct pt_regs *regs) > { > /* regs will be equal to current_pt_regs() */ > - return do_fork(regs->d1, regs->d2, 0, > - (int __user *)regs->d3, (int __user *)regs->d4); > + struct kernel_clone_args args = { > + .flags = regs->d1 & ~CSIGNAL, > + .pidfd = (int __user *)regs->d3, > + .child_tid = (int __user *)regs->d4, > + .parent_tid = (int __user *)regs->d3, > + .exit_signal = regs->d1 & CSIGNAL, > + .stack = regs->d2, > + .tls = regs->d5, > + }; > + > + if (!legacy_clone_args_valid(&args)) > + return -EINVAL; > + > + return _do_fork(&args); > } > > /* > @@ -130,8 +142,9 @@ asmlinkage int m68k_clone3(struct pt_regs *regs) > return sys_clone3((struct clone_args __user *)regs->d1, regs->d2); > } > > -int copy_thread(unsigned long clone_flags, unsigned long usp, > - unsigned long arg, struct task_struct *p) > +int copy_thread_tls(unsigned long clone_flags, unsigned long usp, > + unsigned long arg, struct task_struct *p, > + unsigned long tls) > { > struct fork_frame { > struct switch_stack sw; > @@ -166,7 +179,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, > p->thread.usp = usp ?: rdusp(); > > if (clone_flags & CLONE_SETTLS) > - task_thread_info(p)->tp_value = frame->regs.d5; > + task_thread_info(p)->tp_value = tls; > > #ifdef CONFIG_FPU > if (!FPU_IS_EMU) { >