From: Marcelo Tosatti Subject: [patch 02/10] KVM: MMU: move local TLB flush to mmu_set_spte Date: Thu, 18 Sep 2008 18:27:51 -0300 Message-ID: <20080918213336.548424061@localhost.localdomain> References: <20080918212749.800177179@localhost.localdomain> Cc: kvm@vger.kernel.org, "David S. Ahern" , Marcelo Tosatti To: Avi Kivity Return-path: Received: from mx1.redhat.com ([66.187.233.31]:59379 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756648AbYIRVuA (ORCPT ); Thu, 18 Sep 2008 17:50:00 -0400 Content-Disposition: inline; filename=mmu-set-spte-tlb-flush Sender: kvm-owner@vger.kernel.org List-ID: Since the sync page path can collapse flushes. Also only flush if the spte was writable before. Signed-off-by: Marcelo Tosatti Index: kvm/arch/x86/kvm/mmu.c =================================================================== --- kvm.orig/arch/x86/kvm/mmu.c +++ kvm/arch/x86/kvm/mmu.c @@ -1189,10 +1189,8 @@ static int set_spte(struct kvm_vcpu *vcp __func__, gfn); ret = 1; pte_access &= ~ACC_WRITE_MASK; - if (is_writeble_pte(spte)) { + if (is_writeble_pte(spte)) spte &= ~PT_WRITABLE_MASK; - kvm_x86_ops->tlb_flush(vcpu); - } } } @@ -1241,9 +1239,12 @@ static void mmu_set_spte(struct kvm_vcpu } } if (set_spte(vcpu, shadow_pte, pte_access, user_fault, write_fault, - dirty, largepage, gfn, pfn, speculative)) + dirty, largepage, gfn, pfn, speculative)) { if (write_fault) *ptwrite = 1; + if (was_writeble) + kvm_x86_ops->tlb_flush(vcpu); + } pgprintk("%s: setting spte %llx\n", __func__, *shadow_pte); pgprintk("instantiating %s PTE (%s) at %ld (%llx) addr %p\n", --