From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH v3 5/6] KVM: introduce gfn_to_hva_read/kvm_read_hva/kvm_read_hva_atomic Date: Mon, 18 Jun 2012 13:16:37 +0300 Message-ID: <4FDF0005.3050300@redhat.com> References: <4FD6ADA6.40008@linux.vnet.ibm.com> <4FD6AE1B.7080501@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , LKML , KVM To: Xiao Guangrong Return-path: In-Reply-To: <4FD6AE1B.7080501@linux.vnet.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 06/12/2012 05:48 AM, Xiao Guangrong wrote: > This set of functions is only used to read data from host space, read is > a special case in the later patch > > > +/* > + * The hva returned by this function is only allowed to be read. > + * It should pair with kvm_read_hva() or kvm_read_hva_atomic(). > + */ > +static unsigned long gfn_to_hva_read(struct kvm *kvm, gfn_t gfn) > +{ > + return gfn_to_hva_many(gfn_to_memslot(kvm, gfn), gfn, NULL); > +} > + > +static int kvm_read_hva(void *data, void *hva, int len) > +{ > + return __copy_from_user(data, (void __user *)hva, len); > + > +} > + > +static int kvm_read_hva_atomic(void *data, void *hva, int len) > +{ > + return __copy_from_user_inatomic(data, (void __user *)hva, len); > + > +} Why cast to __user? Make it __user in the first place. Also these are just simple wrappers, why to them at all? -- error compiling committee.c: too many arguments to function