Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp148947ybg; Sun, 31 May 2020 20:05:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx54/CkyrCjSpcgcgusYfKK2166s8SlLQVwV5Ttn8kIrcBAK+w8Q5hldIicMhp4SYGfGS2P X-Received: by 2002:a17:906:ae81:: with SMTP id md1mr7639956ejb.128.1590980725291; Sun, 31 May 2020 20:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590980725; cv=none; d=google.com; s=arc-20160816; b=YRYXtwjcc5ZdXJkPXt9WNYq+Q/1QS0bajNLiDfsXOOL9isokQ5OMJQyzw/e7kJAubI 69fVkjICxVsxoE5y954xCVm8dSDgPSOH9Js/6hVDhdfA3wVkexrWlUaPapPe2UM3p7nL Bvbh+F/Q8AxPfh//0+oVT7k8CtbpufXz8kSU2BgCTXgLPbxRrv+PjHZxJoqs/5RXvk5I gjn9gi5HpGeoWp0bfjFrClIASuX9HYPz9dCdv9e1BRyf6s1YqJkdqvb6DXjaZhdlurC1 CjZaV/K6PECpxXsPmIrLfm1m5+F1pi2OoTLZJeEQp4GKc64Y6Md3oqbysp+aLK+yxf7U nvAg== 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=b62LEnEDV7l2Freg2rzf87Dft803LlcJC6kCk/80fN4=; b=hAE36oMlKH3bc6Hvpoq5ya0b2QAtC5G+OzVQ0lKhn8fWOVakjSZlVgIzABEaFAhsyo E8Dxeozyym/Pofwcfhnjvhv26DNtFArMYSFSMoLSIRiqGGICQv6fkj/c5Ol4U2/UCiVP fPAHpSGXPL8mZNAZstJ7kFZpDKx4wMi3nwBU4JW39JFFGaugQGkjQD3Q+pUQF9wpK3WT wM4J7HfTCY00HM6/3K+sUG3zrRjPWc5m+vU9zkjOea0xegZB6/GbcAZQVOGzyIWwQlDc vgWLT0FTbwxDFVh5ryCZr01R1z4z7gwPbSEHIq8uu4DR/HSMvJDWp7Fm+Oc9S+lqI5Fg l0xA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l5si4259548ede.477.2020.05.31.20.05.02; Sun, 31 May 2020 20:05:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727119AbgFADDE (ORCPT + 99 others); Sun, 31 May 2020 23:03:04 -0400 Received: from brightrain.aerifal.cx ([216.12.86.13]:36542 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726901AbgFADDE (ORCPT ); Sun, 31 May 2020 23:03:04 -0400 Date: Sun, 31 May 2020 23:03:01 -0400 From: Rich Felker To: Geert Uytterhoeven Cc: John Paul Adrian Glaubitz , Linux-sh list , Yoshinori Sato , Michael Karcher , Linux Kernel Mailing List Subject: Re: [PATCH] sh: Implement __get_user_u64() required for 64-bit get_user() Message-ID: <20200601030300.GT1079@brightrain.aerifal.cx> References: <20200529174540.4189874-1-glaubitz@physik.fu-berlin.de> <20200529174540.4189874-2-glaubitz@physik.fu-berlin.de> <2ad089c1-75cf-0986-c40f-c7f3f8fd6ead@physik.fu-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 31, 2020 at 12:43:11PM +0200, Geert Uytterhoeven wrote: > Hi Adrian, > > On Sun, May 31, 2020 at 11:59 AM John Paul Adrian Glaubitz > wrote: > > On 5/31/20 11:54 AM, John Paul Adrian Glaubitz wrote: > > > On 5/31/20 11:52 AM, Geert Uytterhoeven wrote: > > >> As this is the 64-bit variant, I think this single move should be > > >> replaced by a double move: > > >> > > >> "mov #0,%R1\n\t" \ > > >> "mov #0,%S1\n\t" \ > > >> > > >> Same for the big endian version below. > > >> > > >> Disclaimer: uncompiled, untested, no SH assembler expert. > > > > > > Right, this makes sense. I'll send a new patch shortly. > > > > Hmm, this change is not the case for __put_user_asm() vs. __put_user_u64(). > > But I have to admit, I don't know what the part below "3:\n\t" is for. > > It's part of the exception handling, in case the passed (userspace) pointer > points to an inaccessible address, and triggers an exception. > > For an invalid store, nothing is done, besides returning -EFAULT. > Hence there's no "mov #0, %1\n\t" in the put_user case. > For an invalid load, the data is replaced by zero, and -EFAULT is returned. > > > +__asm__ __volatile__( \ > > + "1:\n\t" \ > > + "mov.l %2,%R1\n\t" \ > > + "mov.l %T2,%S1\n\t" \ > > + "2:\n" \ > > (reordering the two sections for easier explanation) > > > + ".section __ex_table,\"a\"\n\t" \ > > + ".long 1b, 3b\n\t" \ > > In case an exception happens for the instruction at 1b, jump to 3b. > > Note that the m68k version has two entries here: one for each half of > the 64-bit access[*]. > I don't know if that is really needed (and thus SH needs it, too), or if > the exception code handles subsequent instructions automatically. Can I propose a different solution? For archs where there isn't actually any 64-bit load or store instruction, does it make sense to be writing asm just to do two 32-bit loads/stores, especially when this code is not in a hot path? What about just having the 64-bit versions call the corresponding 32-bit version twice? (Ideally this would even be arch-generic and could replace the m68k asm.) It would return EFAULT if either of the 32-bit calls did. Rich