Skip to content

Commit 17f71a2

Browse files
committed
RISC-V: KVM: Fix riscv_vcpu_get_isa_ext_single() for missing extensions
The riscv_vcpu_get_isa_ext_single() should fail with -ENOENT error when corresponding ISA extension is not available on the host. Fixes: e98b108 ("RISC-V: KVM: Factor-out ONE_REG related code to its own source file") Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent ef4d483 commit 17f71a2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/riscv/kvm/vcpu_onereg.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,11 @@ static int riscv_vcpu_get_isa_ext_single(struct kvm_vcpu *vcpu,
460460
reg_num >= ARRAY_SIZE(kvm_isa_ext_arr))
461461
return -ENOENT;
462462

463-
*reg_val = 0;
464463
host_isa_ext = kvm_isa_ext_arr[reg_num];
464+
if (!__riscv_isa_extension_available(NULL, host_isa_ext))
465+
return -ENOENT;
466+
467+
*reg_val = 0;
465468
if (__riscv_isa_extension_available(vcpu->arch.isa, host_isa_ext))
466469
*reg_val = 1; /* Mark the given extension as available */
467470

0 commit comments

Comments
 (0)