From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 6/7] KVM: MMU: Simplify spte fetch() function Date: Sun, 11 Jul 2010 19:08:21 +0300 Message-ID: <4C39EC75.9030502@redhat.com> References: <1278862955-6890-1-git-send-email-avi@redhat.com> <1278862955-6890-7-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit To: Xiao Guangrong , Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:44894 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751346Ab0GKQIY (ORCPT ); Sun, 11 Jul 2010 12:08:24 -0400 In-Reply-To: <1278862955-6890-7-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 07/11/2010 06:42 PM, Avi Kivity wrote: > Paritition the function into three sections: > > - fetching indirect shadow pages (host_level> guest_level) > - fetching direct shadow pages (page_level< host_level<= guest_level) > - the final spte (page_level == host_level) > > Instead of the current spaghetti. > > + > + for (; > + shadow_walk_okay(&iterator)&& iterator.level> hlevel; > + shadow_walk_next(&iterator)) { > + gfn_t direct_gfn; > + > + level = iterator.level; > + sptep = iterator.sptep; > > drop_spte_if_large(vcpu, sptep); > > if (is_shadow_present_pte(*sptep)) > continue; > > - if (level<= gw->level) { > - direct = 1; > - access = direct_access; > - > - /* > - * It is a large guest pages backed by small host pages, > - * So we set @direct(@sp->role.direct)=1, and set > - * @table_gfn(@sp->gfn)=the base page frame for linear > - * translations. > - */ > - table_gfn = gw->gfn& ~(KVM_PAGES_PER_HPAGE(level) - 1); > - } else { > - direct = 0; > - table_gfn = gw->table_gfn[level - 2]; > - } > - sp = kvm_mmu_get_page(vcpu, table_gfn, addr, level-1, > - direct, access, sptep); > - if (!direct) > - if (!FNAME(validate_indirect_spte)(vcpu, sptep, sp, > - gw, level)) { > - kvm_release_pfn_clean(pfn); > - sptep = NULL; > - break; > - } > + validate_direct_spte(vcpu, sptep, direct_access); > + > + direct_gfn = gw->gfn& ~(KVM_PAGES_PER_HPAGE(level) - 1); > > + sp = kvm_mmu_get_page(vcpu, direct_gfn, addr, level-1, > + true, direct_access, sptep); > link_shadow_page(sptep, sp); > } > > validate_direct_spte() should be before the 'continue' above, probably. -- error compiling committee.c: too many arguments to function