[PATCH] KVM: riscv: SBI FWFT: Apply LOCK flag only on successful set

Anup Patel anup at brainfault.org
Mon Jul 13 01:33:10 PDT 2026


On Wed, Jun 24, 2026 at 6:33 PM SeungJu Cheon <suunj1331 at gmail.com> wrote:
>
> kvm_sbi_fwft_set() applies the caller's flags to conf->flags before
> invoking the set() callback. If the callback returns an error, the LOCK
> bit persists and the feature becomes permanently locked without its value
> ever being changed.
>
> Move the flags assignment after the callback so LOCK takes effect only
> on success.
>
> Fixes: 6b72fd170592 ("RISC-V: KVM: add support for FWFT SBI extension")
> Signed-off-by: SeungJu Cheon <suunj1331 at gmail.com>

LGTM.

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

Queued this patch as a fix for Linux-7.2-rcX

Thanks,
Anup


> ---
>  arch/riscv/kvm/vcpu_sbi_fwft.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kvm/vcpu_sbi_fwft.c b/arch/riscv/kvm/vcpu_sbi_fwft.c
> index ab39ac464ffd..1342adb3180c 100644
> --- a/arch/riscv/kvm/vcpu_sbi_fwft.c
> +++ b/arch/riscv/kvm/vcpu_sbi_fwft.c
> @@ -327,9 +327,11 @@ static int kvm_sbi_fwft_set(struct kvm_vcpu *vcpu, u32 feature,
>         if (conf->flags & SBI_FWFT_SET_FLAG_LOCK)
>                 return SBI_ERR_DENIED_LOCKED;
>
> -       conf->flags = flags;
> +       ret = conf->feature->set(vcpu, conf, false, value);
> +       if (ret == SBI_SUCCESS)
> +               conf->flags = flags;
>
> -       return conf->feature->set(vcpu, conf, false, value);
> +       return ret;
>  }
>
>  static int kvm_sbi_fwft_get(struct kvm_vcpu *vcpu, unsigned long feature,
> --
> 2.52.0
>



More information about the linux-riscv mailing list