[PATCH v2 2/3] RISC-V: KVM: Add SBI FWFT validation support

Anup Patel anup at brainfault.org
Wed Jul 29 00:59:54 PDT 2026


On Mon, Jul 6, 2026 at 7:42 AM Inochi Amaoto <inochiama at gmail.com> wrote:
>
> Since the KVM SBI has extension parameters validation support,
> implement it for the SBI FWFT support.
>
> Signed-off-by: Inochi Amaoto <inochiama at gmail.com>

LGTM.

Reviewed-by: Anup Patel <anup at brainfault.org>

Thanks,
Anup

> ---
>  arch/riscv/kvm/vcpu_sbi_fwft.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
>
> diff --git a/arch/riscv/kvm/vcpu_sbi_fwft.c b/arch/riscv/kvm/vcpu_sbi_fwft.c
> index bc514ae6521d..0aa1f9a57c90 100644
> --- a/arch/riscv/kvm/vcpu_sbi_fwft.c
> +++ b/arch/riscv/kvm/vcpu_sbi_fwft.c
> @@ -604,6 +604,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);
> @@ -756,6 +780,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,
> --
> 2.55.0
>



More information about the linux-riscv mailing list