Commit 63bd6606 authored by Daniel Henrique Barboza's avatar Daniel Henrique Barboza Committed by Anup Patel

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: default avatarDaniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
parent bea8d237
...@@ -235,18 +235,24 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu, ...@@ -235,18 +235,24 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu,
return -EINVAL; return -EINVAL;
break; break;
case KVM_REG_RISCV_CONFIG_REG(mvendorid): case KVM_REG_RISCV_CONFIG_REG(mvendorid):
if (reg_val == vcpu->arch.mvendorid)
break;
if (!vcpu->arch.ran_atleast_once) if (!vcpu->arch.ran_atleast_once)
vcpu->arch.mvendorid = reg_val; vcpu->arch.mvendorid = reg_val;
else else
return -EBUSY; return -EBUSY;
break; break;
case KVM_REG_RISCV_CONFIG_REG(marchid): case KVM_REG_RISCV_CONFIG_REG(marchid):
if (reg_val == vcpu->arch.marchid)
break;
if (!vcpu->arch.ran_atleast_once) if (!vcpu->arch.ran_atleast_once)
vcpu->arch.marchid = reg_val; vcpu->arch.marchid = reg_val;
else else
return -EBUSY; return -EBUSY;
break; break;
case KVM_REG_RISCV_CONFIG_REG(mimpid): case KVM_REG_RISCV_CONFIG_REG(mimpid):
if (reg_val == vcpu->arch.mimpid)
break;
if (!vcpu->arch.ran_atleast_once) if (!vcpu->arch.ran_atleast_once)
vcpu->arch.mimpid = reg_val; vcpu->arch.mimpid = reg_val;
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment