diff options
| author | Anup Patel <apatel@ventanamicro.com> | 2022-12-07 09:16:51 +0530 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-12-31 13:26:35 +0100 |
| commit | b1b3d18708526b77f97beebc89d3746cfd474e98 (patch) | |
| tree | 75123e04545f6f04351c1a4ece92e01892c52450 /arch | |
| parent | 1c8cf1562450d251198021b0cea5f74e1fd62615 (diff) | |
| download | linux-b1b3d18708526b77f97beebc89d3746cfd474e98.tar.gz linux-b1b3d18708526b77f97beebc89d3746cfd474e98.tar.bz2 linux-b1b3d18708526b77f97beebc89d3746cfd474e98.zip | |
RISC-V: KVM: Fix reg_val check in kvm_riscv_vcpu_set_reg_config()
[ Upstream commit e482d9e33d5b0f222cbef7341dcd52cead6b9edc ]
The reg_val check in kvm_riscv_vcpu_set_reg_config() should only
be done for isa config register.
Fixes: 9bfd900beeec ("RISC-V: KVM: Improve ISA extension by using a bitmap")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Signed-off-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/riscv/kvm/vcpu.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index f692c0716aa7..aa7ae6327044 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -286,12 +286,15 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu, if (copy_from_user(®_val, uaddr, KVM_REG_SIZE(reg->id))) return -EFAULT; - /* This ONE REG interface is only defined for single letter extensions */ - if (fls(reg_val) >= RISCV_ISA_EXT_BASE) - return -EINVAL; - switch (reg_num) { case KVM_REG_RISCV_CONFIG_REG(isa): + /* + * This ONE REG interface is only defined for + * single letter extensions. + */ + if (fls(reg_val) >= RISCV_ISA_EXT_BASE) + return -EINVAL; + if (!vcpu->arch.ran_atleast_once) { /* Ignore the enable/disable request for certain extensions */ for (i = 0; i < RISCV_ISA_EXT_BASE; i++) { |
