From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CADDC433E0 for ; Mon, 1 Feb 2021 16:58:58 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0CAD464EA1 for ; Mon, 1 Feb 2021 16:58:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0CAD464EA1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codefail.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DTvKp6TwdzDrWk for ; Tue, 2 Feb 2021 03:58:54 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=codefail.de (client-ip=68.65.122.19; helo=mta-09-3.privateemail.com; envelope-from=cmr@codefail.de; receiver=) Received: from MTA-09-3.privateemail.com (mta-09-3.privateemail.com [68.65.122.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4DTvHd0G59zDrRW for ; Tue, 2 Feb 2021 03:57:00 +1100 (AEDT) Received: from MTA-09.privateemail.com (localhost [127.0.0.1]) by MTA-09.privateemail.com (Postfix) with ESMTP id 634E5600A0; Mon, 1 Feb 2021 11:56:57 -0500 (EST) Received: from localhost (unknown [10.20.151.204]) by MTA-09.privateemail.com (Postfix) with ESMTPA id 2963360091; Mon, 1 Feb 2021 16:56:57 +0000 (UTC) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 To: "David Laight" , "linuxppc-dev@lists.ozlabs.org" Subject: RE: [PATCH v4 02/10] powerpc/signal: Add unsafe_copy_{vsx, fpr}_from_user() From: "Christopher M. Riedl" Date: Mon, 01 Feb 2021 10:55:23 -0600 Message-Id: In-Reply-To: <0433d40adacc47a3a27bc8bc35e076e3@AcuMS.aculab.com> X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon Feb 1, 2021 at 10:15 AM CST, David Laight wrote: > From: Christopher M. Riedl > > Sent: 01 February 2021 15:56 > >=20 > > On Thu Jan 28, 2021 at 4:38 AM CST, David Laight wrote: > > > From: Christopher M. Riedl > > > > Sent: 28 January 2021 04:04 > > > > > > > > Reuse the "safe" implementation from signal.c except for calling > > > > unsafe_copy_from_user() to copy into a local buffer. > > > > > > > > Signed-off-by: Christopher M. Riedl > > > > --- > > > > arch/powerpc/kernel/signal.h | 33 ++++++++++++++++++++++++++++++++= + > > > > 1 file changed, 33 insertions(+) > > > > > > > > diff --git a/arch/powerpc/kernel/signal.h b/arch/powerpc/kernel/sig= nal.h > > > > index 2559a681536e..c18402d625f1 100644 > > > > --- a/arch/powerpc/kernel/signal.h > > > > +++ b/arch/powerpc/kernel/signal.h > > > > @@ -53,6 +53,33 @@ unsigned long copy_ckfpr_from_user(struct task_s= truct *task, void __user *from); > > > > &buf[i], label);\ > > > > } while (0) > > > > > > > > +#define unsafe_copy_fpr_from_user(task, from, label) do { \ > > > > + struct task_struct *__t =3D task; \ > > > > + u64 __user *__f =3D (u64 __user *)from; \ > > > > + u64 buf[ELF_NFPREG]; \ > > > > > > How big is that buffer? > > > Isn't is likely to be reasonably large compared to a reasonable > > > kernel stack frame. > > > Especially since this isn't even a leaf function. > > > > >=20 > > I think Christophe answered this - I don't really have an opinion eithe= r > > way. What would be a 'reasonable' kernel stack frame for reference? > > Zero :-) > Hehe good point! > >=20 > > > > + int i; \ > > > > + \ > > > > + unsafe_copy_from_user(buf, __f, ELF_NFPREG * sizeof(double), \ > > > > + label); \ > > > > + for (i =3D 0; i < ELF_NFPREG - 1; i++) \ > > > > + __t->thread.TS_FPR(i) =3D buf[i]; \ > > > > + __t->thread.fp_state.fpscr =3D buf[i]; \ > > > > +} while (0) > > On further reflection, since you immediately loop through the buffer > why not just use user_access_begin() and unsafe_get_user() in the loop. Christophe had suggested this a few revisions ago as well. When I tried this approach, the signal handling performance took a pretty big hit: https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-October/219351.html I included some numbers on v3 as well but decided to drop the approach altogether for this one since it just didn't seem worth the hit. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, > MK1 1PT, UK > Registration No: 1397386 (Wales)