[patch 3/3] KVM: move postcommit flush to x86, as mmio sptes are x86 specific

Marcelo Tosatti
2012-08-24T18:58:12Z

[-- Attachment #1: 03-move-postcommit-flush-to-x86 --]
[-- Type: text/plain, Size: 1221 bytes --]

Other arches do not need this.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: kvm/arch/x86/kvm/x86.c
===================================================================
--- kvm.orig/arch/x86/kvm/x86.c
+++ kvm/arch/x86/kvm/x86.c
@@ -6455,6 +6455,14 @@ void kvm_arch_commit_memory_region(struc
kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages);
kvm_mmu_slot_remove_write_access(kvm, mem->slot);
spin_unlock(&kvm->mmu_lock);
+ /*
+ * If the new memory slot is created, we need to clear all
+ * mmio sptes.
+ */
+ if (old.npages == 0 && npages) {
+ kvm_mmu_zap_all(kvm);
+ kvm_reload_remote_mmus(kvm);
+ }
}

void kvm_arch_flush_shadow_all(struct kvm *kvm)
Index: kvm/virt/kvm/kvm_main.c
===================================================================
--- kvm.orig/virt/kvm/kvm_main.c
+++ kvm/virt/kvm/kvm_main.c
@@ -849,13 +849,6 @@ int __kvm_set_memory_region(struct kvm *

kvm_arch_commit_memory_region(kvm, mem, old, user_alloc);

- /*
- * If the new memory slot is created, we need to clear all
- * mmio sptes.
- */
- if (npages && old.base_gfn != mem->guest_phys_addr >> PAGE_SHIFT)
- kvm_arch_flush_shadow_all(kvm);
-
kvm_free_physmem_slot(&old, &new);
kfree(old_memslots);