Skip to content

Commit 63bd660

Browse files
danielhbavpatel
authored andcommitted
RISC-V: KVM: avoid EBUSY when writing the same machine ID val
Right now we do not allow any write in mvendorid/marchid/mimpid if the vcpu already started, preventing these regs to be changed. However, if userspace doesn't change them, an alternative is to consider the reg write a no-op and avoid erroring out altogether. Userpace can then be oblivious about KVM internals if no changes were intended in the first place. Allow the same form of 'lazy writing' that registers such as zicbom/zicboz_block_size supports: avoid erroring out if userspace makes no changes in mvendorid/marchid/mimpid during reg write. Signed-off-by: Daniel Henrique Barboza <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent bea8d23 commit 63bd660

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/riscv/kvm/vcpu_onereg.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,24 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu,
235235
return -EINVAL;
236236
break;
237237
case KVM_REG_RISCV_CONFIG_REG(mvendorid):
238+
if (reg_val == vcpu->arch.mvendorid)
239+
break;
238240
if (!vcpu->arch.ran_atleast_once)
239241
vcpu->arch.mvendorid = reg_val;
240242
else
241243
return -EBUSY;
242244
break;
243245
case KVM_REG_RISCV_CONFIG_REG(marchid):
246+
if (reg_val == vcpu->arch.marchid)
247+
break;
244248
if (!vcpu->arch.ran_atleast_once)
245249
vcpu->arch.marchid = reg_val;
246250
else
247251
return -EBUSY;
248252
break;
249253
case KVM_REG_RISCV_CONFIG_REG(mimpid):
254+
if (reg_val == vcpu->arch.mimpid)
255+
break;
250256
if (!vcpu->arch.ran_atleast_once)
251257
vcpu->arch.mimpid = reg_val;
252258
else

0 commit comments

Comments
 (0)