From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [patch 3/3] KVM: MMU: prepopulate the shadow on invlpg Date: Fri, 31 Oct 2008 17:47:27 -0200 Message-ID: <20081031194727.GD21772@dmt.cnet> References: <20081025223111.498934405@localhost.localdomain> <20081025223243.946600413@localhost.localdomain> <49045906.7070305@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx2.redhat.com ([66.187.237.31]:58615 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752287AbYJaTsj (ORCPT ); Fri, 31 Oct 2008 15:48:39 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id m9VJmdY0027702 for ; Fri, 31 Oct 2008 15:48:39 -0400 Content-Disposition: inline In-Reply-To: <49045906.7070305@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, Oct 26, 2008 at 01:48:22PM +0200, Avi Kivity wrote: >> Index: kvm/arch/x86/kvm/mmu.c >> =================================================================== >> --- kvm.orig/arch/x86/kvm/mmu.c >> +++ kvm/arch/x86/kvm/mmu.c >> @@ -2365,7 +2365,8 @@ static void kvm_mmu_access_page(struct k >> } >> void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, >> - const u8 *new, int bytes) >> + const u8 *new, int bytes, >> + bool speculative) >> > > kvm_mmu_pte_write()s are always speculative. Maybe this is misnamed? Yep. >> + sw->pte_gpa = (sp->gfn << PAGE_SHIFT); >> + sw->pte_gpa += (sptep - sp->spt) * sizeof(pt_element_t); >> + >> + if (is_shadow_present_pte(*sptep)) { >> rmap_remove(vcpu->kvm, sptep); >> + sw->pte_gpa = -1; >> > > Why? The pte could have heen replaced (for example, a write access to a > cow page). Well look-aheads on address space teardown will be useless. OTOH the guest pte read cost is minimal compared to an exit. Whatever you prefer. Learning guest behaviour as suggested earlier would be optimal, but simple is good.