mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
RISC-V: KVM: Reset the SBI extension when disable it
The SBI extension validation callback can only fix the parameter if the extension is enabled. However, if the extension is disabled after modifty some parameters, the state of the extension is still broken. Reset the extension when the extension is disabled so it can have a clear context. Signed-off-by: Inochi Amaoto <inochiama@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20260729232527.139183-4-inochiama@gmail.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
parent
b88cb6998f
commit
52132eec63
|
|
@ -221,6 +221,7 @@ static int riscv_vcpu_set_sbi_ext_single(struct kvm_vcpu *vcpu,
|
|||
{
|
||||
struct kvm_vcpu_sbi_context *scontext = &vcpu->arch.sbi_context;
|
||||
const struct kvm_riscv_sbi_extension_entry *sext;
|
||||
const struct kvm_vcpu_sbi_extension *ext;
|
||||
|
||||
if (reg_val != 1 && reg_val != 0)
|
||||
return -EINVAL;
|
||||
|
|
@ -229,6 +230,12 @@ static int riscv_vcpu_set_sbi_ext_single(struct kvm_vcpu *vcpu,
|
|||
if (!sext || scontext->ext_status[sext->ext_idx] == KVM_RISCV_SBI_EXT_STATUS_UNAVAILABLE)
|
||||
return -ENOENT;
|
||||
|
||||
ext = sext->ext_ptr;
|
||||
|
||||
if (!reg_val && scontext->ext_status[sext->ext_idx] == KVM_RISCV_SBI_EXT_STATUS_ENABLED &&
|
||||
ext->reset)
|
||||
ext->reset(vcpu);
|
||||
|
||||
scontext->ext_status[sext->ext_idx] = (reg_val) ?
|
||||
KVM_RISCV_SBI_EXT_STATUS_ENABLED :
|
||||
KVM_RISCV_SBI_EXT_STATUS_DISABLED;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user