[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240524103307.2684-5-yongxuan.wang@sifive.com>
Date: Fri, 24 May 2024 18:33:04 +0800
From: Yong-Xuan Wang <yongxuan.wang@...ive.com>
To: linux-riscv@...ts.infradead.org,
kvm-riscv@...ts.infradead.org,
kvm@...r.kernel.org
Cc: greentime.hu@...ive.com,
vincent.chen@...ive.com,
cleger@...osinc.com,
alex@...ti.fr,
Yong-Xuan Wang <yongxuan.wang@...ive.com>,
Anup Patel <anup@...infault.org>,
Atish Patra <atishp@...shpatra.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH v4 4/5] RISC-V: KVM: add support for SBI_FWFT_PTE_AD_HW_UPDATING
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@...ive.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
Powered by blists - more mailing lists