* [PATCH v2 0/3] Add Svadu Extension Support
@ 2023-09-22 8:56 Yong-Xuan Wang
2023-09-22 8:56 ` [PATCH v2 1/3] RISC-V: Detect and Enable " Yong-Xuan Wang
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Yong-Xuan Wang @ 2023-09-22 8:56 UTC (permalink / raw)
To: linux-riscv, kvm-riscv
Cc: greentime.hu, vincent.chen, tjytimi, alex, Yong-Xuan Wang,
Paul Walmsley, Palmer Dabbelt, Albert Ou
Svadu is a RISC-V extension for hardware updating of PTE A/D bits. This
patch set adds support to enable Svadu extension for both host and guest
OS.
---
v2:
- add Co-developed-by: in PATCH1
- use riscv_has_extension_unlikely() to runtime patch the branch in PATCH1
- update dt-binding
Yong-Xuan Wang (3):
RISC-V: Detect and Enable Svadu Extension Support
dt-bindings: riscv: Add Svadu Entry
RISC-V: KVM: Add Svadu Extension Support for Guest/VM
Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
arch/riscv/include/asm/csr.h | 1 +
arch/riscv/include/asm/hwcap.h | 1 +
arch/riscv/include/asm/pgtable.h | 6 ++++++
arch/riscv/include/uapi/asm/kvm.h | 1 +
arch/riscv/kernel/cpufeature.c | 1 +
arch/riscv/kvm/vcpu.c | 3 +++
arch/riscv/kvm/vcpu_onereg.c | 1 +
8 files changed, 20 insertions(+)
--
2.17.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v2 1/3] RISC-V: Detect and Enable Svadu Extension Support 2023-09-22 8:56 [PATCH v2 0/3] Add Svadu Extension Support Yong-Xuan Wang @ 2023-09-22 8:56 ` Yong-Xuan Wang 2023-09-22 9:38 ` Conor Dooley ` (2 more replies) 2023-09-22 8:56 ` [PATCH v2 2/3] dt-bindings: riscv: Add Svadu Entry Yong-Xuan Wang 2023-09-22 8:56 ` [PATCH v2 3/3] RISC-V: KVM: Add Svadu Extension Support for Guest/VM Yong-Xuan Wang 2 siblings, 3 replies; 13+ messages in thread From: Yong-Xuan Wang @ 2023-09-22 8:56 UTC (permalink / raw) To: linux-riscv, kvm-riscv Cc: Heiko Stuebner, Kemeng Shi, Daniel Henrique Barboza, Conor Dooley, Guo Ren, Jisheng Zhang, Qinglin Pan, alex, David Hildenbrand, Matthew Wilcox (Oracle), tjytimi, greentime.hu, wchen, Sergey Matyukevich, Albert Ou, Alexandre Ghiti, Charlie Jenkins, Paul Walmsley, Anup Patel, Yong-Xuan Wang, Rick Edgecombe, linux-kernel, vincent.chen, Evan Green, Palmer Dabbelt, Andrew Morton, Andrew Jones We detect Svadu extension support from DTB and add arch_has_hw_pte_young() to enable optimization in MGLRU and __wp_page_copy_user() if Svadu extension is available. Co-developed-by: Jinyu Tang <tjytimi@163.com> Signed-off-by: Jinyu Tang <tjytimi@163.com> Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> --- arch/riscv/include/asm/csr.h | 1 + arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/include/asm/pgtable.h | 6 ++++++ arch/riscv/kernel/cpufeature.c | 1 + 4 files changed, 9 insertions(+) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 777cb8299551..10648b372a2a 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -194,6 +194,7 @@ /* xENVCFG flags */ #define ENVCFG_STCE (_AC(1, ULL) << 63) #define ENVCFG_PBMTE (_AC(1, ULL) << 62) +#define ENVCFG_HADE (_AC(1, ULL) << 61) #define ENVCFG_CBZE (_AC(1, UL) << 7) #define ENVCFG_CBCFE (_AC(1, UL) << 6) #define ENVCFG_CBIE_SHIFT 4 diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index b7b58258f6c7..1013661d6516 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -58,6 +58,7 @@ #define RISCV_ISA_EXT_ZICSR 40 #define RISCV_ISA_EXT_ZIFENCEI 41 #define RISCV_ISA_EXT_ZIHPM 42 +#define RISCV_ISA_EXT_SVADU 43 #define RISCV_ISA_EXT_MAX 64 diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index b2ba3f79cfe9..028b700cd27b 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -629,6 +629,12 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot) return __pgprot(prot); } +#define arch_has_hw_pte_young arch_has_hw_pte_young +static inline bool arch_has_hw_pte_young(void) +{ + return riscv_has_extension_unlikely(RISCV_ISA_EXT_SVADU); +} + /* * THP functions */ diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 1cfbba65d11a..ead378c04991 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -178,6 +178,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA(ssaia, RISCV_ISA_EXT_SSAIA), __RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF), __RISCV_ISA_EXT_DATA(sstc, RISCV_ISA_EXT_SSTC), + __RISCV_ISA_EXT_DATA(svadu, RISCV_ISA_EXT_SVADU), __RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL), __RISCV_ISA_EXT_DATA(svnapot, RISCV_ISA_EXT_SVNAPOT), __RISCV_ISA_EXT_DATA(svpbmt, RISCV_ISA_EXT_SVPBMT), -- 2.17.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/3] RISC-V: Detect and Enable Svadu Extension Support 2023-09-22 8:56 ` [PATCH v2 1/3] RISC-V: Detect and Enable " Yong-Xuan Wang @ 2023-09-22 9:38 ` Conor Dooley 2023-09-27 7:03 ` Andrew Jones 2023-09-27 7:16 ` Matthew Wilcox 2 siblings, 0 replies; 13+ messages in thread From: Conor Dooley @ 2023-09-22 9:38 UTC (permalink / raw) To: Yong-Xuan Wang Cc: Heiko Stuebner, Kemeng Shi, Daniel Henrique Barboza, Conor Dooley, Guo Ren, Jisheng Zhang, Qinglin Pan, linux-riscv, alex, David Hildenbrand, Matthew Wilcox (Oracle), tjytimi, greentime.hu, wchen, Sergey Matyukevich, Albert Ou, Alexandre Ghiti, Charlie Jenkins, Paul Walmsley, Anup Patel, Rick Edgecombe, linux-kernel, vincent.chen, Evan Green, Palmer Dabbelt, kvm-riscv, Andrew Morton, Andrew Jones [-- Attachment #1.1: Type: text/plain, Size: 477 bytes --] On Fri, Sep 22, 2023 at 08:56:47AM +0000, Yong-Xuan Wang wrote: > We detect Svadu extension support from DTB and add arch_has_hw_pte_young() > to enable optimization in MGLRU and __wp_page_copy_user() if Svadu > extension is available. > > Co-developed-by: Jinyu Tang <tjytimi@163.com> > Signed-off-by: Jinyu Tang <tjytimi@163.com> > Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Thanks, Conor. [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] [-- Attachment #2: Type: text/plain, Size: 161 bytes --] _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/3] RISC-V: Detect and Enable Svadu Extension Support 2023-09-22 8:56 ` [PATCH v2 1/3] RISC-V: Detect and Enable " Yong-Xuan Wang 2023-09-22 9:38 ` Conor Dooley @ 2023-09-27 7:03 ` Andrew Jones 2023-09-27 11:02 ` Yong-Xuan Wang 2023-09-27 7:16 ` Matthew Wilcox 2 siblings, 1 reply; 13+ messages in thread From: Andrew Jones @ 2023-09-27 7:03 UTC (permalink / raw) To: Yong-Xuan Wang Cc: Heiko Stuebner, Kemeng Shi, Daniel Henrique Barboza, Conor Dooley, Guo Ren, Jisheng Zhang, Qinglin Pan, linux-riscv, alex, David Hildenbrand, Matthew Wilcox (Oracle), tjytimi, greentime.hu, wchen, Sergey Matyukevich, Albert Ou, Alexandre Ghiti, Charlie Jenkins, Paul Walmsley, Anup Patel, linux-kernel, vincent.chen, Evan Green, Palmer Dabbelt, kvm-riscv, Andrew Morton, Rick Edgecombe On Fri, Sep 22, 2023 at 08:56:47AM +0000, Yong-Xuan Wang wrote: > We detect Svadu extension support from DTB and add arch_has_hw_pte_young() > to enable optimization in MGLRU and __wp_page_copy_user() if Svadu > extension is available. > > Co-developed-by: Jinyu Tang <tjytimi@163.com> > Signed-off-by: Jinyu Tang <tjytimi@163.com> > Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> > --- > arch/riscv/include/asm/csr.h | 1 + > arch/riscv/include/asm/hwcap.h | 1 + > arch/riscv/include/asm/pgtable.h | 6 ++++++ > arch/riscv/kernel/cpufeature.c | 1 + > 4 files changed, 9 insertions(+) > > diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h > index 777cb8299551..10648b372a2a 100644 > --- a/arch/riscv/include/asm/csr.h > +++ b/arch/riscv/include/asm/csr.h > @@ -194,6 +194,7 @@ > /* xENVCFG flags */ > #define ENVCFG_STCE (_AC(1, ULL) << 63) > #define ENVCFG_PBMTE (_AC(1, ULL) << 62) > +#define ENVCFG_HADE (_AC(1, ULL) << 61) This bit is named 'ADUE' in the spec. Why are we calling it HADE? > #define ENVCFG_CBZE (_AC(1, UL) << 7) > #define ENVCFG_CBCFE (_AC(1, UL) << 6) > #define ENVCFG_CBIE_SHIFT 4 > diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h > index b7b58258f6c7..1013661d6516 100644 > --- a/arch/riscv/include/asm/hwcap.h > +++ b/arch/riscv/include/asm/hwcap.h > @@ -58,6 +58,7 @@ > #define RISCV_ISA_EXT_ZICSR 40 > #define RISCV_ISA_EXT_ZIFENCEI 41 > #define RISCV_ISA_EXT_ZIHPM 42 > +#define RISCV_ISA_EXT_SVADU 43 > > #define RISCV_ISA_EXT_MAX 64 > > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h > index b2ba3f79cfe9..028b700cd27b 100644 > --- a/arch/riscv/include/asm/pgtable.h > +++ b/arch/riscv/include/asm/pgtable.h > @@ -629,6 +629,12 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot) > return __pgprot(prot); > } > > +#define arch_has_hw_pte_young arch_has_hw_pte_young > +static inline bool arch_has_hw_pte_young(void) > +{ > + return riscv_has_extension_unlikely(RISCV_ISA_EXT_SVADU); > +} > + > /* > * THP functions > */ > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c > index 1cfbba65d11a..ead378c04991 100644 > --- a/arch/riscv/kernel/cpufeature.c > +++ b/arch/riscv/kernel/cpufeature.c > @@ -178,6 +178,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { > __RISCV_ISA_EXT_DATA(ssaia, RISCV_ISA_EXT_SSAIA), > __RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF), > __RISCV_ISA_EXT_DATA(sstc, RISCV_ISA_EXT_SSTC), > + __RISCV_ISA_EXT_DATA(svadu, RISCV_ISA_EXT_SVADU), > __RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL), > __RISCV_ISA_EXT_DATA(svnapot, RISCV_ISA_EXT_SVNAPOT), > __RISCV_ISA_EXT_DATA(svpbmt, RISCV_ISA_EXT_SVPBMT), > -- > 2.17.1 > Thanks, drew _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/3] RISC-V: Detect and Enable Svadu Extension Support 2023-09-27 7:03 ` Andrew Jones @ 2023-09-27 11:02 ` Yong-Xuan Wang 0 siblings, 0 replies; 13+ messages in thread From: Yong-Xuan Wang @ 2023-09-27 11:02 UTC (permalink / raw) To: Andrew Jones Cc: Heiko Stuebner, Kemeng Shi, Daniel Henrique Barboza, Conor Dooley, Guo Ren, Jisheng Zhang, Qinglin Pan, linux-riscv, alex, David Hildenbrand, Matthew Wilcox (Oracle), tjytimi, greentime.hu, wchen, Sergey Matyukevich, Albert Ou, Alexandre Ghiti, Charlie Jenkins, Paul Walmsley, Anup Patel, linux-kernel, vincent.chen, Evan Green, Palmer Dabbelt, kvm-riscv, Andrew Morton, Rick Edgecombe Hi drew, On Wed, Sep 27, 2023 at 3:03 PM Andrew Jones <ajones@ventanamicro.com> wrote: > > On Fri, Sep 22, 2023 at 08:56:47AM +0000, Yong-Xuan Wang wrote: > > We detect Svadu extension support from DTB and add arch_has_hw_pte_young() > > to enable optimization in MGLRU and __wp_page_copy_user() if Svadu > > extension is available. > > > > Co-developed-by: Jinyu Tang <tjytimi@163.com> > > Signed-off-by: Jinyu Tang <tjytimi@163.com> > > Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> > > --- > > arch/riscv/include/asm/csr.h | 1 + > > arch/riscv/include/asm/hwcap.h | 1 + > > arch/riscv/include/asm/pgtable.h | 6 ++++++ > > arch/riscv/kernel/cpufeature.c | 1 + > > 4 files changed, 9 insertions(+) > > > > diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h > > index 777cb8299551..10648b372a2a 100644 > > --- a/arch/riscv/include/asm/csr.h > > +++ b/arch/riscv/include/asm/csr.h > > @@ -194,6 +194,7 @@ > > /* xENVCFG flags */ > > #define ENVCFG_STCE (_AC(1, ULL) << 63) > > #define ENVCFG_PBMTE (_AC(1, ULL) << 62) > > +#define ENVCFG_HADE (_AC(1, ULL) << 61) > > This bit is named 'ADUE' in the spec. Why are we calling it HADE? This bit was called HADE in v0.1 spec. I will update it to ADUE in patch v3. Thank you! Regards, Yong-Xuan > > > #define ENVCFG_CBZE (_AC(1, UL) << 7) > > #define ENVCFG_CBCFE (_AC(1, UL) << 6) > > #define ENVCFG_CBIE_SHIFT 4 > > diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h > > index b7b58258f6c7..1013661d6516 100644 > > --- a/arch/riscv/include/asm/hwcap.h > > +++ b/arch/riscv/include/asm/hwcap.h > > @@ -58,6 +58,7 @@ > > #define RISCV_ISA_EXT_ZICSR 40 > > #define RISCV_ISA_EXT_ZIFENCEI 41 > > #define RISCV_ISA_EXT_ZIHPM 42 > > +#define RISCV_ISA_EXT_SVADU 43 > > > > #define RISCV_ISA_EXT_MAX 64 > > > > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h > > index b2ba3f79cfe9..028b700cd27b 100644 > > --- a/arch/riscv/include/asm/pgtable.h > > +++ b/arch/riscv/include/asm/pgtable.h > > @@ -629,6 +629,12 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot) > > return __pgprot(prot); > > } > > > > +#define arch_has_hw_pte_young arch_has_hw_pte_young > > +static inline bool arch_has_hw_pte_young(void) > > +{ > > + return riscv_has_extension_unlikely(RISCV_ISA_EXT_SVADU); > > +} > > + > > /* > > * THP functions > > */ > > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c > > index 1cfbba65d11a..ead378c04991 100644 > > --- a/arch/riscv/kernel/cpufeature.c > > +++ b/arch/riscv/kernel/cpufeature.c > > @@ -178,6 +178,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { > > __RISCV_ISA_EXT_DATA(ssaia, RISCV_ISA_EXT_SSAIA), > > __RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF), > > __RISCV_ISA_EXT_DATA(sstc, RISCV_ISA_EXT_SSTC), > > + __RISCV_ISA_EXT_DATA(svadu, RISCV_ISA_EXT_SVADU), > > __RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL), > > __RISCV_ISA_EXT_DATA(svnapot, RISCV_ISA_EXT_SVNAPOT), > > __RISCV_ISA_EXT_DATA(svpbmt, RISCV_ISA_EXT_SVPBMT), > > -- > > 2.17.1 > > > > Thanks, > drew _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/3] RISC-V: Detect and Enable Svadu Extension Support 2023-09-22 8:56 ` [PATCH v2 1/3] RISC-V: Detect and Enable " Yong-Xuan Wang 2023-09-22 9:38 ` Conor Dooley 2023-09-27 7:03 ` Andrew Jones @ 2023-09-27 7:16 ` Matthew Wilcox 2 siblings, 0 replies; 13+ messages in thread From: Matthew Wilcox @ 2023-09-27 7:16 UTC (permalink / raw) To: Yong-Xuan Wang Cc: Heiko Stuebner, Kemeng Shi, Daniel Henrique Barboza, Conor Dooley, Guo Ren, Jisheng Zhang, Qinglin Pan, linux-riscv, alex, David Hildenbrand, tjytimi, greentime.hu, wchen, Sergey Matyukevich, Albert Ou, Alexandre Ghiti, Charlie Jenkins, Paul Walmsley, Anup Patel, Rick Edgecombe, linux-kernel, vincent.chen, Evan Green, Palmer Dabbelt, kvm-riscv, Andrew Morton, Andrew Jones On Fri, Sep 22, 2023 at 08:56:47AM +0000, Yong-Xuan Wang wrote: > We detect Svadu extension support from DTB and add arch_has_hw_pte_young() > to enable optimization in MGLRU and __wp_page_copy_user() if Svadu > extension is available. If you're going to cc people outside the RiscV space, you should probably explain what Svadu is. To me, it sounds like a Great Old One, maybe a friend of Cthulhu? _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 2/3] dt-bindings: riscv: Add Svadu Entry 2023-09-22 8:56 [PATCH v2 0/3] Add Svadu Extension Support Yong-Xuan Wang 2023-09-22 8:56 ` [PATCH v2 1/3] RISC-V: Detect and Enable " Yong-Xuan Wang @ 2023-09-22 8:56 ` Yong-Xuan Wang 2023-09-22 9:28 ` Conor Dooley ` (2 more replies) 2023-09-22 8:56 ` [PATCH v2 3/3] RISC-V: KVM: Add Svadu Extension Support for Guest/VM Yong-Xuan Wang 2 siblings, 3 replies; 13+ messages in thread From: Yong-Xuan Wang @ 2023-09-22 8:56 UTC (permalink / raw) To: linux-riscv, kvm-riscv Cc: greentime.hu, vincent.chen, tjytimi, alex, Yong-Xuan Wang, Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, devicetree, linux-kernel Add an entry for the Svadu extension to the riscv,isa-extensions property. Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> --- Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml index cc1f546fdbdc..b5a0aed0165b 100644 --- a/Documentation/devicetree/bindings/riscv/extensions.yaml +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml @@ -147,6 +147,12 @@ properties: ratified at commit 3f9ed34 ("Add ability to manually trigger workflow. (#2)") of riscv-time-compare. + - const: svadu + description: | + The standard Svadu supervisor-level extension for hardware updating + of PTE A/D bits as frozen at commit b65e07c ("move to Frozen + state") of riscv-svadu. + - const: svinval description: The standard Svinval supervisor-level extension for fine-grained -- 2.17.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/3] dt-bindings: riscv: Add Svadu Entry 2023-09-22 8:56 ` [PATCH v2 2/3] dt-bindings: riscv: Add Svadu Entry Yong-Xuan Wang @ 2023-09-22 9:28 ` Conor Dooley 2023-09-27 7:04 ` Andrew Jones 2023-09-27 17:24 ` Stefan O'Rear 2 siblings, 0 replies; 13+ messages in thread From: Conor Dooley @ 2023-09-22 9:28 UTC (permalink / raw) To: Yong-Xuan Wang Cc: linux-riscv, kvm-riscv, greentime.hu, vincent.chen, tjytimi, alex, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, devicetree, linux-kernel [-- Attachment #1.1: Type: text/plain, Size: 1298 bytes --] On Fri, Sep 22, 2023 at 08:56:48AM +0000, Yong-Xuan Wang wrote: > Add an entry for the Svadu extension to the riscv,isa-extensions property. > > Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> Acked-by: Conor Dooley <conor.dooley@microchip.com> Thanks, Conor. > --- > Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml > index cc1f546fdbdc..b5a0aed0165b 100644 > --- a/Documentation/devicetree/bindings/riscv/extensions.yaml > +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml > @@ -147,6 +147,12 @@ properties: > ratified at commit 3f9ed34 ("Add ability to manually trigger > workflow. (#2)") of riscv-time-compare. > > + - const: svadu > + description: | > + The standard Svadu supervisor-level extension for hardware updating > + of PTE A/D bits as frozen at commit b65e07c ("move to Frozen > + state") of riscv-svadu. > + > - const: svinval > description: > The standard Svinval supervisor-level extension for fine-grained > -- > 2.17.1 > [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] [-- Attachment #2: Type: text/plain, Size: 161 bytes --] _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/3] dt-bindings: riscv: Add Svadu Entry 2023-09-22 8:56 ` [PATCH v2 2/3] dt-bindings: riscv: Add Svadu Entry Yong-Xuan Wang 2023-09-22 9:28 ` Conor Dooley @ 2023-09-27 7:04 ` Andrew Jones 2023-09-27 17:24 ` Stefan O'Rear 2 siblings, 0 replies; 13+ messages in thread From: Andrew Jones @ 2023-09-27 7:04 UTC (permalink / raw) To: Yong-Xuan Wang Cc: linux-riscv, kvm-riscv, greentime.hu, vincent.chen, tjytimi, alex, Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, devicetree, linux-kernel On Fri, Sep 22, 2023 at 08:56:48AM +0000, Yong-Xuan Wang wrote: > Add an entry for the Svadu extension to the riscv,isa-extensions property. > > Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> > --- > Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml > index cc1f546fdbdc..b5a0aed0165b 100644 > --- a/Documentation/devicetree/bindings/riscv/extensions.yaml > +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml > @@ -147,6 +147,12 @@ properties: > ratified at commit 3f9ed34 ("Add ability to manually trigger > workflow. (#2)") of riscv-time-compare. > > + - const: svadu > + description: | > + The standard Svadu supervisor-level extension for hardware updating > + of PTE A/D bits as frozen at commit b65e07c ("move to Frozen > + state") of riscv-svadu. > + > - const: svinval > description: > The standard Svinval supervisor-level extension for fine-grained > -- > 2.17.1 > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/3] dt-bindings: riscv: Add Svadu Entry 2023-09-22 8:56 ` [PATCH v2 2/3] dt-bindings: riscv: Add Svadu Entry Yong-Xuan Wang 2023-09-22 9:28 ` Conor Dooley 2023-09-27 7:04 ` Andrew Jones @ 2023-09-27 17:24 ` Stefan O'Rear 2023-09-27 18:44 ` Jessica Clarke 2 siblings, 1 reply; 13+ messages in thread From: Stefan O'Rear @ 2023-09-27 17:24 UTC (permalink / raw) To: Yong-Xuan Wang, linux-riscv, kvm-riscv Cc: greentime.hu, vincent.chen, tjytimi, alex, Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, devicetree, linux-kernel On Fri, Sep 22, 2023, at 4:56 AM, Yong-Xuan Wang wrote: > Add an entry for the Svadu extension to the riscv,isa-extensions property. > > Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> > --- > Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml > b/Documentation/devicetree/bindings/riscv/extensions.yaml > index cc1f546fdbdc..b5a0aed0165b 100644 > --- a/Documentation/devicetree/bindings/riscv/extensions.yaml > +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml > @@ -147,6 +147,12 @@ properties: > ratified at commit 3f9ed34 ("Add ability to manually > trigger > workflow. (#2)") of riscv-time-compare. > > + - const: svadu > + description: | > + The standard Svadu supervisor-level extension for hardware updating > + of PTE A/D bits as frozen at commit b65e07c ("move to Frozen > + state") of riscv-svadu. > + This is incomplete without a specification of the behavior of the HADE bit implied by svadu being present. The ratified RVA20 requires page table accesses with A/D = 0 to trap, in other words HADE = 0 for RVA20 conformance. If we are serious about compatibility, I think that we need platforms to be able to conform to both RVA20 and RVA23, which requires HADE = 0 at kernel entry with a SBI call to set HADE = 1. For the same reason KVM should probably default to HADE = 0 so that the default configuration remains conformant to RVA20. -s > - const: svinval > description: > The standard Svinval supervisor-level extension for fine-grained > -- > 2.17.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/3] dt-bindings: riscv: Add Svadu Entry 2023-09-27 17:24 ` Stefan O'Rear @ 2023-09-27 18:44 ` Jessica Clarke 0 siblings, 0 replies; 13+ messages in thread From: Jessica Clarke @ 2023-09-27 18:44 UTC (permalink / raw) To: LKML Cc: Yong-Xuan Wang, linux-riscv, kvm-riscv, Greentime Hu, Vincent Chen, Jinyu Tang, Alexandre Ghiti, Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, Stefan O'Rear On 27 Sep 2023, at 18:24, Stefan O'Rear <sorear@fastmail.com> wrote: > > On Fri, Sep 22, 2023, at 4:56 AM, Yong-Xuan Wang wrote: >> Add an entry for the Svadu extension to the riscv,isa-extensions property. >> >> Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> >> --- >> Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml >> b/Documentation/devicetree/bindings/riscv/extensions.yaml >> index cc1f546fdbdc..b5a0aed0165b 100644 >> --- a/Documentation/devicetree/bindings/riscv/extensions.yaml >> +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml >> @@ -147,6 +147,12 @@ properties: >> ratified at commit 3f9ed34 ("Add ability to manually >> trigger >> workflow. (#2)") of riscv-time-compare. >> >> + - const: svadu >> + description: | >> + The standard Svadu supervisor-level extension for hardware updating >> + of PTE A/D bits as frozen at commit b65e07c ("move to Frozen >> + state") of riscv-svadu. >> + > > This is incomplete without a specification of the behavior of the HADE bit implied > by svadu being present. > > The ratified RVA20 requires page table accesses with A/D = 0 to trap, in other > words HADE = 0 for RVA20 conformance. If we are serious about compatibility, > I think that we need platforms to be able to conform to both RVA20 and RVA23, > which requires HADE = 0 at kernel entry with a SBI call to set HADE = 1. For > the same reason KVM should probably default to HADE = 0 so that the default > configuration remains conformant to RVA20. I’ve filed https://github.com/riscv/riscv-svadu/issues/21 to track this broken ISA design, as discussed on IRC. As a FreeBSD RISC-V developer, and sometime reviewer of Linux RISC-V patches, this is a NAK from me for this ISA design. Which does beg the question of how much sense the current RISC-V processes make, given for freezing a spec you just need to send out the relevant RFC patches, they don’t actually need to have any review from the project in question that says it’s a sensible design, instead treating that as part of the public review period, where it’s much harder to fundamentally change the spec, despite being the first time most people see it or take it seriously as a thing to look at. In my opinion there is a serious need for knowledgeable people on the software side to review the ISA extension and its interaction with software *before* it can be frozen so that these things can be fixed. And of course, if they do get fixed during/after public review, what good is the frozen state anyway, because a spec that changes is not very frozen. But I’m probably preaching to the choir here about RISC-V processes being unfit for purpose. Jess >> - const: svinval >> description: >> The standard Svinval supervisor-level extension for fine-grained >> -- >> 2.17.1 >> >> >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 3/3] RISC-V: KVM: Add Svadu Extension Support for Guest/VM 2023-09-22 8:56 [PATCH v2 0/3] Add Svadu Extension Support Yong-Xuan Wang 2023-09-22 8:56 ` [PATCH v2 1/3] RISC-V: Detect and Enable " Yong-Xuan Wang 2023-09-22 8:56 ` [PATCH v2 2/3] dt-bindings: riscv: Add Svadu Entry Yong-Xuan Wang @ 2023-09-22 8:56 ` Yong-Xuan Wang 2023-09-27 7:27 ` Andrew Jones 2 siblings, 1 reply; 13+ messages in thread From: Yong-Xuan Wang @ 2023-09-22 8:56 UTC (permalink / raw) To: linux-riscv, kvm-riscv Cc: greentime.hu, vincent.chen, tjytimi, alex, Yong-Xuan Wang, Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou, kvm, linux-kernel We extend the KVM ISA extension ONE_REG interface to allow VMM tools to detect and enable Svadu extension for Guest/VM. Also set the HADE bit in henvcfg CSR if Svadu extension is available for Guest/VM. Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> --- arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kvm/vcpu.c | 3 +++ arch/riscv/kvm/vcpu_onereg.c | 1 + 3 files changed, 5 insertions(+) diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h index 992c5e407104..3c7a6c762d0f 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -131,6 +131,7 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_ZICSR, KVM_RISCV_ISA_EXT_ZIFENCEI, KVM_RISCV_ISA_EXT_ZIHPM, + KVM_RISCV_ISA_EXT_SVADU, KVM_RISCV_ISA_EXT_MAX, }; diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index 82229db1ce73..91b92a1f4e33 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -487,6 +487,9 @@ static void kvm_riscv_vcpu_update_config(const unsigned long *isa) if (riscv_isa_extension_available(isa, ZICBOZ)) henvcfg |= ENVCFG_CBZE; + if (riscv_isa_extension_available(isa, SVADU)) + henvcfg |= ENVCFG_HADE; + csr_write(CSR_HENVCFG, henvcfg); #ifdef CONFIG_32BIT csr_write(CSR_HENVCFGH, henvcfg >> 32); diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c index 1b7e9fa265cb..211915dad677 100644 --- a/arch/riscv/kvm/vcpu_onereg.c +++ b/arch/riscv/kvm/vcpu_onereg.c @@ -36,6 +36,7 @@ static const unsigned long kvm_isa_ext_arr[] = { /* Multi letter extensions (alphabetically sorted) */ KVM_ISA_EXT_ARR(SSAIA), KVM_ISA_EXT_ARR(SSTC), + KVM_ISA_EXT_ARR(SVADU), KVM_ISA_EXT_ARR(SVINVAL), KVM_ISA_EXT_ARR(SVNAPOT), KVM_ISA_EXT_ARR(SVPBMT), -- 2.17.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 3/3] RISC-V: KVM: Add Svadu Extension Support for Guest/VM 2023-09-22 8:56 ` [PATCH v2 3/3] RISC-V: KVM: Add Svadu Extension Support for Guest/VM Yong-Xuan Wang @ 2023-09-27 7:27 ` Andrew Jones 0 siblings, 0 replies; 13+ messages in thread From: Andrew Jones @ 2023-09-27 7:27 UTC (permalink / raw) To: Yong-Xuan Wang Cc: linux-riscv, kvm-riscv, greentime.hu, vincent.chen, tjytimi, alex, Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou, kvm, linux-kernel On Fri, Sep 22, 2023 at 08:56:49AM +0000, Yong-Xuan Wang wrote: > We extend the KVM ISA extension ONE_REG interface to allow VMM > tools to detect and enable Svadu extension for Guest/VM. > > Also set the HADE bit in henvcfg CSR if Svadu extension is > available for Guest/VM. > > Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> > --- > arch/riscv/include/uapi/asm/kvm.h | 1 + > arch/riscv/kvm/vcpu.c | 3 +++ > arch/riscv/kvm/vcpu_onereg.c | 1 + > 3 files changed, 5 insertions(+) > > diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h > index 992c5e407104..3c7a6c762d0f 100644 > --- a/arch/riscv/include/uapi/asm/kvm.h > +++ b/arch/riscv/include/uapi/asm/kvm.h > @@ -131,6 +131,7 @@ enum KVM_RISCV_ISA_EXT_ID { > KVM_RISCV_ISA_EXT_ZICSR, > KVM_RISCV_ISA_EXT_ZIFENCEI, > KVM_RISCV_ISA_EXT_ZIHPM, > + KVM_RISCV_ISA_EXT_SVADU, This register will show up as "new" in kselftests test[1]. We should add another patch to this series to update the test to handle/test it. [1] tools/testing/selftests/kvm/riscv/get-reg-list.c > KVM_RISCV_ISA_EXT_MAX, > }; > > diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c > index 82229db1ce73..91b92a1f4e33 100644 > --- a/arch/riscv/kvm/vcpu.c > +++ b/arch/riscv/kvm/vcpu.c > @@ -487,6 +487,9 @@ static void kvm_riscv_vcpu_update_config(const unsigned long *isa) > if (riscv_isa_extension_available(isa, ZICBOZ)) > henvcfg |= ENVCFG_CBZE; > > + if (riscv_isa_extension_available(isa, SVADU)) > + henvcfg |= ENVCFG_HADE; > + > csr_write(CSR_HENVCFG, henvcfg); > #ifdef CONFIG_32BIT > csr_write(CSR_HENVCFGH, henvcfg >> 32); > diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c > index 1b7e9fa265cb..211915dad677 100644 > --- a/arch/riscv/kvm/vcpu_onereg.c > +++ b/arch/riscv/kvm/vcpu_onereg.c > @@ -36,6 +36,7 @@ static const unsigned long kvm_isa_ext_arr[] = { > /* Multi letter extensions (alphabetically sorted) */ > KVM_ISA_EXT_ARR(SSAIA), > KVM_ISA_EXT_ARR(SSTC), > + KVM_ISA_EXT_ARR(SVADU), > KVM_ISA_EXT_ARR(SVINVAL), > KVM_ISA_EXT_ARR(SVNAPOT), > KVM_ISA_EXT_ARR(SVPBMT), > -- > 2.17.1 > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Thanks, drew _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-09-27 18:45 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-09-22 8:56 [PATCH v2 0/3] Add Svadu Extension Support Yong-Xuan Wang 2023-09-22 8:56 ` [PATCH v2 1/3] RISC-V: Detect and Enable " Yong-Xuan Wang 2023-09-22 9:38 ` Conor Dooley 2023-09-27 7:03 ` Andrew Jones 2023-09-27 11:02 ` Yong-Xuan Wang 2023-09-27 7:16 ` Matthew Wilcox 2023-09-22 8:56 ` [PATCH v2 2/3] dt-bindings: riscv: Add Svadu Entry Yong-Xuan Wang 2023-09-22 9:28 ` Conor Dooley 2023-09-27 7:04 ` Andrew Jones 2023-09-27 17:24 ` Stefan O'Rear 2023-09-27 18:44 ` Jessica Clarke 2023-09-22 8:56 ` [PATCH v2 3/3] RISC-V: KVM: Add Svadu Extension Support for Guest/VM Yong-Xuan Wang 2023-09-27 7:27 ` Andrew Jones
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox