Skip to content

Commit 6ebbdec

Browse files
committed
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: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent 52ec4b6 commit 6ebbdec

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

arch/riscv/include/uapi/asm/kvm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ struct kvm_sregs {
4949
struct kvm_riscv_config {
5050
unsigned long isa;
5151
unsigned long zicbom_block_size;
52+
unsigned long mvendorid;
53+
unsigned long marchid;
54+
unsigned long mimpid;
5255
};
5356

5457
/* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */

arch/riscv/kvm/vcpu.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ static int kvm_riscv_vcpu_get_reg_config(struct kvm_vcpu *vcpu,
276276
return -EINVAL;
277277
reg_val = riscv_cbom_block_size;
278278
break;
279+
case KVM_REG_RISCV_CONFIG_REG(mvendorid):
280+
reg_val = vcpu->arch.mvendorid;
281+
break;
282+
case KVM_REG_RISCV_CONFIG_REG(marchid):
283+
reg_val = vcpu->arch.marchid;
284+
break;
285+
case KVM_REG_RISCV_CONFIG_REG(mimpid):
286+
reg_val = vcpu->arch.mimpid;
287+
break;
279288
default:
280289
return -EINVAL;
281290
}
@@ -338,6 +347,24 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu,
338347
break;
339348
case KVM_REG_RISCV_CONFIG_REG(zicbom_block_size):
340349
return -EOPNOTSUPP;
350+
case KVM_REG_RISCV_CONFIG_REG(mvendorid):
351+
if (!vcpu->arch.ran_atleast_once)
352+
vcpu->arch.mvendorid = reg_val;
353+
else
354+
return -EBUSY;
355+
break;
356+
case KVM_REG_RISCV_CONFIG_REG(marchid):
357+
if (!vcpu->arch.ran_atleast_once)
358+
vcpu->arch.marchid = reg_val;
359+
else
360+
return -EBUSY;
361+
break;
362+
case KVM_REG_RISCV_CONFIG_REG(mimpid):
363+
if (!vcpu->arch.ran_atleast_once)
364+
vcpu->arch.mimpid = reg_val;
365+
else
366+
return -EBUSY;
367+
break;
341368
default:
342369
return -EINVAL;
343370
}

0 commit comments

Comments
 (0)