Skip to content

Commit e482d9e

Browse files
committed
RISC-V: KVM: Fix reg_val check in kvm_riscv_vcpu_set_reg_config()
The reg_val check in kvm_riscv_vcpu_set_reg_config() should only be done for isa config register. Fixes: 9bfd900 ("RISC-V: KVM: Improve ISA extension by using a bitmap") Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Atish Patra <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent 3e2d475 commit e482d9e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

arch/riscv/kvm/vcpu.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,15 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu,
296296
if (copy_from_user(&reg_val, uaddr, KVM_REG_SIZE(reg->id)))
297297
return -EFAULT;
298298

299-
/* This ONE REG interface is only defined for single letter extensions */
300-
if (fls(reg_val) >= RISCV_ISA_EXT_BASE)
301-
return -EINVAL;
302-
303299
switch (reg_num) {
304300
case KVM_REG_RISCV_CONFIG_REG(isa):
301+
/*
302+
* This ONE REG interface is only defined for
303+
* single letter extensions.
304+
*/
305+
if (fls(reg_val) >= RISCV_ISA_EXT_BASE)
306+
return -EINVAL;
307+
305308
if (!vcpu->arch.ran_atleast_once) {
306309
/* Ignore the enable/disable request for certain extensions */
307310
for (i = 0; i < RISCV_ISA_EXT_BASE; i++) {

0 commit comments

Comments
 (0)