Commit 6ebbdecf authored by Anup Patel's avatar Anup Patel Committed by Anup Patel

RISC-V: KVM: Add ONE_REG interface for mvendorid, marchid, and mimpid

We add ONE_REG interface for VCPU mvendorid, marchid, and mimpid
so that KVM user-space can change this details to support migration
across heterogeneous hosts.
Signed-off-by: default avatarAnup Patel <apatel@ventanamicro.com>
Reviewed-by: default avatarAtish Patra <atishp@rivosinc.com>
Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
parent 52ec4b69
...@@ -49,6 +49,9 @@ struct kvm_sregs { ...@@ -49,6 +49,9 @@ struct kvm_sregs {
struct kvm_riscv_config { struct kvm_riscv_config {
unsigned long isa; unsigned long isa;
unsigned long zicbom_block_size; unsigned long zicbom_block_size;
unsigned long mvendorid;
unsigned long marchid;
unsigned long mimpid;
}; };
/* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
......
...@@ -276,6 +276,15 @@ static int kvm_riscv_vcpu_get_reg_config(struct kvm_vcpu *vcpu, ...@@ -276,6 +276,15 @@ static int kvm_riscv_vcpu_get_reg_config(struct kvm_vcpu *vcpu,
return -EINVAL; return -EINVAL;
reg_val = riscv_cbom_block_size; reg_val = riscv_cbom_block_size;
break; break;
case KVM_REG_RISCV_CONFIG_REG(mvendorid):
reg_val = vcpu->arch.mvendorid;
break;
case KVM_REG_RISCV_CONFIG_REG(marchid):
reg_val = vcpu->arch.marchid;
break;
case KVM_REG_RISCV_CONFIG_REG(mimpid):
reg_val = vcpu->arch.mimpid;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -338,6 +347,24 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu, ...@@ -338,6 +347,24 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu,
break; break;
case KVM_REG_RISCV_CONFIG_REG(zicbom_block_size): case KVM_REG_RISCV_CONFIG_REG(zicbom_block_size):
return -EOPNOTSUPP; return -EOPNOTSUPP;
case KVM_REG_RISCV_CONFIG_REG(mvendorid):
if (!vcpu->arch.ran_atleast_once)
vcpu->arch.mvendorid = reg_val;
else
return -EBUSY;
break;
case KVM_REG_RISCV_CONFIG_REG(marchid):
if (!vcpu->arch.ran_atleast_once)
vcpu->arch.marchid = reg_val;
else
return -EBUSY;
break;
case KVM_REG_RISCV_CONFIG_REG(mimpid):
if (!vcpu->arch.ran_atleast_once)
vcpu->arch.mimpid = reg_val;
else
return -EBUSY;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
......
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