* [PATCH v6 0/4] Add Svade and Svadu Extensions Support
@ 2024-06-28 9:37 Yong-Xuan Wang
2024-06-28 9:37 ` [PATCH v6 1/4] RISC-V: " Yong-Xuan Wang
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Yong-Xuan Wang @ 2024-06-28 9:37 UTC (permalink / raw)
To: linux-kernel, linux-riscv, kvm-riscv, kvm
Cc: greentime.hu, vincent.chen, Yong-Xuan Wang, Paul Walmsley,
Palmer Dabbelt, Albert Ou
Svade and Svadu extensions represent two schemes for managing the PTE A/D
bit. When the PTE A/D bits need to be set, Svade extension intdicates that
a related page fault will be raised. In contrast, the Svadu extension
supports hardware updating of PTE A/D bits. This series enables Svade and
Svadu extensions for both host and guest OS.
Regrading the mailing thread[1], we have 4 possible combinations of
these extensions in the device tree, the default hardware behavior for
these possibilities are:
1) Neither Svade nor Svadu present in DT => It is technically
unknown whether the platform uses Svade or Svadu. Supervisor may
assume Svade to be present and enabled or it can discover based
on mvendorid, marchid, and mimpid.
2) Only Svade present in DT => Supervisor must assume Svade to be
always enabled. (Obvious)
3) Only Svadu present in DT => Supervisor must assume Svadu to be
always enabled. (Obvious)
4) Both Svade and Svadu present in DT => Supervisor must assume
Svadu turned-off at boot time. To use Svadu, supervisor must
explicitly enable it using the SBI FWFT extension.
The Svade extension is mandatory and the Svadu extension is optional in
RVA23 profile. Platforms want to take the advantage of Svadu can choose
3. Those are aware of the profile can choose 4, and Linux won't get the
benefit of svadu until the SBI FWFT extension is available.
[1] https://lore.kernel.org/linux-kernel/20240527-e9845c06619bca5cd285098c@orel/T/#m29644eb88e241ec282df4ccd5199514e913b06ee
---
v6:
- reflect the platform's behavior by riscv_isa_extension_available() and
update the the arch_has_hw_pte_young() in PATCH1 (Conor, Andrew)
- update the dtbinding in PATCH2 (Alexandre, Andrew, Anup, Conor)
- update the henvcfg condition in PATCH3 (Andrew)
- check if Svade is allowed to disabled based on arch_has_hw_pte_young()
in PATCH3
v5:
- remove all Acked-by and Reviewed-by (Conor, Andrew)
- add Svade support
- update the arch_has_hw_pte_young() in PATCH1
- update the dtbinding in PATCH2 (Alexandre, Andrew)
- check the availibility of Svadu for Guest/VM based on
arch_has_hw_pte_young() in PATCH3
v4:
- fix 32bit kernel build error in PATCH1 (Conor)
- update the status of Svadu extension to ratified in PATCH2
- add the PATCH4 to suporrt SBI_FWFT_PTE_AD_HW_UPDATING for guest OS
- update the PATCH1 and PATCH3 to integrate with FWFT extension
- rebase PATCH5 on the lastest get-reg-list test (Andrew)
v3:
- fix the control bit name to ADUE in PATCH1 and PATCH3
- update get-reg-list in PATCH4
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 (4):
RISC-V: Add Svade and Svadu Extensions Support
dt-bindings: riscv: Add Svade and Svadu Entries
RISC-V: KVM: Add Svade and Svadu Extensions Support for Guest/VM
KVM: riscv: selftests: Add Svade and Svadu Extension to get-reg-list
test
.../devicetree/bindings/riscv/extensions.yaml | 28 ++++++++++++++++
arch/riscv/Kconfig | 1 +
arch/riscv/include/asm/csr.h | 1 +
arch/riscv/include/asm/hwcap.h | 2 ++
arch/riscv/include/asm/pgtable.h | 13 +++++++-
arch/riscv/include/uapi/asm/kvm.h | 2 ++
arch/riscv/kernel/cpufeature.c | 32 +++++++++++++++++++
arch/riscv/kvm/vcpu.c | 3 ++
arch/riscv/kvm/vcpu_onereg.c | 15 +++++++++
.../selftests/kvm/riscv/get-reg-list.c | 8 +++++
10 files changed, 104 insertions(+), 1 deletion(-)
--
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] 9+ messages in thread
* [PATCH v6 1/4] RISC-V: Add Svade and Svadu Extensions Support
2024-06-28 9:37 [PATCH v6 0/4] Add Svade and Svadu Extensions Support Yong-Xuan Wang
@ 2024-06-28 9:37 ` Yong-Xuan Wang
2024-06-28 9:37 ` [PATCH v6 2/4] dt-bindings: riscv: Add Svade and Svadu Entries Yong-Xuan Wang
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Yong-Xuan Wang @ 2024-06-28 9:37 UTC (permalink / raw)
To: linux-kernel, linux-riscv, kvm-riscv, kvm
Cc: greentime.hu, vincent.chen, Yong-Xuan Wang, Jinyu Tang,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Andrew Jones,
Anup Patel, Conor Dooley, Mayuresh Chitale, Atish Patra,
Samuel Holland, Samuel Ortiz, Daniel Henrique Barboza,
Clément Léger, Evan Green, Xiao Wang, Alexandre Ghiti,
Andrew Morton, Mike Rapoport (IBM), Kemeng Shi, Charlie Jenkins,
Peter Xu, Matthew Wilcox (Oracle), Jisheng Zhang, Leonardo Bras
Svade and Svadu extensions represent two schemes for managing the PTE A/D
bits. When the PTE A/D bits need to be set, Svade extension intdicates
that a related page fault will be raised. In contrast, the Svadu extension
supports hardware updating of PTE A/D bits. Since the Svade extension is
mandatory and the Svadu extension is optional in RVA23 profile, by default
the M-mode firmware will enable the Svadu extension in the menvcfg CSR
when only Svadu is present in DT.
This patch detects Svade and Svadu extensions from DT and adds
arch_has_hw_pte_young() to enable optimization in MGLRU and
__wp_page_copy_user() when we have the PTE A/D bits hardware updating
support.
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: Andrew Jones <ajones@ventanamicro.com>
---
arch/riscv/Kconfig | 1 +
arch/riscv/include/asm/csr.h | 1 +
arch/riscv/include/asm/hwcap.h | 2 ++
arch/riscv/include/asm/pgtable.h | 13 ++++++++++++-
arch/riscv/kernel/cpufeature.c | 32 ++++++++++++++++++++++++++++++++
5 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 0525ee2d63c7..3d705e28ff85 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -36,6 +36,7 @@ config RISCV
select ARCH_HAS_PMEM_API
select ARCH_HAS_PREPARE_SYNC_CORE_CMD
select ARCH_HAS_PTE_SPECIAL
+ select ARCH_HAS_HW_PTE_YOUNG
select ARCH_HAS_SET_DIRECT_MAP if MMU
select ARCH_HAS_SET_MEMORY if MMU
select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h
index 25966995da04..524cd4131c71 100644
--- a/arch/riscv/include/asm/csr.h
+++ b/arch/riscv/include/asm/csr.h
@@ -195,6 +195,7 @@
/* xENVCFG flags */
#define ENVCFG_STCE (_AC(1, ULL) << 63)
#define ENVCFG_PBMTE (_AC(1, ULL) << 62)
+#define ENVCFG_ADUE (_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 e17d0078a651..35d7aa49785d 100644
--- a/arch/riscv/include/asm/hwcap.h
+++ b/arch/riscv/include/asm/hwcap.h
@@ -81,6 +81,8 @@
#define RISCV_ISA_EXT_ZTSO 72
#define RISCV_ISA_EXT_ZACAS 73
#define RISCV_ISA_EXT_XANDESPMU 74
+#define RISCV_ISA_EXT_SVADE 75
+#define RISCV_ISA_EXT_SVADU 76
#define RISCV_ISA_EXT_XLINUXENVCFG 127
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index aad8b8ca51f1..ec0cdacd7da0 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -120,6 +120,7 @@
#include <asm/tlbflush.h>
#include <linux/mm_types.h>
#include <asm/compat.h>
+#include <asm/cpufeature.h>
#define __page_val_to_pfn(_val) (((_val) & _PAGE_PFN_MASK) >> _PAGE_PFN_SHIFT)
@@ -288,7 +289,6 @@ static inline pte_t pud_pte(pud_t pud)
}
#ifdef CONFIG_RISCV_ISA_SVNAPOT
-#include <asm/cpufeature.h>
static __always_inline bool has_svnapot(void)
{
@@ -624,6 +624,17 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot)
return __pgprot(prot);
}
+/*
+ * Both Svade and Svadu control the hardware behavior when the PTE A/D bits need to be set. By
+ * default the M-mode firmware enables the hardware updating scheme when only Svadu is present in
+ * DT.
+ */
+#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 5ef48cb20ee1..d31f79bc4daf 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -301,6 +301,8 @@ 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(svade, RISCV_ISA_EXT_SVADE),
+ __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),
@@ -554,6 +556,21 @@ static void __init riscv_fill_hwcap_from_isa_string(unsigned long *isa2hwcap)
clear_bit(RISCV_ISA_EXT_v, isainfo->isa);
}
+ /*
+ * When neither Svade nor Svadu present in DT, it is technically
+ * unknown whether the platform uses Svade or Svadu. Supervisor may
+ * assume Svade to be present and enabled or it can discover based
+ * on mvendorid, marchid, and mimpid. When both Svade and Svadu present
+ * in DT, supervisor must assume Svadu turned-off at boot time. To use
+ * Svadu, supervisor must explicitly enable it using the SBI FWFT extension.
+ */
+ if (!test_bit(RISCV_ISA_EXT_SVADE, isainfo->isa) &&
+ !test_bit(RISCV_ISA_EXT_SVADU, isainfo->isa))
+ set_bit(RISCV_ISA_EXT_SVADE, isainfo->isa);
+ else if (test_bit(RISCV_ISA_EXT_SVADE, isainfo->isa) &&
+ test_bit(RISCV_ISA_EXT_SVADU, isainfo->isa))
+ clear_bit(RISCV_ISA_EXT_SVADU, isainfo->isa);
+
/*
* All "okay" hart should have same isa. Set HWCAP based on
* common capabilities of every "okay" hart, in case they don't
@@ -619,6 +636,21 @@ static int __init riscv_fill_hwcap_from_ext_list(unsigned long *isa2hwcap)
of_node_put(cpu_node);
+ /*
+ * When neither Svade nor Svadu present in DT, it is technically
+ * unknown whether the platform uses Svade or Svadu. Supervisor may
+ * assume Svade to be present and enabled or it can discover based
+ * on mvendorid, marchid, and mimpid. When both Svade and Svadu present
+ * in DT, supervisor must assume Svadu turned-off at boot time. To use
+ * Svadu, supervisor must explicitly enable it using the SBI FWFT extension.
+ */
+ if (!test_bit(RISCV_ISA_EXT_SVADE, isainfo->isa) &&
+ !test_bit(RISCV_ISA_EXT_SVADU, isainfo->isa))
+ set_bit(RISCV_ISA_EXT_SVADE, isainfo->isa);
+ else if (test_bit(RISCV_ISA_EXT_SVADE, isainfo->isa) &&
+ test_bit(RISCV_ISA_EXT_SVADU, isainfo->isa))
+ clear_bit(RISCV_ISA_EXT_SVADU, isainfo->isa);
+
/*
* All "okay" harts should have same isa. Set HWCAP based on
* common capabilities of every "okay" hart, in case they don't.
--
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] 9+ messages in thread
* [PATCH v6 2/4] dt-bindings: riscv: Add Svade and Svadu Entries
2024-06-28 9:37 [PATCH v6 0/4] Add Svade and Svadu Extensions Support Yong-Xuan Wang
2024-06-28 9:37 ` [PATCH v6 1/4] RISC-V: " Yong-Xuan Wang
@ 2024-06-28 9:37 ` Yong-Xuan Wang
2024-06-28 16:19 ` Conor Dooley
2024-06-28 9:37 ` [PATCH v6 3/4] RISC-V: KVM: Add Svade and Svadu Extensions Support for Guest/VM Yong-Xuan Wang
2024-06-28 9:37 ` [PATCH v6 4/4] KVM: riscv: selftests: Add Svade and Svadu Extension to get-reg-list test Yong-Xuan Wang
3 siblings, 1 reply; 9+ messages in thread
From: Yong-Xuan Wang @ 2024-06-28 9:37 UTC (permalink / raw)
To: linux-kernel, linux-riscv, kvm-riscv, kvm
Cc: greentime.hu, vincent.chen, Yong-Xuan Wang, Conor Dooley,
Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt,
Albert Ou, devicetree
Add entries for the Svade and Svadu extensions to the riscv,isa-extensions
property.
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
---
.../devicetree/bindings/riscv/extensions.yaml | 28 +++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml
index 468c646247aa..c3d053ce7783 100644
--- a/Documentation/devicetree/bindings/riscv/extensions.yaml
+++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
@@ -153,6 +153,34 @@ properties:
ratified at commit 3f9ed34 ("Add ability to manually trigger
workflow. (#2)") of riscv-time-compare.
+ - const: svade
+ description: |
+ The standard Svade supervisor-level extension for SW-managed PTE A/D
+ bit updates as ratified in the 20240213 version of the privileged
+ ISA specification.
+
+ Both Svade and Svadu extensions control the hardware behavior when
+ the PTE A/D bits need to be set. The default behavior for the four
+ possible combinations of these extensions in the device tree are:
+ 1) Neither Svade nor Svadu present in DT => It is technically
+ unknown whether the platform uses Svade or Svadu. Supervisor may
+ assume Svade to be present and enabled or it can discover based
+ on mvendorid, marchid, and mimpid.
+ 2) Only Svade present in DT => Supervisor must assume Svade to be
+ always enabled. (Obvious)
+ 3) Only Svadu present in DT => Supervisor must assume Svadu to be
+ always enabled. (Obvious)
+ 4) Both Svade and Svadu present in DT => Supervisor must assume
+ Svadu turned-off at boot time. To use Svadu, supervisor must
+ explicitly enable it using the SBI FWFT extension.
+
+ - const: svadu
+ description: |
+ The standard Svadu supervisor-level extension for hardware updating
+ of PTE A/D bits as ratified at commit c1abccf ("Merge pull request
+ #25 from ved-rivos/ratified") of riscv-svadu. Please refer to Svade
+ dt-binding description for more details.
+
- 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] 9+ messages in thread
* [PATCH v6 3/4] RISC-V: KVM: Add Svade and Svadu Extensions Support for Guest/VM
2024-06-28 9:37 [PATCH v6 0/4] Add Svade and Svadu Extensions Support Yong-Xuan Wang
2024-06-28 9:37 ` [PATCH v6 1/4] RISC-V: " Yong-Xuan Wang
2024-06-28 9:37 ` [PATCH v6 2/4] dt-bindings: riscv: Add Svade and Svadu Entries Yong-Xuan Wang
@ 2024-06-28 9:37 ` Yong-Xuan Wang
2024-06-28 9:37 ` [PATCH v6 4/4] KVM: riscv: selftests: Add Svade and Svadu Extension to get-reg-list test Yong-Xuan Wang
3 siblings, 0 replies; 9+ messages in thread
From: Yong-Xuan Wang @ 2024-06-28 9:37 UTC (permalink / raw)
To: linux-kernel, linux-riscv, kvm-riscv, kvm
Cc: greentime.hu, vincent.chen, Yong-Xuan Wang, Anup Patel,
Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou
We extend the KVM ISA extension ONE_REG interface to allow VMM tools to
detect and enable Svade and Svadu extensions for Guest/VM. Since the
henvcfg.ADUE is read-only zero if the menvcfg.ADUE is zero, the Svadu
extension is available for Guest/VM and the Svade extension is allowed
to disabledonly when arch_has_hw_pte_young() is true.
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
---
arch/riscv/include/uapi/asm/kvm.h | 2 ++
arch/riscv/kvm/vcpu.c | 3 +++
arch/riscv/kvm/vcpu_onereg.c | 15 +++++++++++++++
3 files changed, 20 insertions(+)
diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h
index e878e7cc3978..a5e0c35d7e9a 100644
--- a/arch/riscv/include/uapi/asm/kvm.h
+++ b/arch/riscv/include/uapi/asm/kvm.h
@@ -168,6 +168,8 @@ enum KVM_RISCV_ISA_EXT_ID {
KVM_RISCV_ISA_EXT_ZTSO,
KVM_RISCV_ISA_EXT_ZACAS,
KVM_RISCV_ISA_EXT_SSCOFPMF,
+ KVM_RISCV_ISA_EXT_SVADE,
+ 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 17e21df36cc1..64a15af459e0 100644
--- a/arch/riscv/kvm/vcpu.c
+++ b/arch/riscv/kvm/vcpu.c
@@ -540,6 +540,9 @@ static void kvm_riscv_vcpu_setup_config(struct kvm_vcpu *vcpu)
if (riscv_isa_extension_available(isa, ZICBOZ))
cfg->henvcfg |= ENVCFG_CBZE;
+ if (riscv_isa_extension_available(isa, SVADU))
+ cfg->henvcfg |= ENVCFG_ADUE;
+
if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SMSTATEEN)) {
cfg->hstateen0 |= SMSTATEEN0_HSENVCFG;
if (riscv_isa_extension_available(isa, SSAIA))
diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c
index 62874fbca29f..474fdeafe9fe 100644
--- a/arch/riscv/kvm/vcpu_onereg.c
+++ b/arch/riscv/kvm/vcpu_onereg.c
@@ -15,6 +15,7 @@
#include <asm/cacheflush.h>
#include <asm/cpufeature.h>
#include <asm/kvm_vcpu_vector.h>
+#include <asm/pgtable.h>
#include <asm/vector.h>
#define KVM_RISCV_BASE_ISA_MASK GENMASK(25, 0)
@@ -38,6 +39,8 @@ static const unsigned long kvm_isa_ext_arr[] = {
KVM_ISA_EXT_ARR(SSAIA),
KVM_ISA_EXT_ARR(SSCOFPMF),
KVM_ISA_EXT_ARR(SSTC),
+ KVM_ISA_EXT_ARR(SVADE),
+ KVM_ISA_EXT_ARR(SVADU),
KVM_ISA_EXT_ARR(SVINVAL),
KVM_ISA_EXT_ARR(SVNAPOT),
KVM_ISA_EXT_ARR(SVPBMT),
@@ -105,6 +108,12 @@ static bool kvm_riscv_vcpu_isa_enable_allowed(unsigned long ext)
return __riscv_isa_extension_available(NULL, RISCV_ISA_EXT_SSAIA);
case KVM_RISCV_ISA_EXT_V:
return riscv_v_vstate_ctrl_user_allowed();
+ case KVM_RISCV_ISA_EXT_SVADU:
+ /*
+ * The henvcfg.ADUE is read-only zero if menvcfg.ADUE is zero.
+ * Guest OS can use Svadu only when host os enable Svadu.
+ */
+ return arch_has_hw_pte_young();
default:
break;
}
@@ -167,6 +176,12 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext)
/* Extensions which can be disabled using Smstateen */
case KVM_RISCV_ISA_EXT_SSAIA:
return riscv_has_extension_unlikely(RISCV_ISA_EXT_SMSTATEEN);
+ case KVM_RISCV_ISA_EXT_SVADE:
+ /*
+ * The henvcfg.ADUE is read-only zero if menvcfg.ADUE is zero.
+ * Svade is not allowed to disable when the platform use Svade.
+ */
+ return arch_has_hw_pte_young();
default:
break;
}
--
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] 9+ messages in thread
* [PATCH v6 4/4] KVM: riscv: selftests: Add Svade and Svadu Extension to get-reg-list test
2024-06-28 9:37 [PATCH v6 0/4] Add Svade and Svadu Extensions Support Yong-Xuan Wang
` (2 preceding siblings ...)
2024-06-28 9:37 ` [PATCH v6 3/4] RISC-V: KVM: Add Svade and Svadu Extensions Support for Guest/VM Yong-Xuan Wang
@ 2024-06-28 9:37 ` Yong-Xuan Wang
3 siblings, 0 replies; 9+ messages in thread
From: Yong-Xuan Wang @ 2024-06-28 9:37 UTC (permalink / raw)
To: linux-kernel, linux-riscv, kvm-riscv, kvm
Cc: greentime.hu, vincent.chen, Yong-Xuan Wang, Anup Patel,
Atish Patra, Paolo Bonzini, Shuah Khan, Paul Walmsley,
Palmer Dabbelt, Albert Ou, linux-kselftest
Update the get-reg-list test to test the Svade and Svadu Extensions are
available for guest OS.
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
---
tools/testing/selftests/kvm/riscv/get-reg-list.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c b/tools/testing/selftests/kvm/riscv/get-reg-list.c
index 222198dd6d04..1d32351ad55e 100644
--- a/tools/testing/selftests/kvm/riscv/get-reg-list.c
+++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c
@@ -45,6 +45,8 @@ bool filter_reg(__u64 reg)
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SSAIA:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SSCOFPMF:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SSTC:
+ case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVADE:
+ case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVADU:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVINVAL:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVNAPOT:
case KVM_REG_RISCV_ISA_EXT | KVM_REG_RISCV_ISA_SINGLE | KVM_RISCV_ISA_EXT_SVPBMT:
@@ -411,6 +413,8 @@ static const char *isa_ext_single_id_to_str(__u64 reg_off)
KVM_ISA_EXT_ARR(SSAIA),
KVM_ISA_EXT_ARR(SSCOFPMF),
KVM_ISA_EXT_ARR(SSTC),
+ KVM_ISA_EXT_ARR(SVADE),
+ KVM_ISA_EXT_ARR(SVADU),
KVM_ISA_EXT_ARR(SVINVAL),
KVM_ISA_EXT_ARR(SVNAPOT),
KVM_ISA_EXT_ARR(SVPBMT),
@@ -935,6 +939,8 @@ KVM_ISA_EXT_SIMPLE_CONFIG(h, H);
KVM_ISA_EXT_SUBLIST_CONFIG(smstateen, SMSTATEEN);
KVM_ISA_EXT_SIMPLE_CONFIG(sscofpmf, SSCOFPMF);
KVM_ISA_EXT_SIMPLE_CONFIG(sstc, SSTC);
+KVM_ISA_EXT_SIMPLE_CONFIG(svade, SVADE);
+KVM_ISA_EXT_SIMPLE_CONFIG(svadu, SVADU);
KVM_ISA_EXT_SIMPLE_CONFIG(svinval, SVINVAL);
KVM_ISA_EXT_SIMPLE_CONFIG(svnapot, SVNAPOT);
KVM_ISA_EXT_SIMPLE_CONFIG(svpbmt, SVPBMT);
@@ -991,6 +997,8 @@ struct vcpu_reg_list *vcpu_configs[] = {
&config_smstateen,
&config_sscofpmf,
&config_sstc,
+ &config_svade,
+ &config_svadu,
&config_svinval,
&config_svnapot,
&config_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] 9+ messages in thread
* Re: [PATCH v6 2/4] dt-bindings: riscv: Add Svade and Svadu Entries
2024-06-28 9:37 ` [PATCH v6 2/4] dt-bindings: riscv: Add Svade and Svadu Entries Yong-Xuan Wang
@ 2024-06-28 16:19 ` Conor Dooley
2024-06-29 13:09 ` Jessica Clarke
0 siblings, 1 reply; 9+ messages in thread
From: Conor Dooley @ 2024-06-28 16:19 UTC (permalink / raw)
To: Yong-Xuan Wang
Cc: linux-kernel, linux-riscv, kvm-riscv, kvm, greentime.hu,
vincent.chen, Rob Herring, Krzysztof Kozlowski, Paul Walmsley,
Palmer Dabbelt, Albert Ou, devicetree
[-- Attachment #1.1: Type: text/plain, Size: 3149 bytes --]
On Fri, Jun 28, 2024 at 05:37:06PM +0800, Yong-Xuan Wang wrote:
> Add entries for the Svade and Svadu extensions to the riscv,isa-extensions
> property.
>
> Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
> ---
> .../devicetree/bindings/riscv/extensions.yaml | 28 +++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml
> index 468c646247aa..c3d053ce7783 100644
> --- a/Documentation/devicetree/bindings/riscv/extensions.yaml
> +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
> @@ -153,6 +153,34 @@ properties:
> ratified at commit 3f9ed34 ("Add ability to manually trigger
> workflow. (#2)") of riscv-time-compare.
>
> + - const: svade
> + description: |
> + The standard Svade supervisor-level extension for SW-managed PTE A/D
> + bit updates as ratified in the 20240213 version of the privileged
> + ISA specification.
> +
> + Both Svade and Svadu extensions control the hardware behavior when
> + the PTE A/D bits need to be set. The default behavior for the four
> + possible combinations of these extensions in the device tree are:
> + 1) Neither Svade nor Svadu present in DT =>
> It is technically
> + unknown whether the platform uses Svade or Svadu. Supervisor may
> + assume Svade to be present and enabled or it can discover based
> + on mvendorid, marchid, and mimpid.
I would just write "for backwards compatibility, if neither Svade nor
Svadu appear in the devicetree the supervisor may assume Svade to be
present and enabled". If there are systems that this behaviour causes
problems for, we can deal with them iff they appear. I don't think
looking at m*id would be sufficient here anyway, since the firmware can
have an impact. I'd just drop that part entirely.
> + 2) Only Svade present in DT => Supervisor must assume Svade to be
> + always enabled. (Obvious)
nit: I'd drop the "(Obvious)" comments from here.
Cheers,
Conor.
> + 3) Only Svadu present in DT => Supervisor must assume Svadu to be
> + always enabled. (Obvious)
> + 4) Both Svade and Svadu present in DT => Supervisor must assume
> + Svadu turned-off at boot time. To use Svadu, supervisor must
> + explicitly enable it using the SBI FWFT extension.
> +
> + - const: svadu
> + description: |
> + The standard Svadu supervisor-level extension for hardware updating
> + of PTE A/D bits as ratified at commit c1abccf ("Merge pull request
> + #25 from ved-rivos/ratified") of riscv-svadu. Please refer to Svade
> + dt-binding description for more details.
> +
> - 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] 9+ messages in thread
* Re: [PATCH v6 2/4] dt-bindings: riscv: Add Svade and Svadu Entries
2024-06-28 16:19 ` Conor Dooley
@ 2024-06-29 13:09 ` Jessica Clarke
2024-06-30 14:09 ` Conor Dooley
0 siblings, 1 reply; 9+ messages in thread
From: Jessica Clarke @ 2024-06-29 13:09 UTC (permalink / raw)
To: Conor Dooley
Cc: Yong-Xuan Wang, LKML, linux-riscv, kvm-riscv, kvm, Greentime Hu,
Vincent Chen, Rob Herring, Krzysztof Kozlowski, Paul Walmsley,
Palmer Dabbelt, Albert Ou,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
On 28 Jun 2024, at 17:19, Conor Dooley <conor@kernel.org> wrote:
>
> On Fri, Jun 28, 2024 at 05:37:06PM +0800, Yong-Xuan Wang wrote:
>> Add entries for the Svade and Svadu extensions to the riscv,isa-extensions
>> property.
>>
>> Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
>> ---
>> .../devicetree/bindings/riscv/extensions.yaml | 28 +++++++++++++++++++
>> 1 file changed, 28 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml
>> index 468c646247aa..c3d053ce7783 100644
>> --- a/Documentation/devicetree/bindings/riscv/extensions.yaml
>> +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
>> @@ -153,6 +153,34 @@ properties:
>> ratified at commit 3f9ed34 ("Add ability to manually trigger
>> workflow. (#2)") of riscv-time-compare.
>>
>> + - const: svade
>> + description: |
>> + The standard Svade supervisor-level extension for SW-managed PTE A/D
>> + bit updates as ratified in the 20240213 version of the privileged
>> + ISA specification.
>> +
>> + Both Svade and Svadu extensions control the hardware behavior when
>> + the PTE A/D bits need to be set. The default behavior for the four
>> + possible combinations of these extensions in the device tree are:
>> + 1) Neither Svade nor Svadu present in DT =>
>
>> It is technically
>> + unknown whether the platform uses Svade or Svadu. Supervisor may
>> + assume Svade to be present and enabled or it can discover based
>> + on mvendorid, marchid, and mimpid.
>
> I would just write "for backwards compatibility, if neither Svade nor
> Svadu appear in the devicetree the supervisor may assume Svade to be
> present and enabled". If there are systems that this behaviour causes
> problems for, we can deal with them iff they appear. I don't think
> looking at m*id would be sufficient here anyway, since the firmware can
> have an impact. I'd just drop that part entirely.
Older QEMU falls into that category, as do Bluespec’s soft-cores (which
ours are derived from at Cambridge). I feel that, in reality, one
should be prepared to handle both trapping and atomic updates if
writing an OS that aims to support case 1.
Jess
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v6 2/4] dt-bindings: riscv: Add Svade and Svadu Entries
2024-06-29 13:09 ` Jessica Clarke
@ 2024-06-30 14:09 ` Conor Dooley
2024-07-11 10:34 ` Yong-Xuan Wang
0 siblings, 1 reply; 9+ messages in thread
From: Conor Dooley @ 2024-06-30 14:09 UTC (permalink / raw)
To: Jessica Clarke
Cc: Yong-Xuan Wang, LKML, linux-riscv, kvm-riscv, kvm, Greentime Hu,
Vincent Chen, Rob Herring, Krzysztof Kozlowski, Paul Walmsley,
Palmer Dabbelt, Albert Ou,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
[-- Attachment #1.1: Type: text/plain, Size: 2875 bytes --]
On Sat, Jun 29, 2024 at 02:09:34PM +0100, Jessica Clarke wrote:
> On 28 Jun 2024, at 17:19, Conor Dooley <conor@kernel.org> wrote:
> >
> > On Fri, Jun 28, 2024 at 05:37:06PM +0800, Yong-Xuan Wang wrote:
> >> Add entries for the Svade and Svadu extensions to the riscv,isa-extensions
> >> property.
> >>
> >> Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
> >> ---
> >> .../devicetree/bindings/riscv/extensions.yaml | 28 +++++++++++++++++++
> >> 1 file changed, 28 insertions(+)
> >>
> >> diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml
> >> index 468c646247aa..c3d053ce7783 100644
> >> --- a/Documentation/devicetree/bindings/riscv/extensions.yaml
> >> +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
> >> @@ -153,6 +153,34 @@ properties:
> >> ratified at commit 3f9ed34 ("Add ability to manually trigger
> >> workflow. (#2)") of riscv-time-compare.
> >>
> >> + - const: svade
> >> + description: |
> >> + The standard Svade supervisor-level extension for SW-managed PTE A/D
> >> + bit updates as ratified in the 20240213 version of the privileged
> >> + ISA specification.
> >> +
> >> + Both Svade and Svadu extensions control the hardware behavior when
> >> + the PTE A/D bits need to be set. The default behavior for the four
> >> + possible combinations of these extensions in the device tree are:
> >> + 1) Neither Svade nor Svadu present in DT =>
> >
> >> It is technically
> >> + unknown whether the platform uses Svade or Svadu. Supervisor may
> >> + assume Svade to be present and enabled or it can discover based
> >> + on mvendorid, marchid, and mimpid.
> >
> > I would just write "for backwards compatibility, if neither Svade nor
> > Svadu appear in the devicetree the supervisor may assume Svade to be
> > present and enabled". If there are systems that this behaviour causes
> > problems for, we can deal with them iff they appear. I don't think
> > looking at m*id would be sufficient here anyway, since the firmware can
> > have an impact. I'd just drop that part entirely.
>
> Older QEMU falls into that category, as do Bluespec’s soft-cores (which
> ours are derived from at Cambridge). I feel that, in reality, one
> should be prepared to handle both trapping and atomic updates if
> writing an OS that aims to support case 1.
I guess that is actually what we should put in then, to use an
approximation of your wording, something like
Neither Svade nor Svadu present in DT => Supervisor software should be
prepared to handle either hardware updating of the PTE A/D bits or page
faults when they need updated
?
[-- 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] 9+ messages in thread
* Re: [PATCH v6 2/4] dt-bindings: riscv: Add Svade and Svadu Entries
2024-06-30 14:09 ` Conor Dooley
@ 2024-07-11 10:34 ` Yong-Xuan Wang
0 siblings, 0 replies; 9+ messages in thread
From: Yong-Xuan Wang @ 2024-07-11 10:34 UTC (permalink / raw)
To: Conor Dooley
Cc: Jessica Clarke, LKML, linux-riscv, kvm-riscv, kvm, Greentime Hu,
Vincent Chen, Rob Herring, Krzysztof Kozlowski, Paul Walmsley,
Palmer Dabbelt, Albert Ou,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
Hi Conor and Jessica,
On Sun, Jun 30, 2024 at 10:09 PM Conor Dooley <conor@kernel.org> wrote:
>
> On Sat, Jun 29, 2024 at 02:09:34PM +0100, Jessica Clarke wrote:
> > On 28 Jun 2024, at 17:19, Conor Dooley <conor@kernel.org> wrote:
> > >
> > > On Fri, Jun 28, 2024 at 05:37:06PM +0800, Yong-Xuan Wang wrote:
> > >> Add entries for the Svade and Svadu extensions to the riscv,isa-extensions
> > >> property.
> > >>
> > >> Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
> > >> ---
> > >> .../devicetree/bindings/riscv/extensions.yaml | 28 +++++++++++++++++++
> > >> 1 file changed, 28 insertions(+)
> > >>
> > >> diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml
> > >> index 468c646247aa..c3d053ce7783 100644
> > >> --- a/Documentation/devicetree/bindings/riscv/extensions.yaml
> > >> +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
> > >> @@ -153,6 +153,34 @@ properties:
> > >> ratified at commit 3f9ed34 ("Add ability to manually trigger
> > >> workflow. (#2)") of riscv-time-compare.
> > >>
> > >> + - const: svade
> > >> + description: |
> > >> + The standard Svade supervisor-level extension for SW-managed PTE A/D
> > >> + bit updates as ratified in the 20240213 version of the privileged
> > >> + ISA specification.
> > >> +
> > >> + Both Svade and Svadu extensions control the hardware behavior when
> > >> + the PTE A/D bits need to be set. The default behavior for the four
> > >> + possible combinations of these extensions in the device tree are:
> > >> + 1) Neither Svade nor Svadu present in DT =>
> > >
> > >> It is technically
> > >> + unknown whether the platform uses Svade or Svadu. Supervisor may
> > >> + assume Svade to be present and enabled or it can discover based
> > >> + on mvendorid, marchid, and mimpid.
> > >
> > > I would just write "for backwards compatibility, if neither Svade nor
> > > Svadu appear in the devicetree the supervisor may assume Svade to be
> > > present and enabled". If there are systems that this behaviour causes
> > > problems for, we can deal with them iff they appear. I don't think
> > > looking at m*id would be sufficient here anyway, since the firmware can
> > > have an impact. I'd just drop that part entirely.
> >
> > Older QEMU falls into that category, as do Bluespec’s soft-cores (which
> > ours are derived from at Cambridge). I feel that, in reality, one
> > should be prepared to handle both trapping and atomic updates if
> > writing an OS that aims to support case 1.
>
> I guess that is actually what we should put in then, to use an
> approximation of your wording, something like
> Neither Svade nor Svadu present in DT => Supervisor software should be
> prepared to handle either hardware updating of the PTE A/D bits or page
> faults when they need updated
> ?
Thank you! I will update in the next version.
Regards,
Yong-Xuan
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-07-11 10:35 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-28 9:37 [PATCH v6 0/4] Add Svade and Svadu Extensions Support Yong-Xuan Wang
2024-06-28 9:37 ` [PATCH v6 1/4] RISC-V: " Yong-Xuan Wang
2024-06-28 9:37 ` [PATCH v6 2/4] dt-bindings: riscv: Add Svade and Svadu Entries Yong-Xuan Wang
2024-06-28 16:19 ` Conor Dooley
2024-06-29 13:09 ` Jessica Clarke
2024-06-30 14:09 ` Conor Dooley
2024-07-11 10:34 ` Yong-Xuan Wang
2024-06-28 9:37 ` [PATCH v6 3/4] RISC-V: KVM: Add Svade and Svadu Extensions Support for Guest/VM Yong-Xuan Wang
2024-06-28 9:37 ` [PATCH v6 4/4] KVM: riscv: selftests: Add Svade and Svadu Extension to get-reg-list test Yong-Xuan Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox