Skip to content

Commit 031f9ef

Browse files
xiaobo55xavpatel
authored andcommitted
KVM: riscv: Add KVM_GET_REG_LIST API support
KVM_GET_REG_LIST API will return all registers that are available to KVM_GET/SET_ONE_REG APIs. It's very useful to identify some platform regression issue during VM migration. Since this API was already supported on arm64, it is straightforward to enable it on riscv with similar code structure. Signed-off-by: Haibo Xu <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent cbc0daa commit 031f9ef

File tree

4 files changed

+388
-1
lines changed

4 files changed

+388
-1
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3501,7 +3501,7 @@ VCPU matching underlying host.
35013501
---------------------
35023502

35033503
:Capability: basic
3504-
:Architectures: arm64, mips
3504+
:Architectures: arm64, mips, riscv
35053505
:Type: vcpu ioctl
35063506
:Parameters: struct kvm_reg_list (in/out)
35073507
:Returns: 0 on success; -1 on error

arch/riscv/include/asm/kvm_host.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ int kvm_riscv_vcpu_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
338338
void __kvm_riscv_switch_to(struct kvm_vcpu_arch *vcpu_arch);
339339

340340
void kvm_riscv_vcpu_setup_isa(struct kvm_vcpu *vcpu);
341+
unsigned long kvm_riscv_vcpu_num_regs(struct kvm_vcpu *vcpu);
342+
int kvm_riscv_vcpu_copy_reg_indices(struct kvm_vcpu *vcpu,
343+
u64 __user *uindices);
341344
int kvm_riscv_vcpu_get_reg(struct kvm_vcpu *vcpu,
342345
const struct kvm_one_reg *reg);
343346
int kvm_riscv_vcpu_set_reg(struct kvm_vcpu *vcpu,

arch/riscv/kvm/vcpu.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,24 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
254254
r = kvm_riscv_vcpu_get_reg(vcpu, &reg);
255255
break;
256256
}
257+
case KVM_GET_REG_LIST: {
258+
struct kvm_reg_list __user *user_list = argp;
259+
struct kvm_reg_list reg_list;
260+
unsigned int n;
261+
262+
r = -EFAULT;
263+
if (copy_from_user(&reg_list, user_list, sizeof(reg_list)))
264+
break;
265+
n = reg_list.n;
266+
reg_list.n = kvm_riscv_vcpu_num_regs(vcpu);
267+
if (copy_to_user(user_list, &reg_list, sizeof(reg_list)))
268+
break;
269+
r = -E2BIG;
270+
if (n < reg_list.n)
271+
break;
272+
r = kvm_riscv_vcpu_copy_reg_indices(vcpu, user_list->reg);
273+
break;
274+
}
257275
default:
258276
break;
259277
}

0 commit comments

Comments
 (0)