From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [patch 04/10] KVM: MMU: mode specific sync_page Date: Fri, 19 Sep 2008 17:44:53 -0700 Message-ID: <48D44785.1060208@redhat.com> References: <20080918212749.800177179@localhost.localdomain> <20080918213336.719431509@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Avi Kivity , kvm@vger.kernel.org, "David S. Ahern" To: Marcelo Tosatti Return-path: Received: from mx2.redhat.com ([66.187.237.31]:44537 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752800AbYITApQ (ORCPT ); Fri, 19 Sep 2008 20:45:16 -0400 In-Reply-To: <20080918213336.719431509@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: Marcelo Tosatti wrote: > Examine guest pagetable and bring the shadow back in sync. Caller is responsible > for local TLB flush before re-entering guest mode. > > Neat! We had a gpte snapshot, and I forgot all about it. > + for (i = 0; i < PT64_ENT_PER_PAGE; i++) { > + if (is_shadow_present_pte(sp->spt[i])) { > if (!is_..()) continue; to reduce indentation. > + pte_gpa += (i+offset) * sizeof(pt_element_t); > + > + if (kvm_read_guest_atomic(vcpu->kvm, pte_gpa, &gpte, > + sizeof(pt_element_t))) > + return -EINVAL; > I guess we want a kvm_map_guest_page_atomic() to speed this up. Can be done later as an optimization, of course. > + > + if (gpte_to_gfn(gpte) != gfn || !(gpte & PT_ACCESSED_MASK)) { > + rmap_remove(vcpu->kvm, &sp->spt[i]); > + if (is_present_pte(gpte)) > + sp->spt[i] = shadow_trap_nonpresent_pte; > + else > + sp->spt[i] = shadow_notrap_nonpresent_pte; > set_shadow_pte() > + continue; > + } > + > + if (!is_present_pte(gpte)) { > + rmap_remove(vcpu->kvm, &sp->spt[i]); > + sp->spt[i] = shadow_notrap_nonpresent_pte; > + continue; > + } > Merge with previous block? -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.