Re: [PATCH] KVM: riscv: SBI FWFT: Apply LOCK flag only on successful set
Anup Patel <[email protected]> Mon, 13 Jul 2026 14:03:10 +0530
| Newsgroups | dev.linux.lists.linux-kernel-mentees,org.infradead.lists.kvm-riscv,org.infradead.lists.linux-riscv,org.kernel.vger.kvm |
|---|---|
| Message-ID | <CAAhSdy2YUuC8BLVDp53VWGnUYLShGkuWeHr87mpe5RnZx3PLSQ@mail.gmail.com> |
On Wed, Jun 24, 2026 at 6:33=E2=80=AFPM SeungJu Cheon <[email protected]>= 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 <[email protected]> LGTM. Reviewed-by: Anup Patel <[email protected]> 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_fwf= t.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, u= 32 feature, > if (conf->flags & SBI_FWFT_SET_FLAG_LOCK) > return SBI_ERR_DENIED_LOCKED; > > - conf->flags =3D flags; > + ret =3D conf->feature->set(vcpu, conf, false, value); > + if (ret =3D=3D SBI_SUCCESS) > + conf->flags =3D 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 >