* [PATCH RFC v2 0/3] riscv: add Svukte extension
@ 2024-09-27 13:41 Max Hsu
2024-09-27 13:41 ` [PATCH RFC v2 1/3] dt-bindings: riscv: Add Svukte entry Max Hsu
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Max Hsu @ 2024-09-27 13:41 UTC (permalink / raw)
To: Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Anup Patel, Atish Patra
Cc: Palmer Dabbelt, linux-riscv, devicetree, linux-kernel, kvm,
kvm-riscv, Max Hsu, Samuel Holland
RISC-V privileged spec will be added with Svukte extension [1]
Svukte introduce senvcfg.UKTE and hstatus.HUKTE bitfield.
which makes user-mode access to supervisor memory raise page faults
in constant time, mitigating attacks that attempt to discover the
supervisor software's address-space layout.
The following patches add
- dt-binding of Svukte ISA string
- CSR bit definition, ISA detection, senvcfg.UKTE enablement in kernel
- KVM ONE_REG support for Svukte extension
Changes in v2:
- rebase on riscv/for-next (riscv-for-linus-6.12-mw1)
- modify the description of dt-binding on Svukte ISA string
- Link to v1: https://lore.kernel.org/all/20240920-dev-maxh-svukte-rebase-v1-0-7864a88a62bd@sifive.com/
Link: https://github.com/riscv/riscv-isa-manual/pull/1564 [1]
Signed-off-by: Max Hsu <max.hsu@sifive.com>
---
Max Hsu (3):
dt-bindings: riscv: Add Svukte entry
riscv: Add Svukte extension support
riscv: KVM: Add Svukte extension support for Guest/VM
Documentation/devicetree/bindings/riscv/extensions.yaml | 9 +++++++++
arch/riscv/include/asm/csr.h | 2 ++
arch/riscv/include/asm/hwcap.h | 1 +
arch/riscv/include/uapi/asm/kvm.h | 1 +
arch/riscv/kernel/cpufeature.c | 4 ++++
arch/riscv/kvm/vcpu_onereg.c | 1 +
6 files changed, 18 insertions(+)
---
base-commit: b3f835cd7339919561866252a11831ead72e7073
change-id: 20240927-dev-maxh-svukte-rebase-2-5c4d296d1940
Best regards,
--
Max Hsu <max.hsu@sifive.com>
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH RFC v2 1/3] dt-bindings: riscv: Add Svukte entry 2024-09-27 13:41 [PATCH RFC v2 0/3] riscv: add Svukte extension Max Hsu @ 2024-09-27 13:41 ` Max Hsu 2024-09-30 17:04 ` Deepak Gupta 2024-09-27 13:41 ` [PATCH RFC v2 2/3] riscv: Add Svukte extension support Max Hsu 2024-09-27 13:41 ` [PATCH RFC v2 3/3] riscv: KVM: Add Svukte extension support for Guest/VM Max Hsu 2 siblings, 1 reply; 10+ messages in thread From: Max Hsu @ 2024-09-27 13:41 UTC (permalink / raw) To: Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, Anup Patel, Atish Patra Cc: Palmer Dabbelt, linux-riscv, devicetree, linux-kernel, kvm, kvm-riscv, Max Hsu, Samuel Holland Add an entry for the Svukte extension to the riscv,isa-extensions property. Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Max Hsu <max.hsu@sifive.com> --- Documentation/devicetree/bindings/riscv/extensions.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml index 2cf2026cff574d39793157418a4d4211df87315f..9f730e3aaae949debc18396183b989b504dcb899 100644 --- a/Documentation/devicetree/bindings/riscv/extensions.yaml +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml @@ -171,6 +171,15 @@ properties: memory types as ratified in the 20191213 version of the privileged ISA specification. + - const: svukte + description: + The standard Svukte supervisor-level extensions for making user-mode + accesses to supervisor memory raise page faults in constant time, + mitigating attacks that attempt to discover the supervisor + software's address-space layout. Currently under review as Pull + Request number 1564 at commit 81dc9277 ("Svukte v0.3") of + riscv-isa-manual. + - const: svvptc description: The standard Svvptc supervisor-level extension for -- 2.43.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH RFC v2 1/3] dt-bindings: riscv: Add Svukte entry 2024-09-27 13:41 ` [PATCH RFC v2 1/3] dt-bindings: riscv: Add Svukte entry Max Hsu @ 2024-09-30 17:04 ` Deepak Gupta 0 siblings, 0 replies; 10+ messages in thread From: Deepak Gupta @ 2024-09-30 17:04 UTC (permalink / raw) To: Max Hsu Cc: Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, Anup Patel, Atish Patra, Palmer Dabbelt, linux-riscv, devicetree, linux-kernel, kvm, kvm-riscv, Samuel Holland On Fri, Sep 27, 2024 at 09:41:43PM +0800, Max Hsu wrote: >Add an entry for the Svukte extension to the riscv,isa-extensions >property. > >Reviewed-by: Samuel Holland <samuel.holland@sifive.com> >Signed-off-by: Max Hsu <max.hsu@sifive.com> >--- > Documentation/devicetree/bindings/riscv/extensions.yaml | 9 +++++++++ > 1 file changed, 9 insertions(+) > >diff --git a/Documentation/devicetree/bindings/riscv/extensions.yaml b/Documentation/devicetree/bindings/riscv/extensions.yaml >index 2cf2026cff574d39793157418a4d4211df87315f..9f730e3aaae949debc18396183b989b504dcb899 100644 >--- a/Documentation/devicetree/bindings/riscv/extensions.yaml >+++ b/Documentation/devicetree/bindings/riscv/extensions.yaml >@@ -171,6 +171,15 @@ properties: > memory types as ratified in the 20191213 version of the privileged > ISA specification. > >+ - const: svukte >+ description: >+ The standard Svukte supervisor-level extensions for making user-mode >+ accesses to supervisor memory raise page faults in constant time, >+ mitigating attacks that attempt to discover the supervisor >+ software's address-space layout. Currently under review as Pull >+ Request number 1564 at commit 81dc9277 ("Svukte v0.3") of >+ riscv-isa-manual. Reviewed-by: Deepak Gupta <debug@rivosinc.com> >+ > - const: svvptc > description: > The standard Svvptc supervisor-level extension for > >-- >2.43.2 > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH RFC v2 2/3] riscv: Add Svukte extension support 2024-09-27 13:41 [PATCH RFC v2 0/3] riscv: add Svukte extension Max Hsu 2024-09-27 13:41 ` [PATCH RFC v2 1/3] dt-bindings: riscv: Add Svukte entry Max Hsu @ 2024-09-27 13:41 ` Max Hsu 2024-09-30 17:10 ` Deepak Gupta 2024-09-27 13:41 ` [PATCH RFC v2 3/3] riscv: KVM: Add Svukte extension support for Guest/VM Max Hsu 2 siblings, 1 reply; 10+ messages in thread From: Max Hsu @ 2024-09-27 13:41 UTC (permalink / raw) To: Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, Anup Patel, Atish Patra Cc: Palmer Dabbelt, linux-riscv, devicetree, linux-kernel, kvm, kvm-riscv, Max Hsu, Samuel Holland Svukte extension introduce senvcfg.UKTE, hstatus.HUKTE. This patch add CSR bit definition, and detects if Svukte ISA extension is available, cpufeature will set the correspond bit field so the svukte-qualified memory accesses are protected in a manner that is timing-independent of the faulting virtual address. Since hstatus.HU is not enabled by linux, enabling hstatus.HUKTE will not be affective. This patch depends on patch "riscv: Per-thread envcfg CSR support" [1] Link: https://lore.kernel.org/linux-riscv/20240814081126.956287-1-samuel.holland@sifive.com/ [1] Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Max Hsu <max.hsu@sifive.com> --- arch/riscv/include/asm/csr.h | 2 ++ arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/kernel/cpufeature.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 25966995da04e090ff22a11e35be9bc24712f1a8..62b50667d539c50a0bfdadd1c6ab06cda948f6a8 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -122,6 +122,7 @@ #define HSTATUS_VSXL _AC(0x300000000, UL) #define HSTATUS_VSXL_SHIFT 32 #endif +#define HSTATUS_HUKTE _AC(0x01000000, UL) #define HSTATUS_VTSR _AC(0x00400000, UL) #define HSTATUS_VTW _AC(0x00200000, UL) #define HSTATUS_VTVM _AC(0x00100000, UL) @@ -195,6 +196,7 @@ /* xENVCFG flags */ #define ENVCFG_STCE (_AC(1, ULL) << 63) #define ENVCFG_PBMTE (_AC(1, ULL) << 62) +#define ENVCFG_UKTE (_AC(1, UL) << 8) #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 46d9de54179ed40aa7b1ea0ec011fd6eea7218df..3591a4f40131ff5958c07857a1bd1624723d6550 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -93,6 +93,7 @@ #define RISCV_ISA_EXT_ZCMOP 84 #define RISCV_ISA_EXT_ZAWRS 85 #define RISCV_ISA_EXT_SVVPTC 86 +#define RISCV_ISA_EXT_SVUKTE 87 #define RISCV_ISA_EXT_XLINUXENVCFG 127 diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 3a8eeaa9310c32fce2141aff534dc4432b32abbe..e0853cae1dc0ba844d5969a42c30d44287e3250a 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -381,6 +381,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __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), + __RISCV_ISA_EXT_SUPERSET(svukte, RISCV_ISA_EXT_SVUKTE, riscv_xlinuxenvcfg_exts), __RISCV_ISA_EXT_DATA(svvptc, RISCV_ISA_EXT_SVVPTC), }; @@ -921,6 +922,9 @@ void riscv_user_isa_enable(void) { if (riscv_cpu_has_extension_unlikely(smp_processor_id(), RISCV_ISA_EXT_ZICBOZ)) csr_set(CSR_ENVCFG, ENVCFG_CBZE); + + if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SVUKTE)) + current->thread.envcfg |= ENVCFG_UKTE; } #ifdef CONFIG_RISCV_ALTERNATIVE -- 2.43.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH RFC v2 2/3] riscv: Add Svukte extension support 2024-09-27 13:41 ` [PATCH RFC v2 2/3] riscv: Add Svukte extension support Max Hsu @ 2024-09-30 17:10 ` Deepak Gupta 0 siblings, 0 replies; 10+ messages in thread From: Deepak Gupta @ 2024-09-30 17:10 UTC (permalink / raw) To: Max Hsu Cc: Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, Anup Patel, Atish Patra, Palmer Dabbelt, linux-riscv, devicetree, linux-kernel, kvm, kvm-riscv, Samuel Holland On Fri, Sep 27, 2024 at 09:41:44PM +0800, Max Hsu wrote: >Svukte extension introduce senvcfg.UKTE, hstatus.HUKTE. > >This patch add CSR bit definition, and detects if Svukte ISA extension >is available, cpufeature will set the correspond bit field so the >svukte-qualified memory accesses are protected in a manner that is >timing-independent of the faulting virtual address. > >Since hstatus.HU is not enabled by linux, enabling hstatus.HUKTE will >not be affective. > >This patch depends on patch "riscv: Per-thread envcfg CSR support" [1] > >Link: https://lore.kernel.org/linux-riscv/20240814081126.956287-1-samuel.holland@sifive.com/ [1] > >Reviewed-by: Samuel Holland <samuel.holland@sifive.com> >Signed-off-by: Max Hsu <max.hsu@sifive.com> >--- > arch/riscv/include/asm/csr.h | 2 ++ > arch/riscv/include/asm/hwcap.h | 1 + > arch/riscv/kernel/cpufeature.c | 4 ++++ > 3 files changed, 7 insertions(+) > >diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h >index 25966995da04e090ff22a11e35be9bc24712f1a8..62b50667d539c50a0bfdadd1c6ab06cda948f6a8 100644 >--- a/arch/riscv/include/asm/csr.h >+++ b/arch/riscv/include/asm/csr.h >@@ -122,6 +122,7 @@ > #define HSTATUS_VSXL _AC(0x300000000, UL) > #define HSTATUS_VSXL_SHIFT 32 > #endif >+#define HSTATUS_HUKTE _AC(0x01000000, UL) > #define HSTATUS_VTSR _AC(0x00400000, UL) > #define HSTATUS_VTW _AC(0x00200000, UL) > #define HSTATUS_VTVM _AC(0x00100000, UL) >@@ -195,6 +196,7 @@ > /* xENVCFG flags */ > #define ENVCFG_STCE (_AC(1, ULL) << 63) > #define ENVCFG_PBMTE (_AC(1, ULL) << 62) >+#define ENVCFG_UKTE (_AC(1, UL) << 8) > #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 46d9de54179ed40aa7b1ea0ec011fd6eea7218df..3591a4f40131ff5958c07857a1bd1624723d6550 100644 >--- a/arch/riscv/include/asm/hwcap.h >+++ b/arch/riscv/include/asm/hwcap.h >@@ -93,6 +93,7 @@ > #define RISCV_ISA_EXT_ZCMOP 84 > #define RISCV_ISA_EXT_ZAWRS 85 > #define RISCV_ISA_EXT_SVVPTC 86 >+#define RISCV_ISA_EXT_SVUKTE 87 > > #define RISCV_ISA_EXT_XLINUXENVCFG 127 > >diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c >index 3a8eeaa9310c32fce2141aff534dc4432b32abbe..e0853cae1dc0ba844d5969a42c30d44287e3250a 100644 >--- a/arch/riscv/kernel/cpufeature.c >+++ b/arch/riscv/kernel/cpufeature.c >@@ -381,6 +381,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { > __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), >+ __RISCV_ISA_EXT_SUPERSET(svukte, RISCV_ISA_EXT_SVUKTE, riscv_xlinuxenvcfg_exts), > __RISCV_ISA_EXT_DATA(svvptc, RISCV_ISA_EXT_SVVPTC), > }; > >@@ -921,6 +922,9 @@ void riscv_user_isa_enable(void) > { > if (riscv_cpu_has_extension_unlikely(smp_processor_id(), RISCV_ISA_EXT_ZICBOZ)) > csr_set(CSR_ENVCFG, ENVCFG_CBZE); >+ >+ if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SVUKTE)) >+ current->thread.envcfg |= ENVCFG_UKTE; Pending merge of samuel's patches, this looks good to me. Reviewed-by: Deepak Gupta <debug@rivosinc.com> > } > > #ifdef CONFIG_RISCV_ALTERNATIVE > >-- >2.43.2 > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH RFC v2 3/3] riscv: KVM: Add Svukte extension support for Guest/VM 2024-09-27 13:41 [PATCH RFC v2 0/3] riscv: add Svukte extension Max Hsu 2024-09-27 13:41 ` [PATCH RFC v2 1/3] dt-bindings: riscv: Add Svukte entry Max Hsu 2024-09-27 13:41 ` [PATCH RFC v2 2/3] riscv: Add Svukte extension support Max Hsu @ 2024-09-27 13:41 ` Max Hsu 2024-10-24 19:16 ` Anup Patel 2 siblings, 1 reply; 10+ messages in thread From: Max Hsu @ 2024-09-27 13:41 UTC (permalink / raw) To: Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, Anup Patel, Atish Patra Cc: Palmer Dabbelt, linux-riscv, devicetree, linux-kernel, kvm, kvm-riscv, Max Hsu, Samuel Holland Add KVM ISA extension ONE_REG interface to allow VMM tools to detect and enable Svukte extension for Guest/VM. Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Max Hsu <max.hsu@sifive.com> --- arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kvm/vcpu_onereg.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h index e97db3296456e19f79ca02e4c4f70ae1b4abb48b..41b466b7ffaec421e8389d3f5b178580091a2c98 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -175,6 +175,7 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_ZCF, KVM_RISCV_ISA_EXT_ZCMOP, KVM_RISCV_ISA_EXT_ZAWRS, + KVM_RISCV_ISA_EXT_SVUKTE, KVM_RISCV_ISA_EXT_MAX, }; diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c index b319c4c13c54ce22d2a7552f4c9f256a0c50780e..67237d6e53882a9fcd2cf265aa1704f25cc4a701 100644 --- a/arch/riscv/kvm/vcpu_onereg.c +++ b/arch/riscv/kvm/vcpu_onereg.c @@ -41,6 +41,7 @@ static const unsigned long kvm_isa_ext_arr[] = { KVM_ISA_EXT_ARR(SVINVAL), KVM_ISA_EXT_ARR(SVNAPOT), KVM_ISA_EXT_ARR(SVPBMT), + KVM_ISA_EXT_ARR(SVUKTE), KVM_ISA_EXT_ARR(ZACAS), KVM_ISA_EXT_ARR(ZAWRS), KVM_ISA_EXT_ARR(ZBA), -- 2.43.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH RFC v2 3/3] riscv: KVM: Add Svukte extension support for Guest/VM 2024-09-27 13:41 ` [PATCH RFC v2 3/3] riscv: KVM: Add Svukte extension support for Guest/VM Max Hsu @ 2024-10-24 19:16 ` Anup Patel 2024-11-04 7:44 ` Max Hsu 0 siblings, 1 reply; 10+ messages in thread From: Anup Patel @ 2024-10-24 19:16 UTC (permalink / raw) To: Max Hsu Cc: Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, Atish Patra, Palmer Dabbelt, linux-riscv, devicetree, linux-kernel, kvm, kvm-riscv, Samuel Holland On Fri, Sep 27, 2024 at 7:12 PM Max Hsu <max.hsu@sifive.com> wrote: > > Add KVM ISA extension ONE_REG interface to allow VMM tools to > detect and enable Svukte extension for Guest/VM. > > Reviewed-by: Samuel Holland <samuel.holland@sifive.com> > Signed-off-by: Max Hsu <max.hsu@sifive.com> > --- > arch/riscv/include/uapi/asm/kvm.h | 1 + > arch/riscv/kvm/vcpu_onereg.c | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h > index e97db3296456e19f79ca02e4c4f70ae1b4abb48b..41b466b7ffaec421e8389d3f5b178580091a2c98 100644 > --- a/arch/riscv/include/uapi/asm/kvm.h > +++ b/arch/riscv/include/uapi/asm/kvm.h > @@ -175,6 +175,7 @@ enum KVM_RISCV_ISA_EXT_ID { > KVM_RISCV_ISA_EXT_ZCF, > KVM_RISCV_ISA_EXT_ZCMOP, > KVM_RISCV_ISA_EXT_ZAWRS, > + KVM_RISCV_ISA_EXT_SVUKTE, > KVM_RISCV_ISA_EXT_MAX, > }; > > diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c > index b319c4c13c54ce22d2a7552f4c9f256a0c50780e..67237d6e53882a9fcd2cf265aa1704f25cc4a701 100644 > --- a/arch/riscv/kvm/vcpu_onereg.c > +++ b/arch/riscv/kvm/vcpu_onereg.c > @@ -41,6 +41,7 @@ static const unsigned long kvm_isa_ext_arr[] = { > KVM_ISA_EXT_ARR(SVINVAL), > KVM_ISA_EXT_ARR(SVNAPOT), > KVM_ISA_EXT_ARR(SVPBMT), > + KVM_ISA_EXT_ARR(SVUKTE), > KVM_ISA_EXT_ARR(ZACAS), > KVM_ISA_EXT_ARR(ZAWRS), > KVM_ISA_EXT_ARR(ZBA), The KVM_RISCV_ISA_EXT_SVUKTE should be added to the switch-case in kvm_riscv_vcpu_isa_disable_allowed() because hypervisor seems to have no way to disable Svukte for the Guest when it's available on the Host. Regards, Anup ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH RFC v2 3/3] riscv: KVM: Add Svukte extension support for Guest/VM 2024-10-24 19:16 ` Anup Patel @ 2024-11-04 7:44 ` Max Hsu 2024-11-04 13:19 ` Anup Patel 0 siblings, 1 reply; 10+ messages in thread From: Max Hsu @ 2024-11-04 7:44 UTC (permalink / raw) To: Anup Patel Cc: Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, Atish Patra, Palmer Dabbelt, linux-riscv, devicetree, linux-kernel, kvm, kvm-riscv, Samuel Holland Hi Anup, Thank you for the suggestion. I’m not entirely sure if I fully understand it, but I believe the hypervisor should be able to disable the Svukte extension. Inside the switch-case of kvm_riscv_vcpu_isa_disable_allowed(), the default case breaks and returns true. So that means when the KVM_RISCV_ISA_EXT_SVUKTE passed into kvm_riscv_vcpu_isa_disable_allowed() it will return true. If I've misunderstood, please let me know. Best regards, Max Hsu On Fri, Oct 25, 2024 at 3:17 AM Anup Patel <anup@brainfault.org> wrote: > > On Fri, Sep 27, 2024 at 7:12 PM Max Hsu <max.hsu@sifive.com> wrote: > > > > Add KVM ISA extension ONE_REG interface to allow VMM tools to > > detect and enable Svukte extension for Guest/VM. > > > > Reviewed-by: Samuel Holland <samuel.holland@sifive.com> > > Signed-off-by: Max Hsu <max.hsu@sifive.com> > > --- > > arch/riscv/include/uapi/asm/kvm.h | 1 + > > arch/riscv/kvm/vcpu_onereg.c | 1 + > > 2 files changed, 2 insertions(+) > > > > diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h > > index e97db3296456e19f79ca02e4c4f70ae1b4abb48b..41b466b7ffaec421e8389d3f5b178580091a2c98 100644 > > --- a/arch/riscv/include/uapi/asm/kvm.h > > +++ b/arch/riscv/include/uapi/asm/kvm.h > > @@ -175,6 +175,7 @@ enum KVM_RISCV_ISA_EXT_ID { > > KVM_RISCV_ISA_EXT_ZCF, > > KVM_RISCV_ISA_EXT_ZCMOP, > > KVM_RISCV_ISA_EXT_ZAWRS, > > + KVM_RISCV_ISA_EXT_SVUKTE, > > KVM_RISCV_ISA_EXT_MAX, > > }; > > > > diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c > > index b319c4c13c54ce22d2a7552f4c9f256a0c50780e..67237d6e53882a9fcd2cf265aa1704f25cc4a701 100644 > > --- a/arch/riscv/kvm/vcpu_onereg.c > > +++ b/arch/riscv/kvm/vcpu_onereg.c > > @@ -41,6 +41,7 @@ static const unsigned long kvm_isa_ext_arr[] = { > > KVM_ISA_EXT_ARR(SVINVAL), > > KVM_ISA_EXT_ARR(SVNAPOT), > > KVM_ISA_EXT_ARR(SVPBMT), > > + KVM_ISA_EXT_ARR(SVUKTE), > > KVM_ISA_EXT_ARR(ZACAS), > > KVM_ISA_EXT_ARR(ZAWRS), > > KVM_ISA_EXT_ARR(ZBA), > > The KVM_RISCV_ISA_EXT_SVUKTE should be added to the > switch-case in kvm_riscv_vcpu_isa_disable_allowed() because > hypervisor seems to have no way to disable Svukte for the Guest > when it's available on the Host. > > Regards, > Anup ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH RFC v2 3/3] riscv: KVM: Add Svukte extension support for Guest/VM 2024-11-04 7:44 ` Max Hsu @ 2024-11-04 13:19 ` Anup Patel 2024-11-20 13:52 ` Max Hsu 0 siblings, 1 reply; 10+ messages in thread From: Anup Patel @ 2024-11-04 13:19 UTC (permalink / raw) To: Max Hsu Cc: Anup Patel, Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, Atish Patra, Palmer Dabbelt, linux-riscv, devicetree, linux-kernel, kvm, kvm-riscv, Samuel Holland On Mon, Nov 4, 2024 at 1:14 PM Max Hsu <max.hsu@sifive.com> wrote: > > Hi Anup, > > Thank you for the suggestion. > > I’m not entirely sure if I fully understand it, but I believe the > hypervisor should be able to disable the Svukte extension. > > Inside the switch-case of kvm_riscv_vcpu_isa_disable_allowed(), > the default case breaks and returns true. > > So that means when the KVM_RISCV_ISA_EXT_SVUKTE passed into > kvm_riscv_vcpu_isa_disable_allowed() it will return true. > > If I've misunderstood, please let me know. I don't see any code in this patch which disables/enables Svukte for Guest based on KVM ONE_REG interface. Regards, Anup > > Best regards, > Max Hsu > > On Fri, Oct 25, 2024 at 3:17 AM Anup Patel <anup@brainfault.org> wrote: > > > > On Fri, Sep 27, 2024 at 7:12 PM Max Hsu <max.hsu@sifive.com> wrote: > > > > > > Add KVM ISA extension ONE_REG interface to allow VMM tools to > > > detect and enable Svukte extension for Guest/VM. > > > > > > Reviewed-by: Samuel Holland <samuel.holland@sifive.com> > > > Signed-off-by: Max Hsu <max.hsu@sifive.com> > > > --- > > > arch/riscv/include/uapi/asm/kvm.h | 1 + > > > arch/riscv/kvm/vcpu_onereg.c | 1 + > > > 2 files changed, 2 insertions(+) > > > > > > diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h > > > index e97db3296456e19f79ca02e4c4f70ae1b4abb48b..41b466b7ffaec421e8389d3f5b178580091a2c98 100644 > > > --- a/arch/riscv/include/uapi/asm/kvm.h > > > +++ b/arch/riscv/include/uapi/asm/kvm.h > > > @@ -175,6 +175,7 @@ enum KVM_RISCV_ISA_EXT_ID { > > > KVM_RISCV_ISA_EXT_ZCF, > > > KVM_RISCV_ISA_EXT_ZCMOP, > > > KVM_RISCV_ISA_EXT_ZAWRS, > > > + KVM_RISCV_ISA_EXT_SVUKTE, > > > KVM_RISCV_ISA_EXT_MAX, > > > }; > > > > > > diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c > > > index b319c4c13c54ce22d2a7552f4c9f256a0c50780e..67237d6e53882a9fcd2cf265aa1704f25cc4a701 100644 > > > --- a/arch/riscv/kvm/vcpu_onereg.c > > > +++ b/arch/riscv/kvm/vcpu_onereg.c > > > @@ -41,6 +41,7 @@ static const unsigned long kvm_isa_ext_arr[] = { > > > KVM_ISA_EXT_ARR(SVINVAL), > > > KVM_ISA_EXT_ARR(SVNAPOT), > > > KVM_ISA_EXT_ARR(SVPBMT), > > > + KVM_ISA_EXT_ARR(SVUKTE), > > > KVM_ISA_EXT_ARR(ZACAS), > > > KVM_ISA_EXT_ARR(ZAWRS), > > > KVM_ISA_EXT_ARR(ZBA), > > > > The KVM_RISCV_ISA_EXT_SVUKTE should be added to the > > switch-case in kvm_riscv_vcpu_isa_disable_allowed() because > > hypervisor seems to have no way to disable Svukte for the Guest > > when it's available on the Host. > > > > Regards, > > Anup > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH RFC v2 3/3] riscv: KVM: Add Svukte extension support for Guest/VM 2024-11-04 13:19 ` Anup Patel @ 2024-11-20 13:52 ` Max Hsu 0 siblings, 0 replies; 10+ messages in thread From: Max Hsu @ 2024-11-20 13:52 UTC (permalink / raw) To: Anup Patel Cc: Anup Patel, Conor Dooley, Rob Herring, Krzysztof Kozlowski, Paul Walmsley, Palmer Dabbelt, Albert Ou, Atish Patra, Palmer Dabbelt, linux-riscv, devicetree, linux-kernel, kvm, kvm-riscv, Samuel Holland Hi Anup, From your reply, I think my commit message was misleading. Therefore, I will send RFC v3 patches and explain the guest scenario in the cover letter. Thanks for the suggestion. Best regards, Max Hsu On Mon, Nov 4, 2024 at 9:19 PM Anup Patel <apatel@ventanamicro.com> wrote: > > On Mon, Nov 4, 2024 at 1:14 PM Max Hsu <max.hsu@sifive.com> wrote: > > > > Hi Anup, > > > > Thank you for the suggestion. > > > > I’m not entirely sure if I fully understand it, but I believe the > > hypervisor should be able to disable the Svukte extension. > > > > Inside the switch-case of kvm_riscv_vcpu_isa_disable_allowed(), > > the default case breaks and returns true. > > > > So that means when the KVM_RISCV_ISA_EXT_SVUKTE passed into > > kvm_riscv_vcpu_isa_disable_allowed() it will return true. > > > > If I've misunderstood, please let me know. > > I don't see any code in this patch which disables/enables Svukte for > Guest based on KVM ONE_REG interface. > > Regards, > Anup > > > > > Best regards, > > Max Hsu > > > > On Fri, Oct 25, 2024 at 3:17 AM Anup Patel <anup@brainfault.org> wrote: > > > > > > On Fri, Sep 27, 2024 at 7:12 PM Max Hsu <max.hsu@sifive.com> wrote: > > > > > > > > Add KVM ISA extension ONE_REG interface to allow VMM tools to > > > > detect and enable Svukte extension for Guest/VM. > > > > > > > > Reviewed-by: Samuel Holland <samuel.holland@sifive.com> > > > > Signed-off-by: Max Hsu <max.hsu@sifive.com> > > > > --- > > > > arch/riscv/include/uapi/asm/kvm.h | 1 + > > > > arch/riscv/kvm/vcpu_onereg.c | 1 + > > > > 2 files changed, 2 insertions(+) > > > > > > > > diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h > > > > index e97db3296456e19f79ca02e4c4f70ae1b4abb48b..41b466b7ffaec421e8389d3f5b178580091a2c98 100644 > > > > --- a/arch/riscv/include/uapi/asm/kvm.h > > > > +++ b/arch/riscv/include/uapi/asm/kvm.h > > > > @@ -175,6 +175,7 @@ enum KVM_RISCV_ISA_EXT_ID { > > > > KVM_RISCV_ISA_EXT_ZCF, > > > > KVM_RISCV_ISA_EXT_ZCMOP, > > > > KVM_RISCV_ISA_EXT_ZAWRS, > > > > + KVM_RISCV_ISA_EXT_SVUKTE, > > > > KVM_RISCV_ISA_EXT_MAX, > > > > }; > > > > > > > > diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c > > > > index b319c4c13c54ce22d2a7552f4c9f256a0c50780e..67237d6e53882a9fcd2cf265aa1704f25cc4a701 100644 > > > > --- a/arch/riscv/kvm/vcpu_onereg.c > > > > +++ b/arch/riscv/kvm/vcpu_onereg.c > > > > @@ -41,6 +41,7 @@ static const unsigned long kvm_isa_ext_arr[] = { > > > > KVM_ISA_EXT_ARR(SVINVAL), > > > > KVM_ISA_EXT_ARR(SVNAPOT), > > > > KVM_ISA_EXT_ARR(SVPBMT), > > > > + KVM_ISA_EXT_ARR(SVUKTE), > > > > KVM_ISA_EXT_ARR(ZACAS), > > > > KVM_ISA_EXT_ARR(ZAWRS), > > > > KVM_ISA_EXT_ARR(ZBA), > > > > > > The KVM_RISCV_ISA_EXT_SVUKTE should be added to the > > > switch-case in kvm_riscv_vcpu_isa_disable_allowed() because > > > hypervisor seems to have no way to disable Svukte for the Guest > > > when it's available on the Host. > > > > > > Regards, > > > Anup > > ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-11-20 13:52 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-09-27 13:41 [PATCH RFC v2 0/3] riscv: add Svukte extension Max Hsu 2024-09-27 13:41 ` [PATCH RFC v2 1/3] dt-bindings: riscv: Add Svukte entry Max Hsu 2024-09-30 17:04 ` Deepak Gupta 2024-09-27 13:41 ` [PATCH RFC v2 2/3] riscv: Add Svukte extension support Max Hsu 2024-09-30 17:10 ` Deepak Gupta 2024-09-27 13:41 ` [PATCH RFC v2 3/3] riscv: KVM: Add Svukte extension support for Guest/VM Max Hsu 2024-10-24 19:16 ` Anup Patel 2024-11-04 7:44 ` Max Hsu 2024-11-04 13:19 ` Anup Patel 2024-11-20 13:52 ` Max Hsu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).