* [PATCH] KVM: riscv: SBI FWFT: Apply LOCK flag only on successful set
@ 2026-06-24 13:02 SeungJu Cheon
2026-07-13 8:33 ` Anup Patel
0 siblings, 1 reply; 2+ messages in thread
From: SeungJu Cheon @ 2026-06-24 13:02 UTC (permalink / raw)
To: anup
Cc: atish.patra, cleger, ajones, skhan, kvm, kvm-riscv, linux-riscv,
linux-kernel-mentees, SeungJu Cheon
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@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: riscv: SBI FWFT: Apply LOCK flag only on successful set
2026-06-24 13:02 [PATCH] KVM: riscv: SBI FWFT: Apply LOCK flag only on successful set SeungJu Cheon
@ 2026-07-13 8:33 ` Anup Patel
0 siblings, 0 replies; 2+ messages in thread
From: Anup Patel @ 2026-07-13 8:33 UTC (permalink / raw)
To: SeungJu Cheon
Cc: atish.patra, cleger, ajones, skhan, kvm, kvm-riscv, linux-riscv,
linux-kernel-mentees
On Wed, Jun 24, 2026 at 6:33 PM SeungJu Cheon <suunj1331@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@gmail.com>
LGTM.
Reviewed-by: Anup Patel <anup@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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-13 8:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24 13:02 [PATCH] KVM: riscv: SBI FWFT: Apply LOCK flag only on successful set SeungJu Cheon
2026-07-13 8:33 ` Anup Patel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox