Skip to content

Commit bea8d23

Browse files
danielhbavpatel
authored andcommitted
RISC-V: KVM: avoid EBUSY when writing same ISA val
kvm_riscv_vcpu_set_reg_config() will return -EBUSY if the ISA config reg is being written after the VCPU ran at least once. The same restriction isn't placed in kvm_riscv_vcpu_get_reg_config(), so there's a chance that we'll -EBUSY out on an ISA config reg write even if the userspace intended no changes to it. We'll allow the same form of 'lazy writing' that registers such as zicbom/zicboz_block_size supports: avoid erroring out if userspace made no changes to the ISA config reg. Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent d57304b commit bea8d23

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

arch/riscv/kvm/vcpu_onereg.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu,
190190
if (fls(reg_val) >= RISCV_ISA_EXT_BASE)
191191
return -EINVAL;
192192

193+
/*
194+
* Return early (i.e. do nothing) if reg_val is the same
195+
* value retrievable via kvm_riscv_vcpu_get_reg_config().
196+
*/
197+
if (reg_val == (vcpu->arch.isa[0] & KVM_RISCV_BASE_ISA_MASK))
198+
break;
199+
193200
if (!vcpu->arch.ran_atleast_once) {
194201
/* Ignore the enable/disable request for certain extensions */
195202
for (i = 0; i < RISCV_ISA_EXT_BASE; i++) {

0 commit comments

Comments
 (0)