lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJF2gTT90V6gQw12XZEXB1TJXb5QNdXM6qcfXh1yzWzDPExgPQ@mail.gmail.com>
Date:   Tue, 2 Nov 2021 10:07:58 +0800
From:   Guo Ren <guoren@...nel.org>
To:     Palmer Dabbelt <palmerdabbelt@...gle.com>
Cc:     Wei Fu <wefu@...hat.com>, Anup Patel <Anup.Patel@....com>,
        Atish Patra <Atish.Patra@....com>,
        Christoph Müllner <christoph.muellner@...ll.eu>,
        Philipp Tomsich <philipp.tomsich@...ll.eu>,
        Christoph Hellwig <hch@....de>,
        liush <liush@...winnertech.com>,
        Wei Wu (吴伟) <lazyparser@...il.com>,
        Drew Fustini <drew@...gleboard.org>,
        linux-riscv <linux-riscv@...ts.infradead.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        taiten.peng@...onical.com,
        Aniket Ponkshe <aniket.ponkshe@...onical.com>,
        Heinrich Schuchardt <heinrich.schuchardt@...onical.com>,
        Gordan Markus <gordan.markus@...onical.com>,
        Guo Ren <guoren@...ux.alibaba.com>,
        Arnd Bergmann <arnd@...db.de>, Chen-Yu Tsai <wens@...e.org>,
        Maxime Ripard <maxime@...no.tech>,
        Daniel Lustig <dlustig@...dia.com>,
        Greg Favor <gfavor@...tanamicro.com>,
        Andrea Mondelli <andrea.mondelli@...wei.com>,
        Jonathan Behrens <behrensj@....edu>,
        "Xinhaoqu (Freddie)" <xinhaoqu@...wei.com>,
        Bill Huffman <huffman@...ence.com>,
        Nick Kossifidis <mick@....forth.gr>,
        Allen Baum <allen.baum@...erantotech.com>,
        Josh Scheid <jscheid@...tanamicro.com>,
        Richard Trauben <rtrauben@...il.com>
Subject: Re: [RESEND PATCH V3 0/2] riscv: add RISC-V Svpbmt Standard Extension supports

On Wed, Oct 27, 2021 at 8:12 AM Palmer Dabbelt <palmerdabbelt@...gle.com> wrote:
>
> On Sun, 24 Oct 2021 21:06:05 PDT (-0700), wefu@...hat.com wrote:
> > From: Fu Wei <wefu@...hat.com>
> >
> > 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 as
> > the MT (aka MemType) field. This field specifies one of three memory types
> > as shown in the following table:
> > 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(-)



-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ