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=-7.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 7322BC32753 for ; Wed, 14 Aug 2019 17:03:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 477CE21744 for ; Wed, 14 Aug 2019 17:03:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="H5s/9+rY"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="KqQ8A8lx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 477CE21744 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:Message-ID: In-Reply-To:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6WO1Grhjsq+yfu+/HHp6+SeU3GKoVJBcJSnbo+awq18=; b=H5s/9+rYOZAySc DZHDzWsIRkceORxN4UyP5Lae0+plGl0qlbUZobq85ITeW9+XF1T33cDgch2+g1JGSRW95tN8+j6Oz +SrMXNMCq3Gr0YY6lgAT+o6CKKi2g0OcQBtI/t2MfOEc1Pq5er9bEHuGmaDiuByzDZt6MeWDmtDCl m4M+IormqxM2zFeG3rZ5UcJpiJNEkeFu8fvrZbYOWC3Tc36HKO5KHKk+lmOofoPz19s7vET8C/d5x g7suo0ELDtZtSblBMDFCzfCCa2lDFJ59aIcSBU1BNz7GznxHeCufXUFd/Ze9xx4B/66WR5wn/eL+/ Z78FnsoQtrYGR5O8Lt1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hxwgh-0004xw-MO; Wed, 14 Aug 2019 17:03:51 +0000 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hxwga-0004w5-NG for linux-riscv@lists.infradead.org; Wed, 14 Aug 2019 17:03:50 +0000 Received: by mail-ot1-x344.google.com with SMTP id r20so34203221ota.5 for ; Wed, 14 Aug 2019 10:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=VPLCSa9Mg0xoV570EQzBhdB+yL6SWWFzgzVz0WEOMmM=; b=KqQ8A8lxk8/sEERoY23MTYdhjwaFVgQfEetYHnne/7JmYwUyN+151g95rH1mlxfml5 31rwg7xFPxqPpRlOEIZRo6FoT0Oh2eRFEQgERFYG9hlqhD4JlK0tpU8tIDQmNCk+6Lqo os8ExkAoMPjLYxqvDdqguUtEfAxcBBy48JH1OZ2ID4DtVMh22mS81YF6JJWZMQBgSkxD 0c3TB5HfPVlqOiUP4kNNXvn8O3diQuhrVkaoT1a9TMX64zBLyfKtwRmSM+EHJHUkEDyn esWz3u/ULTE2iR3PJkoGCPG2/WGS2mNeZj0TA43vIQ9dVvXLhWM71IB0K33UEgneKYYz imGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=VPLCSa9Mg0xoV570EQzBhdB+yL6SWWFzgzVz0WEOMmM=; b=qPFi8nzEDcZj6t2IQ8Ns/Gv48nudwW6di831UrJ10oxhQ2NGilS0NLsPqNHaZQI7ZU 8r9TahWU1XidxHtM7vWG4L+42VPSFNrupY/wH6QWu4SG3GCDwnBvT6PXETT0tWdilOMU k5ZsVKamOUfKqbMabNGyZYVvp1No7gBksZrI8Llq+Xehtl8eeHFmf79NaaH9mgDeV1/R AMUTrkvAYOM9JHxPwHvPJ5F6IvrgLqAov3S5jDiE1I06TWwLefaEW0kSsBl7zeQomHCj lMxOvZ44zEYlvnbFYdGjZjK3LcygDLvt1wBgl0ALe+G+dQlN7f1HgLA25hpfDRdsEKsc 1++A== X-Gm-Message-State: APjAAAVJDjgfMChlicr8Qwm7ontP6QYXmLY0ungj9JGwfXM9ISpX770h HYKvAF5KBKRC41pPDD4CO9xypA== X-Google-Smtp-Source: APXvYqyqCQzLpuS6BURi8/0FnChrnzuBBO/kh4mQ+4revHO/BtVwDmErIC+VTD1JGTfiQkttw2qk/g== X-Received: by 2002:a6b:8f82:: with SMTP id r124mr1023322iod.6.1565802220297; Wed, 14 Aug 2019 10:03:40 -0700 (PDT) Received: from localhost (c-73-95-159-87.hsd1.co.comcast.net. [73.95.159.87]) by smtp.gmail.com with ESMTPSA id x23sm428250iob.36.2019.08.14.10.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2019 10:03:39 -0700 (PDT) Date: Wed, 14 Aug 2019 10:03:39 -0700 (PDT) From: Paul Walmsley X-X-Sender: paulw@viisi.sifive.com To: Nick Hu Subject: Re: [PATCH 1/2] riscv: Add memmove string operation. In-Reply-To: <20190814032732.GA8989@andestech.com> Message-ID: References: <20190814032732.GA8989@andestech.com> User-Agent: Alpine 2.21.9999 (DEB 301 2018-08-15) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190814_100346_453197_C2CC1CCA X-CRM114-Status: GOOD ( 22.54 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?ISO-2022-JP?Q?=1B$BN%=3F&=1B=28JZong_Zong-Xian_Li=28=1B$BM{=3D!7{?= =?ISO-2022-JP?Q?=1B=28J=29?= , "aou@eecs.berkeley.edu" , =?ISO-2022-JP?Q?Alan_Quey-Liang_Kao=28=1B$B9b3!NI=1B=28J=29?= , Atish Patra , Greg KH , Palmer Dabbelt , "linux-kernel@vger.kernel.org" , "kasan-dev@googlegroups.com" , Christoph Hellwig , "alexios.zavras@intel.com" , Anup Patel , "glider@google.com" , "green.hu@gmail.com" , "aryabinin@virtuozzo.com" , "tglx@linutronix.de" , "deanbo422@gmail.com" , "linux-riscv@lists.infradead.org" , "dvyukov@google.com" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org Hi Nick, On Wed, 14 Aug 2019, Nick Hu wrote: > 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: > > > > > > 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? > > 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. Thanks for the explanation. What do you think about Palmer's idea to define a generic C set of KASAN string operations, derived from the newlib code? - Paul _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv