Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp267973ybl; Tue, 13 Aug 2019 20:29:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyjOApl2xmtGRb2pHxCJ4bWJM6w0BSNkwnDFeIFV2Mbb+SUHLYgCI+tJybsbPD3bprFXJQ X-Received: by 2002:a17:902:1027:: with SMTP id b36mr29013304pla.203.1565753398170; Tue, 13 Aug 2019 20:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565753398; cv=none; d=google.com; s=arc-20160816; b=um+pqA1tXW1VptThHarcw6lEF0mcFvBQHwvnQXAqqddlrs2PRqLfOkmyfExutsNNeg yFyBEFrwb7Ba+c3CAf4xH7UTkrsG4pk7tPJa6RUoP1Q0P+kEUy/o9tdfuwusUxGzfZ33 1nQohM26xMFaO5PAWyLoFxP6C5ZOmw84mzxiIwft/O6d2wwqriswyO9YYhLhyZJKLG+x z7N3yvwoPZHfnfTQ75hjTWJh6jFcraxitZKpP6RxRC+eu6e9iW/xCw6x1vCTfc0TZuTa Xb5E/qbgjoMOzhHvfP6Fxagcth+AP4EmoVE51veUIv+fFSOPj94ppPvu6uv8xHzLgyR5 kwnA== 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=XrgLkjrPICHwgApgT3/klkUJR7obvhDhJsCZqlvVLQI=; b=avhbSb5igu1GvsCr60zlAGDMNm+CsOnKj7rpeleNjx3r0zd8cltsFoRHGlIAhncu76 rWL6G7sPkwezrr3U/oSWcmXzr53nmfpBAR7XdPC0+vw5G5m1ch9f/FJcG+sPVjunqVrl c7NaE9OWcGP1mGyNuF9fWDP1SGYMdznlUE2E/O+IlkSe5wagjWrhZAYbzxH4je1GsDuG 59hsLnNp2xYIIHu/80nWCtG/L+bTBwVB4Y4yK/hdVOCdzOUx5SSjD66/Pf++MMhcv9Az SCWXi3rMhToLNbtIRaIF/D7pdyh1bQ3VBdDtNzYMUi7R1UKGOMVY3b41E4vERDof7N1i LnRw== 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 y12si69612193pgg.585.2019.08.13.20.29.39; Tue, 13 Aug 2019 20:29:58 -0700 (PDT) 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 S1727221AbfHND3F (ORCPT + 99 others); Tue, 13 Aug 2019 23:29:05 -0400 Received: from 59-120-53-16.HINET-IP.hinet.net ([59.120.53.16]:36836 "EHLO ATCSQR.andestech.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726797AbfHND3F (ORCPT ); Tue, 13 Aug 2019 23:29:05 -0400 Received: from mail.andestech.com (atcpcs16.andestech.com [10.0.1.222]) by ATCSQR.andestech.com with ESMTP id x7E3G38F041472; Wed, 14 Aug 2019 11:16:03 +0800 (GMT-8) (envelope-from nickhu@andestech.com) Received: from andestech.com (10.0.15.65) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.123.3; Wed, 14 Aug 2019 11:27:32 +0800 Date: Wed, 14 Aug 2019 11:27:33 +0800 From: Nick Hu To: Paul Walmsley CC: Palmer Dabbelt , Christoph Hellwig , Alan Quey-Liang =?utf-8?B?S2FvKOmrmOmtgeiJryk=?= , "aou@eecs.berkeley.edu" , "green.hu@gmail.com" , "deanbo422@gmail.com" , "tglx@linutronix.de" , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "aryabinin@virtuozzo.com" , "glider@google.com" , "dvyukov@google.com" , Anup Patel , Greg KH , "alexios.zavras@intel.com" , Atish Patra , =?utf-8?B?6Zui6IG3Wm9uZyBab25nLVhpYW4gTGko5p2O5a6X5oayKQ==?= , "kasan-dev@googlegroups.com" Subject: Re: [PATCH 1/2] riscv: Add memmove string operation. Message-ID: <20190814032732.GA8989@andestech.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [10.0.15.65] X-DNSRBL: X-MAIL: ATCSQR.andestech.com x7E3G38F041472 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 14, 2019 at 10:22:15AM +0800, Paul Walmsley wrote: > On Tue, 13 Aug 2019, Palmer Dabbelt wrote: > > > On Mon, 12 Aug 2019 08:04:46 PDT (-0700), Christoph Hellwig wrote: > > > On Wed, Aug 07, 2019 at 03:19:14PM +0800, Nick Hu wrote: > > > > There are some features which need this string operation for compilation, > > > > like KASAN. So the purpose of this porting is for the features like KASAN > > > > which cannot be compiled without it. > > > > > > > > KASAN's string operations would replace the original string operations and > > > > call for the architecture defined string operations. Since we don't have > > > > this in current kernel, this patch provides the implementation. > > > > > > > > This porting refers to the 'arch/nds32/lib/memmove.S'. > > > > > > This looks sensible to me, although my stringop asm is rather rusty, > > > so just an ack and not a real review-by: > > > > > > Acked-by: Christoph Hellwig > > > > FWIW, we just write this in C everywhere else and rely on the compiler to > > unroll the loops. I always prefer C to assembly when possible, so I'd prefer > > if we just adopt the string code from newlib. We have a RISC-V-specific > > memcpy in there, but just use the generic memmove. > > > > Maybe the best bet here would be to adopt the newlib memcpy/memmove as generic > > Linux functions? They're both in C so they should be fine, and they both look > > faster than what's in lib/string.c. Then everyone would benefit and we don't > > need this tricky RISC-V assembly. Also, from the look of it the newlib code > > is faster because the inner loop is unrolled. > > There's a generic memmove implementation in the kernel already: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/string.h#n362 > > Nick, could you tell us more about why the generic memmove() isn't > suitable? > > > - Paul Hi Paul, KASAN has its own string operations(memcpy/memmove/memset) because it needs to hook some code to check memory region. It would undefined the original string operations and called the string operations with the prefix '__'. But the generic string operations didn't declare with the prefix. Other archs with KASAN support like arm64 and xtensa all have their own string operations and defined with the prefix. Nick