From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Roedel Subject: Re: [PATCH 3/8] kvm/mmu: rename is_largepage_backed to mapping_level Date: Tue, 23 Jun 2009 19:00:12 +0200 Message-ID: <20090623170012.GH5139@amd.com> References: <1245417389-5527-1-git-send-email-joerg.roedel@amd.com> <1245417389-5527-4-git-send-email-joerg.roedel@amd.com> <20090623155933.GA3651@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Avi Kivity , kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from outbound-dub.frontbridge.com ([213.199.154.16]:19330 "EHLO IE1EHSOBE005.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759296AbZFWRAd convert rfc822-to-8bit (ORCPT ); Tue, 23 Jun 2009 13:00:33 -0400 Content-Disposition: inline In-Reply-To: <20090623155933.GA3651@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Jun 23, 2009 at 12:59:33PM -0300, Marcelo Tosatti wrote: > Hi Joerg, >=20 > On Fri, Jun 19, 2009 at 03:16:24PM +0200, Joerg Roedel wrote: > > gfn =3D unalias_gfn(kvm, gfn); > > - write_count =3D slot_largepage_idx(gfn, > > - gfn_to_memslot_unaliased(kvm, gfn)); > > - *write_count +=3D 1; > > + > > + for (i =3D PT_DIRECTORY_LEVEL; > > + i < PT_PAGE_TABLE_LEVEL + KVM_NR_PAGE_SIZES; ++i) { > > + slot =3D gfn_to_memslot_unaliased(kvm, gfn); >=20 > Can't you move this call out of the loop? True. Will do this. > > @@ -1704,7 +1739,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u6= 4 *sptep, > > if ((pte_access & ACC_WRITE_MASK) > > || (write_fault && !is_write_protection(vcpu) && !user_fault)= ) { > > =20 > > - if (largepage && has_wrprotected_page(vcpu->kvm, gfn)) { > > + if (largepage && has_wrprotected_page(vcpu->kvm, gfn, 1)) { >=20 > It seems direct_map is missing the large pte overwrite check that > fetch() contains: >=20 > if (is_large_pte(*sptep)) { > rmap_remove(vcpu->kvm, sptep); > __set_spte(sptep, shadow_trap_nonpresent_pte)= ; > kvm_flush_remote_tlbs(vcpu->kvm); > } >=20 > (perhaps its not a possible scenario at the moment, but...). This function is only called from mmu_set_spte which takes care of this= =2E Thanks, Joerg --=20 | Advanced Micro Devices GmbH Operating | Karl-Hammerschmidt-Str. 34, 85609 Dornach bei M=FCnchen System |=20 Research | Gesch=E4ftsf=FChrer: Thomas M. McCoy, Giuliano Meroni Center | Sitz: Dornach, Gemeinde Aschheim, Landkreis M=FCnchen | Registergericht M=FCnchen, HRB Nr. 43632