From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH v2 04/22] KVM: x86: introduce vcpu_gva_to_gpa to cleanup the code Date: Wed, 29 Jun 2011 14:09:52 +0300 Message-ID: <4E0B0800.6030609@redhat.com> References: <4E01FBC9.3020009@cn.fujitsu.com> <4E01FC5B.9040809@cn.fujitsu.com> <4E0AE129.1070200@redhat.com> <4E0B04F1.1010807@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , LKML , KVM To: Xiao Guangrong Return-path: In-Reply-To: <4E0B04F1.1010807@cn.fujitsu.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 06/29/2011 01:56 PM, Xiao Guangrong wrote: > On 06/29/2011 04:24 PM, Avi Kivity wrote: > > >> +static int vcpu_gva_to_gpa(struct kvm_vcpu *vcpu, unsigned long gva, > >> + gpa_t *gpa, struct x86_exception *exception, > >> + bool write) > >> +{ > >> + u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; > >> + > >> + if (write) > >> + access |= PFERR_WRITE_MASK; > > > > Needs fetch as well so NX/SMEP can work. > > > > This function is only used by read/write emulator, execute permission is > not needed for read/write, no? It's not good to have a function which only implements the functionality partially. It can later be misused. You can pass the page-fault-error-code instead of the write parameter, I think it will be simpler. -- error compiling committee.c: too many arguments to function