From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 3/3] KVM: Add KVM_VCPU_GET_REG_LIST/KVM_CAP_REG_LIST. Date: Wed, 10 Oct 2012 15:12:39 -0300 Message-ID: <20121010181239.GA10649@amt.cnet> References: <1346831926-31820-1-git-send-email-rusty.russell@linaro.org> <1346831926-31820-4-git-send-email-rusty.russell@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org, Avi Kivity , Christoffer Dall , Alexander Graf , Peter Maydell To: Rusty Russell Return-path: Received: from mx1.redhat.com ([209.132.183.28]:17201 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756924Ab2JJSM4 (ORCPT ); Wed, 10 Oct 2012 14:12:56 -0400 Content-Disposition: inline In-Reply-To: <1346831926-31820-4-git-send-email-rusty.russell@linaro.org> Sender: kvm-owner@vger.kernel.org List-ID: 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. >=20 > It's inspired by KVM_GET_MSR_INDEX_LIST, except it's a per-vcpu ioctl= , > and uses 64-bit indices. >=20 > Signed-off-by: Rusty Russell > --- > 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(-) >=20 > diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtua= l/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.) > =20 > =20 > +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: > + =A0E2BIG: =A0=A0=A0=A0the reg index list is too big to fit in the a= rray specified by > + =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0the user (the number required w= ill 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 =3D argp; > + struct kvm_reg_list reg_list; > + unsigned n; > + > + if (copy_from_user(®_list, user_list, sizeof reg_list)) > + return -EFAULT; > + n =3D reg_list.n; > + reg_list.n =3D kvm_arch_num_regs(vcpu); The code does not actually support more than 2^32 registers, does it? Why "__u64 n" ?