Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755270Ab1F2LYO (ORCPT ); Wed, 29 Jun 2011 07:24:14 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:61207 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755052Ab1F2LYM (ORCPT ); Wed, 29 Jun 2011 07:24:12 -0400 Message-ID: <4E0B0BCA.5050103@cn.fujitsu.com> Date: Wed, 29 Jun 2011 19:26:02 +0800 From: Xiao Guangrong User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc15 Thunderbird/3.1.10 MIME-Version: 1.0 To: Avi Kivity CC: Marcelo Tosatti , LKML , KVM Subject: Re: [PATCH v2 04/22] KVM: x86: introduce vcpu_gva_to_gpa to cleanup the code References: <4E01FBC9.3020009@cn.fujitsu.com> <4E01FC5B.9040809@cn.fujitsu.com> <4E0AE129.1070200@redhat.com> <4E0B04F1.1010807@cn.fujitsu.com> <4E0B0800.6030609@redhat.com> In-Reply-To: <4E0B0800.6030609@redhat.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-06-29 19:23:32, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-06-29 19:23:32, Serialize complete at 2011-06-29 19:23:32 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1300 Lines: 31 On 06/29/2011 07:09 PM, Avi Kivity wrote: > 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. > Actually, we will get the cache mmio info in this function, i think it is pure waste for other access execpt mmio, what about change the function name to vcpu_gva_to_gpa_mmio? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/