From: Yong-Xuan Wang <yongxuan.wang@sifive.com>
To: linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org,
kvm@vger.kernel.org
Cc: greentime.hu@sifive.com, vincent.chen@sifive.com,
cleger@rivosinc.com, alex@ghiti.fr,
Yong-Xuan Wang <yongxuan.wang@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>,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH v4 4/5] RISC-V: KVM: add support for SBI_FWFT_PTE_AD_HW_UPDATING
Date: Fri, 24 May 2024 18:33:04 +0800 [thread overview]
Message-ID: <20240524103307.2684-5-yongxuan.wang@sifive.com> (raw)
In-Reply-To: <20240524103307.2684-1-yongxuan.wang@sifive.com>
Add support for SBI_FWFT_PTE_AD_HW_UPDATING to set the PTE A/D bits
updating behavior for Guest/VM.
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
---
arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h | 2 +-
arch/riscv/kvm/vcpu_sbi_fwft.c | 38 +++++++++++++++++++++-
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h b/arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h
index 7b7bcc5c8fee..3614a44e0a4a 100644
--- a/arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h
+++ b/arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h
@@ -11,7 +11,7 @@
#include <asm/sbi.h>
-#define KVM_SBI_FWFT_FEATURE_COUNT 1
+#define KVM_SBI_FWFT_FEATURE_COUNT 2
struct kvm_sbi_fwft_config;
struct kvm_vcpu;
diff --git a/arch/riscv/kvm/vcpu_sbi_fwft.c b/arch/riscv/kvm/vcpu_sbi_fwft.c
index 89ec263c250d..14ef74023340 100644
--- a/arch/riscv/kvm/vcpu_sbi_fwft.c
+++ b/arch/riscv/kvm/vcpu_sbi_fwft.c
@@ -71,6 +71,36 @@ static int kvm_sbi_fwft_get_misaligned_delegation(struct kvm_vcpu *vcpu,
return SBI_SUCCESS;
}
+static int kvm_sbi_fwft_adue_supported(struct kvm_vcpu *vcpu)
+{
+ if (!riscv_isa_extension_available(vcpu->arch.isa, SVADU))
+ return SBI_ERR_NOT_SUPPORTED;
+
+ return 0;
+}
+
+static int kvm_sbi_fwft_set_adue(struct kvm_vcpu *vcpu, struct kvm_sbi_fwft_config *conf,
+ unsigned long value)
+{
+ if (value)
+ vcpu->arch.cfg.henvcfg |= ENVCFG_ADUE;
+ else
+ vcpu->arch.cfg.henvcfg &= ~ENVCFG_ADUE;
+
+ return SBI_SUCCESS;
+}
+
+static int kvm_sbi_fwft_get_adue(struct kvm_vcpu *vcpu, struct kvm_sbi_fwft_config *conf,
+ unsigned long *value)
+{
+ if (!riscv_isa_extension_available(vcpu->arch.isa, SVADU))
+ return SBI_ERR_NOT_SUPPORTED;
+
+ *value = !!(vcpu->arch.cfg.henvcfg & ENVCFG_ADUE);
+
+ return SBI_SUCCESS;
+}
+
static struct kvm_sbi_fwft_config *
kvm_sbi_fwft_get_config(struct kvm_vcpu *vcpu, enum sbi_fwft_feature_t feature)
{
@@ -177,7 +207,13 @@ static const struct kvm_sbi_fwft_feature features[] = {
.supported = kvm_sbi_fwft_misaligned_delegation_supported,
.set = kvm_sbi_fwft_set_misaligned_delegation,
.get = kvm_sbi_fwft_get_misaligned_delegation,
- }
+ },
+ {
+ .id = SBI_FWFT_PTE_AD_HW_UPDATING,
+ .supported = kvm_sbi_fwft_adue_supported,
+ .set = kvm_sbi_fwft_set_adue,
+ .get = kvm_sbi_fwft_get_adue,
+ },
};
static_assert(ARRAY_SIZE(features) == KVM_SBI_FWFT_FEATURE_COUNT);
--
2.17.1
next prev parent reply other threads:[~2024-05-24 10:33 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240524103307.2684-1-yongxuan.wang@sifive.com>
2024-05-24 10:33 ` [RFC PATCH v4 1/5] RISC-V: Detect and Enable Svadu Extension Support Yong-Xuan Wang
2024-05-27 16:25 ` Andrew Jones
2024-05-29 15:37 ` Yong-Xuan Wang
2024-05-30 8:19 ` Alexandre Ghiti
2024-05-30 8:47 ` Andrew Jones
2024-05-30 9:01 ` Alexandre Ghiti
2024-05-30 9:11 ` Anup Patel
2024-05-30 9:24 ` Andrew Jones
2024-06-03 11:29 ` Alexandre Ghiti
2024-06-03 11:40 ` Anup Patel
2024-06-04 2:26 ` Yong-Xuan Wang
2024-05-30 9:41 ` Yong-Xuan Wang
2024-05-24 10:33 ` [RFC PATCH v4 2/5] dt-bindings: riscv: Add Svadu Entry Yong-Xuan Wang
2024-05-27 15:09 ` Conor Dooley
2024-05-29 9:33 ` Yong-Xuan Wang
2024-05-24 10:33 ` [RFC PATCH v4 3/5] RISC-V: KVM: Add Svadu Extension Support for Guest/VM Yong-Xuan Wang
2024-05-27 16:29 ` Andrew Jones
2024-05-24 10:33 ` Yong-Xuan Wang [this message]
2024-05-27 16:29 ` [RFC PATCH v4 4/5] RISC-V: KVM: add support for SBI_FWFT_PTE_AD_HW_UPDATING Andrew Jones
2024-05-28 10:15 ` Clément Léger
2024-05-29 15:41 ` Yong-Xuan Wang
2024-05-24 10:33 ` [RFC PATCH v4 5/5] KVM: riscv: selftests: Add Svadu Extension to get-reg-list testt Yong-Xuan Wang
2024-05-27 16:29 ` 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=20240524103307.2684-5-yongxuan.wang@sifive.com \
--to=yongxuan.wang@sifive.com \
--cc=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=atishp@atishpatra.org \
--cc=cleger@rivosinc.com \
--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 \
/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
all inboxes | Powered by JetHome®