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: Mon, 12 Jul 2010 11:53:17 +0300 Message-ID: <4C3AD7FD.20103@redhat.com> References: <1278862955-6890-1-git-send-email-avi@redhat.com> <1278862955-6890-7-git-send-email-avi@redhat.com> <4C3AA359.6020305@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Xiao Guangrong Return-path: Received: from mx1.redhat.com ([209.132.183.28]:23939 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754427Ab0GLIxU (ORCPT ); Mon, 12 Jul 2010 04:53:20 -0400 In-Reply-To: <4C3AA359.6020305@cn.fujitsu.com> Sender: kvm-owner@vger.kernel.org List-ID: On 07/12/2010 08:08 AM, Xiao Guangrong wrote: > > Avi Kivity wrote: > > >> - if (is_shadow_present_pte(*sptep)&& !is_large_pte(*sptep) >> - && level == gw->level) >> - validate_direct_spte(vcpu, sptep, direct_access); >> > ...... > > >> + link_shadow_page(sptep, sp); >> + } >> + >> + 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); >> > Need validate_direct_spte() only when 'level == gw->level' > > That is true (and this is a change from the current code), but level < gw->level will be very rare (1G pages backed by 4k pages) so I don't mind the extra check. -- error compiling committee.c: too many arguments to function