Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3699650pxb; Mon, 1 Nov 2021 19:09:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsV0gugjKfQytjqHxVzm8nAPBD09GqXeTxuaWCdv8XdyPWy7jA8hMOEWMnnVTA9oox+Bij X-Received: by 2002:a02:cb58:: with SMTP id k24mr25450511jap.59.1635818997600; Mon, 01 Nov 2021 19:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635818997; cv=none; d=google.com; s=arc-20160816; b=o3cqs7WdfQDcMzNvWAeMxB+1Zk9jfAHslLqfKKK97NgfOV3MwUSMP27a2y+kyYcu6w YOkeeY8oRD7aokB/ULDU+RwkTzhb3/7mrOF9Lpfl5inllfxVlNSl6IlSBJ3xmz9pfab5 CmwL/BpsmZsh7SiLAwZ9CbwgyvcHyKfEIOWnaf94Q+mMsrY11hkxRhPVyzQjG5N/XGly dEOcsuwUaJNXISko8Ni0pomd4EJchR8kAiq+Mi6TTMZtFPgVIlrAu4NvzhS8s9FGoi9E HOMIf7Edj/1ffgR4PUWzvlkThfFmQUKdikXshsz+BFtbI0VIlhYGXUliTUUN8d1gQNRP h8JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=5Jb37zs6MrTOMxZtlnUzZZ9EyJjxnGjanWZ/z/InNxo=; b=lCHCarsOE66tajzUOXx5g1Ypc/Jwm5d4NzvxsNSXmIhFnSSsikE62fM0VjVVojLIH0 iDSUXGCgMMIYk+wBxdM3efOe3FPEsc+5Hv6gKzUTKKnNh/aZWAOWrgI+f52yQymu04Ph UXkDzjAvHjunzebsAXFlZ6jJFMJkd2rN5un+Cgstzn8+QHmCIYauWwDIxjyyiFjnzLak scEKKtizYExibcqrmScHo4enCQNnFxUyfbELIZ28lJZSdgneipBZ2yX7EQyB5/BwI1/c EJIV+UseM3r1G6y3Jj2/bjtneCODdnChrPJ6300F8NPxkhn0KhBl2FEHFFl+LBltO6xt rO9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BVcXlIsx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k12si26468595jav.102.2021.11.01.19.09.44; Mon, 01 Nov 2021 19:09:57 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BVcXlIsx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229510AbhKBCKv (ORCPT + 99 others); Mon, 1 Nov 2021 22:10:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:35498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbhKBCKp (ORCPT ); Mon, 1 Nov 2021 22:10:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F104D60F36 for ; Tue, 2 Nov 2021 02:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635818891; bh=o4Y1/O2KjncLfMawRxMHVVrBmttatJPx2bTgoqvhEa8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=BVcXlIsxpWmtMby5PshVIQ9MhUMSB+iXvnq+jLMiEXOEDKvCyQAnbs+evASu5L1Ja qa+Jpyh3lZpzjSTdH0FKLrncEZpmB8vMHPu3jvBPjIMr+SDOzEq0n7VifVLtg3XFT1 sxMR7QvK3RYL3oBdxeNhvww/7vtn9jeB/j915Jbh8O5TMqhtlLuSqzc8KLzKyY23t6 2Ek1buUNVEpIfack5JavW1txasMZySdbo5ig+zK3+Obw0Z/Xs2wW7/J0W5wdPVXVtr UrMGQKh2ClIcA1BkZpwq4biyWrhLj62VwMnXLd8J1VusWfPzf/IkjG9pSUiW5kFDsc wCSMUOmm75vZw== Received: by mail-ua1-f41.google.com with SMTP id b3so11537066uam.1 for ; Mon, 01 Nov 2021 19:08:10 -0700 (PDT) X-Gm-Message-State: AOAM530zJNnF3Hy/4vTp//6oprV5D7OPcCy3jlmTcKmpeV/293s/vLMy BNTt9wKn4PZOsMpUbeUk8FiSsRfJDCo3yF9uCRA= X-Received: by 2002:a05:6102:510d:: with SMTP id bm13mr14823367vsb.28.1635818889988; Mon, 01 Nov 2021 19:08:09 -0700 (PDT) MIME-Version: 1.0 References: <20211025040607.92786-1-wefu@redhat.com> In-Reply-To: From: Guo Ren Date: Tue, 2 Nov 2021 10:07:58 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RESEND PATCH V3 0/2] riscv: add RISC-V Svpbmt Standard Extension supports To: Palmer Dabbelt Cc: Wei Fu , Anup Patel , Atish Patra , =?UTF-8?Q?Christoph_M=C3=BCllner?= , Philipp Tomsich , Christoph Hellwig , liush , =?UTF-8?B?V2VpIFd1ICjlkLTkvJ8p?= , Drew Fustini , linux-riscv , Linux Kernel Mailing List , taiten.peng@canonical.com, Aniket Ponkshe , Heinrich Schuchardt , Gordan Markus , Guo Ren , Arnd Bergmann , Chen-Yu Tsai , Maxime Ripard , Daniel Lustig , Greg Favor , Andrea Mondelli , Jonathan Behrens , "Xinhaoqu (Freddie)" , Bill Huffman , Nick Kossifidis , Allen Baum , Josh Scheid , Richard Trauben Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 27, 2021 at 8:12 AM Palmer Dabbelt w= rote: > > On Sun, 24 Oct 2021 21:06:05 PDT (-0700), wefu@redhat.com wrote: > > From: Fu Wei > > > > This patch follows the RISC-V standard Svpbmt extension in > > privilege spec to solve the non-coherent SOC DMA synchronization > > issues. > > > > The svpbmt PTE format: > > | 63 | 62-61 | 60-8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 > > N MT RSW D A G U X W R V > > ^ > > > > Of the Reserved bits [63:54] in a leaf PTE, the bits [62:61] are used a= s > > the MT (aka MemType) field. This field specifies one of three memory ty= pes > > as shown in the following table=EF=BC=9A > > MemType RISC-V Description > > ---------- ------------------------------------------------ > > 00 - PMA Normal Cacheable, No change to implied PMA memory type > > 01 - NC Non-cacheable, idempotent, weakly-ordered Main Memory > > 10 - IO Non-cacheable, non-idempotent, strongly-ordered I/O memory > > 11 - Rsvd Reserved for future standard use > > Do you have a pointer to the spec that contains these? I'm specifically > worried about these page-based attributes being elided when paging is > off (ie, M-mode), which has caused issues in systems I've worked with in > the past. Don't worry about that, I've compiled the Linux with the patch and below modification in k210_nommu_defconfig. Passed diff --git a/arch/riscv/include/asm/pgtable-bits.h b/arch/riscv/include/asm/pgtable-bits.h index 3b38fe14f169..b4bb41337fdc 100644 --- a/arch/riscv/include/asm/pgtable-bits.h +++ b/arch/riscv/include/asm/pgtable-bits.h @@ -25,7 +25,7 @@ #define _PAGE_SOFT (1 << 8) /* Reserved for software */ #ifndef __ASSEMBLY__ -#ifdef CONFIG_64BIT +#if defined(CONFIG_64BIT) && defined(CONFIG_MMU) /* * rv64 PTE format: * | 63 | 62 61 | 60 54 | 53 10 | 9 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index d198eabe55d4..58639dfe5917 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -856,7 +856,7 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, } #endif -#ifdef CONFIG_64BIT +#if defined(CONFIG_64BIT) && defined(CONFIG_MMU) struct __riscv_svpbmt_struct __riscv_svpbmt __ro_after_init; EXPORT_SYMBOL(__riscv_svpbmt); So, I don't think the patch would affect M-mode nommu Linux. To separate MMU & no-MMU clearly, I suggest fuwei add #if defined(CONFIG_64BIT) && defined(CONFIG_MMU) > I'm assuming there's something related to this in the specs, > but I'm worried we'll need some sort of ack from M-mode that it's been > setup to work that way. One could imagine an MPRV-like approach > working, but I don't see enough in the old specs and I'm having trouble > figuring out where the canonical version of this lives. > > > The standard protection_map[] needn't be modified because the "PMA" > > type keeps the highest bits zero. > > And the whole modification is limited in the arch/riscv/* and using > > a global variable(__riscv_svpbmt) as _PAGE_DMA_MASK/IO/NC for > > pgprot_noncached (&writecombine) in pgtable.h. > > We also add _PAGE_CHG_MASK to filter PFN than before. > > > > Enable it in devicetree - (Add "mmu-supports-svpbmt" in cpu node) > > - mmu-supports-svpbmt > > Maybe this is enough of an ack, but we'll need to have some pretty > specific documentation if that's the case. It's not described that way > in the docs right now, they just talk about CPU support (IMO we could > probe that with a trap, but I'm fine with the DT entry as it's a bit > simpler). > > > Wei Fu (2): > > dt-bindings: riscv: add mmu-supports-svpbmt for Svpbmt > > riscv: add RISC-V Svpbmt extension supports > > > > .../devicetree/bindings/riscv/cpus.yaml | 5 +++ > > arch/riscv/include/asm/fixmap.h | 2 +- > > arch/riscv/include/asm/pgtable-64.h | 8 ++-- > > arch/riscv/include/asm/pgtable-bits.h | 41 ++++++++++++++++++- > > arch/riscv/include/asm/pgtable.h | 39 ++++++++++++++---- > > arch/riscv/kernel/cpufeature.c | 32 +++++++++++++++ > > arch/riscv/mm/init.c | 5 +++ > > 7 files changed, 117 insertions(+), 15 deletions(-) --=20 Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/