On Wed, Sep 05, 2012 at 05:28:46PM +0930, Rusty Russell wrote: > This is a generic interface to find out what you can use > KVM_GET_ONE_REG/KVM_SET_ONE_REG on. Archs need to define > KVM_HAVE_REG_LIST and then kvm_arch_num_regs() and > kvm_arch_copy_reg_indices() functions. > > It's inspired by KVM_GET_MSR_INDEX_LIST, except it's a per-vcpu ioctl, > and uses 64-bit indices. > > Signed-off-by: Rusty Russell <rusty.russell@xxxxxxxxxx> > --- > Documentation/virtual/kvm/api.txt | 20 ++++++++++++++++++++ > include/linux/kvm.h | 12 ++++++++++++ > include/linux/kvm_host.h | 5 ++++- > virt/kvm/kvm_main.c | 20 ++++++++++++++++++++ > 4 files changed, 56 insertions(+), 1 deletion(-) > > diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt > index b91bfd4..f30c3d0 100644 > --- a/Documentation/virtual/kvm/api.txt > +++ b/Documentation/virtual/kvm/api.txt > @@ -1985,6 +1985,26 @@ the virtualized real-mode area (VRMA) facility, the kernel will > re-create the VMRA HPTEs on the next KVM_RUN of any vcpu.) > > > +4.76 KVM_VCPU_GET_REG_LIST > + > +Capability: KVM_CAP_REG_LIST > +Architectures: all > +Type: vcpu ioctl > +Parameters: struct kvm_reg_list (in/out) > +Returns: 0 on success; -1 on error > +Errors: > + E2BIG: the reg index list is too big to fit in the array specified by > + the user (the number required will be written into n). > + > +struct kvm_reg_list { > + __u64 n; /* number of registers in reg[] */ > + __u64 reg[0]; > +}; > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 169a001..453fe93 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -2082,6 +2082,23 @@ out_free2: > break; > } > #endif > +#ifdef KVM_HAVE_REG_LIST > + case KVM_VCPU_GET_REG_LIST: { > + struct kvm_reg_list __user *user_list = argp; > + struct kvm_reg_list reg_list; > + unsigned n; > + > + if (copy_from_user(®_list, user_list, sizeof reg_list)) > + return -EFAULT; > + n = reg_list.n; > + reg_list.n = kvm_arch_num_regs(vcpu); The code does not actually support more than 2^32 registers, does it? Why "__u64 n" ? -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html