From: Avi Kivity Subject: [PATCH 3/7] KVM: MMU: Add drop_spte_if_large() helper Date: Sun, 11 Jul 2010 18:42:31 +0300 Message-ID: <1278862955-6890-4-git-send-email-avi@redhat.com> References: <1278862955-6890-1-git-send-email-avi@redhat.com> To: Xiao Guangrong , Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:5514 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751520Ab0GKPmi (ORCPT ); Sun, 11 Jul 2010 11:42:38 -0400 In-Reply-To: <1278862955-6890-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: To clarify spte fetching code, move large spte handling into a helper. Signed-off-by: Avi Kivity --- arch/x86/kvm/mmu.c | 8 ++++++++ arch/x86/kvm/paging_tmpl.h | 5 +---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 75cfb79..c02cbe1 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1492,6 +1492,14 @@ static void link_shadow_page(u64 *sptep, struct kvm_mmu_page *sp) __set_spte(sptep, spte); } +static void drop_spte_if_large(struct kvm_vcpu *vcpu, u64 *sptep) +{ + if (is_large_pte(*sptep)) { + drop_spte(vcpu->kvm, sptep, shadow_trap_nonpresent_pte); + kvm_flush_remote_tlbs(vcpu->kvm); + } +} + static void kvm_mmu_page_unlink_children(struct kvm *kvm, struct kvm_mmu_page *sp) { diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 4606c88..2befea7 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -360,10 +360,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, kvm_flush_remote_tlbs(vcpu->kvm); } - if (is_large_pte(*sptep)) { - drop_spte(vcpu->kvm, sptep, shadow_trap_nonpresent_pte); - kvm_flush_remote_tlbs(vcpu->kvm); - } + drop_spte_if_large(vcpu, sptep); if (level <= gw->level) { direct = 1; -- 1.7.1