Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4154566pxf; Tue, 30 Mar 2021 00:04:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaMokoIDs2mEu6QYUpcUYGEGqm6hKKnpB6d+RdOLzOHcXjynAXSlb2fzhrzMRtKR1nOutY X-Received: by 2002:a05:6402:270c:: with SMTP id y12mr32437787edd.284.1617087883116; Tue, 30 Mar 2021 00:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617087883; cv=none; d=google.com; s=arc-20160816; b=FdycB5FG5BXoHGPBDf2XI1p5dAojgjsWFN98KZlm27rnJS3AtYjSXiwxPbnlY9XHOF h7XV8Uzy0nLMWFoKyvs486AD+6dkxPEGrK1g3wOVpWZqL0cp04dc1pQNYXTGPwI5BZq7 7FVptjtW4/pVsGaP8PDPvYjffGm4glGBCrbTtRZ+NvliP0+sbm7pMgHraJEay5tcC0f9 StGElP7NNVdcOLGlNachRa2O4ZFAjJb7Me/36gSRYj86w5E+RTvmpDdOReK8RUHPqfse N8W3kxwaCT42RfQHEx94lKB+adLkmNs/8Z+VQi7u49b2QGBIkmZQgUBsbFt0f+mQ+y6h ds8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=f0kusnESJMcsGVUc6BGJAg8g0vi8Ub1FaVpSpURqZFs=; b=l7Ez/Xj93kcCDnigJUOnFM5RBb0jOKLuMWHNHB9zLqCRoryhhr0MKElB1JZXFpdIeV 3tMdKuMcLkdnxXEzLduBrVbaUVLR/PiMPHkYTwRWHA2sCAAcd5lQ9lA4wiJxaWdiHODc Dp0Al8kxEEIRyVBY+Ri1Sj9e3zuGeyy2/E43b8o19yKTzfAoJfMsdvaCAh5th6K6VSlf EEIQk113+NjTG8y2JUKvv/nWvv+2Hgaif1Sh+RF6iynjL4Xef5YR5WYGmTKkW27JPq2M 0HYtBdfws5aTqRoHNse/CLu5bZvrLme3O7I9e8yNPwokIiv7k2ImF15iTNLXZlGbpOyQ aiNg== 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 l23si14174645ejq.537.2021.03.30.00.04.20; Tue, 30 Mar 2021 00:04:43 -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 S230248AbhC3HDP (ORCPT + 99 others); Tue, 30 Mar 2021 03:03:15 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:45747 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbhC3HCz (ORCPT ); Tue, 30 Mar 2021 03:02:55 -0400 X-Originating-IP: 2.7.49.219 Received: from [192.168.1.12] (lfbn-lyo-1-457-219.w2-7.abo.wanadoo.fr [2.7.49.219]) (Authenticated sender: alex@ghiti.fr) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id C643820002; Tue, 30 Mar 2021 07:02:50 +0000 (UTC) Subject: Re: [PATCH] implement flush_cache_vmap and flush_cache_vunmap for RISC-V To: Jiuyang Liu Cc: Andrew Waterman , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Morton , Geert Uytterhoeven , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <20210329015510.44110-1-liu@jiuyang.me> From: Alex Ghiti Message-ID: <9749165b-32d4-94a2-7c8a-e219fdf1b102@ghiti.fr> Date: Tue, 30 Mar 2021 03:02:50 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <20210329015510.44110-1-liu@jiuyang.me> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jiuyang, Le 3/28/21 ? 9:55 PM, Jiuyang Liu a ?crit?: > This patch implements flush_cache_vmap and flush_cache_vunmap for > RISC-V, since these functions might modify PTE. Without this patch, > SFENCE.VMA won't be added to related codes, which might introduce a bug > in some out-of-order micro-architecture implementations. > > Signed-off-by: Jiuyang Liu > --- > arch/riscv/include/asm/cacheflush.h | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h > index 23ff70350992..4adf25248c43 100644 > --- a/arch/riscv/include/asm/cacheflush.h > +++ b/arch/riscv/include/asm/cacheflush.h > @@ -8,6 +8,14 @@ > > #include > > +/* > + * flush_cache_vmap and flush_cache_vunmap might modify PTE, needs SFENCE.VMA. "might modify PTE" is not entirely true I think, this is what happens before using this function that might modify PTE, those functions ensure those modifications are made visible. > + * - flush_cache_vmap is invoked after map_kernel_range() has installed the page table entries. > + * - flush_cache_vunmap is invoked before unmap_kernel_range() deletes the page table entries > + */ > +#define flush_cache_vmap(start, end) flush_tlb_all() > +#define flush_cache_vunmap(start, end) flush_tlb_all() > + > static inline void local_flush_icache_all(void) > { > asm volatile ("fence.i" ::: "memory"); > FWIW, you can add: Reviewed-by: Alexandre Ghiti Thanks, Alex