From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH] do not call gva_to_gpa on physical address Date: Wed, 14 Jul 2010 18:52:52 +0300 Message-ID: <20100714155252.GJ4689@redhat.com> References: <20100714153858.GI4689@redhat.com> <4C3DDB4F.3050208@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: mtosatti@redhat.com, kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:30542 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752039Ab0GNPwx (ORCPT ); Wed, 14 Jul 2010 11:52:53 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6EFqrLt021412 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 14 Jul 2010 11:52:53 -0400 Content-Disposition: inline In-Reply-To: <4C3DDB4F.3050208@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Jul 14, 2010 at 06:44:15PM +0300, Avi Kivity wrote: > On 07/14/2010 06:38 PM, Gleb Natapov wrote: > >When tdp is enabled cr2 passed to emulator is pga not gva, so no need to > >call gva_to_gpa on it. > > > >Signed-off-by: Gleb Natapov > >diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > >index fb08316..721bf0a 100644 > >--- a/arch/x86/kvm/x86.c > >+++ b/arch/x86/kvm/x86.c > >@@ -3944,10 +3944,13 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t gva) > > if (kvm_mmu_unprotect_page_virt(vcpu, gva)) > > return true; > > > >- gpa = kvm_mmu_gva_to_gpa_system(vcpu, gva, NULL); > >+ if (!tdp_enabled) { > >+ gpa = kvm_mmu_gva_to_gpa_system(vcpu, gva, NULL); > > > >- if (gpa == UNMAPPED_GVA) > >- return true; /* let cpu generate fault */ > >+ if (gpa == UNMAPPED_GVA) > >+ return true; /* let cpu generate fault */ > >+ } else > >+ gpa = gva; > > > > if (!kvm_is_error_hva(gfn_to_hva(vcpu->kvm, gpa>> PAGE_SHIFT))) > > return true; > > Why not > > if (tdp_enabled) > return false; > > at the top? Is there any reason ever to reexecute an instruction > with tdp enabled? > Can't think of one now. If in the future we will shadow some other data structures in the guest except page tables (nested vmx/svm?) there may be the reason. -- Gleb.