Signed-off-by: Avi Kivity <a...@redhat.com>
---
 virt/kvm/kvm_main.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 643ce01..9e2db44 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -302,11 +302,11 @@ static void kvm_mmu_notifier_invalidate_page(struct 
mmu_notifier *mn,
        kvm->mmu_notifier_seq++;
        if (kvm_unmap_hva(kvm, address))
                kvm_mark_tlb_dirty(kvm);
-       /* we've to flush the tlb before the pages can be freed */
-       kvm_cond_flush_remote_tlbs(kvm);
-
        spin_unlock(&kvm->mmu_lock);
        srcu_read_unlock(&kvm->srcu, idx);
+
+       /* we've to flush the tlb before the pages can be freed */
+       kvm_cond_flush_remote_tlbs(kvm);
 }
 
 static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn,
@@ -347,11 +347,11 @@ static void 
kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,
        if (need_tlb_flush)
                kvm_mark_tlb_dirty(kvm);
 
-       /* we've to flush the tlb before the pages can be freed */
-       kvm_cond_flush_remote_tlbs(kvm);
-
        spin_unlock(&kvm->mmu_lock);
        srcu_read_unlock(&kvm->srcu, idx);
+
+       /* we've to flush the tlb before the pages can be freed */
+       kvm_cond_flush_remote_tlbs(kvm);
 }
 
 static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn,
@@ -392,11 +392,13 @@ static int kvm_mmu_notifier_clear_flush_young(struct 
mmu_notifier *mn,
 
        young = kvm_age_hva(kvm, address);
        if (young)
-               kvm_flush_remote_tlbs(kvm);
+               kvm_mark_tlb_dirty(kvm);
 
        spin_unlock(&kvm->mmu_lock);
        srcu_read_unlock(&kvm->srcu, idx);
 
+       kvm_cond_flush_remote_tlbs(kvm);
+
        return young;
 }
 
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to