KVM: Add "exiting guest mode" state
[pandora-kernel.git] / virt / kvm / kvm_main.c
index f29abeb..19209f8 100644 (file)
@@ -171,7 +171,12 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req)
                if (kvm_make_check_request(req, vcpu))
                        continue;
                cpu = vcpu->cpu;
-               if (cpus != NULL && cpu != -1 && cpu != me)
+
+               /* Set ->requests bit before we read ->mode */
+               smp_mb();
+
+               if (cpus != NULL && cpu != -1 && cpu != me &&
+                     kvm_vcpu_exiting_guest_mode(vcpu) != OUTSIDE_GUEST_MODE)
                        cpumask_set_cpu(cpu, cpus);
        }
        if (unlikely(cpus == NULL))
@@ -588,6 +593,7 @@ static int kvm_vm_release(struct inode *inode, struct file *filp)
        return 0;
 }
 
+#ifndef CONFIG_S390
 /*
  * Allocation size is twice as large as the actual dirty bitmap size.
  * This makes it possible to do double buffering: see x86's
@@ -608,6 +614,7 @@ static int kvm_create_dirty_bitmap(struct kvm_memory_slot *memslot)
        memslot->dirty_bitmap_head = memslot->dirty_bitmap;
        return 0;
 }
+#endif /* !CONFIG_S390 */
 
 /*
  * Allocate some memory and give it an address in the guest physical address
@@ -621,7 +628,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
                            struct kvm_userspace_memory_region *mem,
                            int user_alloc)
 {
-       int r, flush_shadow = 0;
+       int r;
        gfn_t base_gfn;
        unsigned long npages;
        unsigned long i;
@@ -741,8 +748,6 @@ skip_lpage:
                if (kvm_create_dirty_bitmap(&new) < 0)
                        goto out_free;
                /* destroy any largepage mappings for dirty tracking */
-               if (old.npages)
-                       flush_shadow = 1;
        }
 #else  /* not defined CONFIG_S390 */
        new.user_alloc = user_alloc;
@@ -813,9 +818,6 @@ skip_lpage:
        kvm_free_physmem_slot(&old, &new);
        kfree(old_memslots);
 
-       if (flush_shadow)
-               kvm_arch_flush_shadow(kvm);
-
        return 0;
 
 out_free: