Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1861035pxk; Sat, 5 Sep 2020 00:15:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+7WS81Kf3kKVLdQQHii+ma5XVapx1LHOOcAkVGMhJcv8OLhE2tffC8vuS7n1t05sY5rit X-Received: by 2002:a17:907:213b:: with SMTP id qo27mr10939401ejb.441.1599290145014; Sat, 05 Sep 2020 00:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599290145; cv=none; d=google.com; s=arc-20160816; b=H50DZY+F6VtdVn3M1l6ehpnRaHwyXKb9akPEaBPoNLjsihSaipLDy8QfvRFQZEeDdo D42NgVZjvlcq81CJ+fhCFxBMCPs2oSZLaa8I1ZEcgLnmu/Kpdo1tE/nF+Z9XVozysfYR PNwFG5TUXtUJhhLeeUN2rO12sLy0GBzsl8K6NlV0fGiC26s8lmg52fBawARsIhF1Ccur pUMoOaTHErqJvroFhMYdtK7I3yRdU5lQoAe8VEseKotVkmTTm5Qq8BD0b3kc3c8b5kY6 vTQUUCOnTOIXmMVYAZYX1p2rgXqFMmj0hfYfHqbERZIhXZm5VJXLHTtTyMtIR7uPFE2P auUA== 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=0RLp8Zmtv3DN4nqF9TKL/nPHcys1RNxeLHS/JxrF8GE=; b=aWQaMxFK+rRLw1SQAFaZiZMTMdZv6gkpTNhICTqT1BrkkD3syQBr6AauVTRDCk6Sen OcJtQ4hEJoRzc7/5pqMNuH7TYBO8n8CDP3aKZD5mhwDPF5xxDl0pjdRTT8JMUGuQ6D1X 0HflpGdZ8+KGfPMVYMNfUgzFqG2M80EQY67ZbqbrDvX2SontPaKWSNuT8S/oQCnvX7I1 VlsnHO8OFpue3HbSr/RTuSXW+4naBZRdNBAgFOoHkmuWx2ygQugkpk0mux5HXolWb1FV XANvqEqU/8bhizrSdSghHs/GH+QXY73Nd5Ofkx2oERGdlQ2kklW+etX851NzRg36J+5F kOCg== 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 t26si5311069ejb.695.2020.09.05.00.15.20; Sat, 05 Sep 2020 00:15:45 -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 S1726381AbgIEHOw (ORCPT + 99 others); Sat, 5 Sep 2020 03:14:52 -0400 Received: from verein.lst.de ([213.95.11.211]:43936 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725818AbgIEHOu (ORCPT ); Sat, 5 Sep 2020 03:14:50 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id F1F6568BEB; Sat, 5 Sep 2020 09:14:47 +0200 (CEST) Date: Sat, 5 Sep 2020 09:14:47 +0200 From: Christoph Hellwig To: Arnd Bergmann Cc: Christoph Hellwig , Paul Walmsley , Palmer Dabbelt , Alexander Viro , linux-riscv , "linux-kernel@vger.kernel.org" , linux-arch Subject: Re: [PATCH 3/8] asm-generic: fix unaligned access hamdling in raw_copy_{from,to}_user Message-ID: <20200905071447.GA13228@lst.de> References: <20200904165216.1799796-1-hch@lst.de> <20200904165216.1799796-4-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 04, 2020 at 08:04:34PM +0200, Arnd Bergmann wrote: > > if (__builtin_constant_p(n)) { > > switch(n) { > > case 1: > > - *(u8 *)to = *(u8 __force *)from; > > + *(u8 *)to = get_unaligned((u8 __force *)from); > > return 0; > > case 2: > > - *(u16 *)to = *(u16 __force *)from; > > + *(u16 *)to = get_unaligned((u16 __force *)from); > > return 0; > > The change look correct and necessary, but I wonder if this could be done > in a way that is a little easier on the compiler than the nested switch/case. > > If I see it right, __put_user() and __get_user() can probably > be reduced to a plain put_unaligned() and get_unaligned() here, > which would simplify these a lot. > > In turn it seems that the generic raw_copy_to_user() can just be the > a plain memcpy(), IIRC the optimization for small sizes should also > be done by modern compilers whenever they can. Sure, I can look into that.