From: Andrew Jones <ajones@ventanamicro.com>
To: Yong-Xuan Wang <yongxuan.wang@sifive.com>
Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
kvm-riscv@lists.infradead.org, kvm@vger.kernel.org,
apatel@ventanamicro.com, alex@ghiti.fr, greentime.hu@sifive.com,
vincent.chen@sifive.com, Anup Patel <anup@brainfault.org>,
Atish Patra <atishp@atishpatra.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>
Subject: Re: [PATCH v5 3/4] RISC-V: KVM: Add Svade and Svadu Extensions Support for Guest/VM
Date: Fri, 21 Jun 2024 10:52:16 +0200 [thread overview]
Message-ID: <20240621-2c3ffd345cba1317bc0f5f9d@orel> (raw)
In-Reply-To: <20240605121512.32083-4-yongxuan.wang@sifive.com>
On Wed, Jun 05, 2024 at 08:15:09PM GMT, Yong-Xuan Wang wrote:
> 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 only when arch_has_hw_pte_young()
> is true.
>
> Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
> ---
> arch/riscv/include/uapi/asm/kvm.h | 2 ++
> arch/riscv/kvm/vcpu.c | 6 ++++++
> arch/riscv/kvm/vcpu_onereg.c | 6 ++++++
> 3 files changed, 14 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..21edd60c4756 100644
> --- a/arch/riscv/kvm/vcpu.c
> +++ b/arch/riscv/kvm/vcpu.c
> @@ -540,6 +540,12 @@ 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_isa_extension_available(isa, SVADE))
> + cfg->henvcfg &= ~ENVCFG_ADUE;
nit: I'd write this as
if (!riscv_isa_extension_available(isa, SVADE) &&
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 c676275ea0a0..06e930f1e206 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,9 @@ 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. */
> + return arch_has_hw_pte_young();
> default:
> break;
> }
> --
> 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
next prev parent reply other threads:[~2024-06-21 8:52 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 12:15 [PATCH v5 0/4] Add Svade and Svadu Extensions Support Yong-Xuan Wang
2024-06-05 12:15 ` [PATCH v5 1/4] RISC-V: " Yong-Xuan Wang
2024-06-21 7:52 ` Alexandre Ghiti
2024-06-21 8:01 ` Conor Dooley
2024-06-21 8:06 ` Alexandre Ghiti
2024-06-21 8:43 ` Andrew Jones
2024-06-21 10:24 ` Conor Dooley
2024-06-21 10:31 ` Alexandre Ghiti
2024-06-21 10:42 ` Andrew Jones
2024-06-21 11:00 ` Conor Dooley
2024-06-21 12:06 ` Andrew Jones
2024-06-25 10:37 ` Yong-Xuan Wang
2024-06-05 12:15 ` [PATCH v5 2/4] dt-bindings: riscv: Add Svade and Svadu Entries Yong-Xuan Wang
2024-06-05 16:54 ` Conor Dooley
2024-06-18 10:38 ` Yong-Xuan Wang
2024-06-19 18:11 ` Conor Dooley
2024-06-20 6:25 ` Anup Patel
2024-06-21 8:33 ` Andrew Jones
2024-06-21 10:11 ` Conor Dooley
2024-06-25 10:15 ` Yong-Xuan Wang
2024-06-21 8:37 ` Alexandre Ghiti
2024-06-21 10:17 ` Conor Dooley
2024-06-21 12:42 ` Alexandre Ghiti
2024-06-21 13:15 ` Andrew Jones
2024-06-21 14:04 ` Conor Dooley
2024-06-21 14:52 ` Andrew Jones
2024-06-21 14:58 ` Conor Dooley
2024-06-21 15:08 ` Andrew Jones
2024-06-22 12:01 ` Conor Dooley
2024-06-25 10:17 ` Yong-Xuan Wang
2024-06-25 10:19 ` Andrew Jones
2024-06-21 7:56 ` Alexandre Ghiti
2024-06-05 12:15 ` [PATCH v5 3/4] RISC-V: KVM: Add Svade and Svadu Extensions Support for Guest/VM Yong-Xuan Wang
2024-06-21 8:52 ` Andrew Jones [this message]
2024-06-05 12:15 ` [PATCH v5 4/4] KVM: riscv: selftests: Add Svade and Svadu Extension to get-reg-list test Yong-Xuan Wang
2024-06-21 8:53 ` Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240621-2c3ffd345cba1317bc0f5f9d@orel \
--to=ajones@ventanamicro.com \
--cc=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=apatel@ventanamicro.com \
--cc=atishp@atishpatra.org \
--cc=greentime.hu@sifive.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=vincent.chen@sifive.com \
--cc=yongxuan.wang@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox