RISC-V: KVM: Add SBI FWFT validation support

Since the KVM SBI has extension parameters validation support,
implement it for the SBI FWFT support.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260729232527.139183-3-inochiama@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Inochi Amaoto 2026-07-30 07:25:23 +08:00 committed by Anup Patel
parent e4f24f9a90
commit b88cb6998f

View File

@ -600,6 +600,30 @@ static void kvm_sbi_ext_fwft_reset(struct kvm_vcpu *vcpu)
}
}
static void kvm_sbi_ext_fwft_validate(struct kvm_vcpu *vcpu)
{
struct kvm_sbi_fwft *fwft = vcpu_to_fwft(vcpu);
const struct kvm_sbi_fwft_feature *feature;
struct kvm_sbi_fwft_config *conf;
int i;
for (i = 0; i < ARRAY_SIZE(features); i++) {
feature = &features[i];
conf = &fwft->configs[i];
if (!conf->supported)
continue;
if (!feature->supported || feature->supported(vcpu))
continue;
conf->enabled = false;
conf->flags = 0;
if (feature->reset)
feature->reset(vcpu);
}
}
static unsigned long kvm_sbi_ext_fwft_get_reg_count(struct kvm_vcpu *vcpu)
{
unsigned long max_reg_count = sizeof(struct kvm_riscv_sbi_fwft) / sizeof(unsigned long);
@ -752,6 +776,7 @@ const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_fwft = {
.init = kvm_sbi_ext_fwft_init,
.deinit = kvm_sbi_ext_fwft_deinit,
.reset = kvm_sbi_ext_fwft_reset,
.validate = kvm_sbi_ext_fwft_validate,
.state_reg_subtype = KVM_REG_RISCV_SBI_FWFT,
.get_state_reg_count = kvm_sbi_ext_fwft_get_reg_count,
.get_state_reg_id = kvm_sbi_ext_fwft_get_reg_id,