Merge branch 'acpi-misc'
[linux-2.6-microblaze.git] / include / linux / kvm_host.h
index e126ebd..1b65e72 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/signal.h>
 #include <linux/sched.h>
 #include <linux/bug.h>
+#include <linux/minmax.h>
 #include <linux/mm.h>
 #include <linux/mmu_notifier.h>
 #include <linux/preempt.h>
@@ -506,6 +507,8 @@ struct kvm {
        struct mmu_notifier mmu_notifier;
        unsigned long mmu_notifier_seq;
        long mmu_notifier_count;
+       unsigned long mmu_notifier_range_start;
+       unsigned long mmu_notifier_range_end;
 #endif
        long tlbs_dirty;
        struct list_head devices;
@@ -733,7 +736,7 @@ kvm_pfn_t gfn_to_pfn_memslot(struct kvm_memory_slot *slot, gfn_t gfn);
 kvm_pfn_t gfn_to_pfn_memslot_atomic(struct kvm_memory_slot *slot, gfn_t gfn);
 kvm_pfn_t __gfn_to_pfn_memslot(struct kvm_memory_slot *slot, gfn_t gfn,
                               bool atomic, bool *async, bool write_fault,
-                              bool *writable);
+                              bool *writable, hva_t *hva);
 
 void kvm_release_pfn_clean(kvm_pfn_t pfn);
 void kvm_release_pfn_dirty(kvm_pfn_t pfn);
@@ -1207,6 +1210,26 @@ static inline int mmu_notifier_retry(struct kvm *kvm, unsigned long mmu_seq)
                return 1;
        return 0;
 }
+
+static inline int mmu_notifier_retry_hva(struct kvm *kvm,
+                                        unsigned long mmu_seq,
+                                        unsigned long hva)
+{
+       lockdep_assert_held(&kvm->mmu_lock);
+       /*
+        * If mmu_notifier_count is non-zero, then the range maintained by
+        * kvm_mmu_notifier_invalidate_range_start contains all addresses that
+        * might be being invalidated. Note that it may include some false
+        * positives, due to shortcuts when handing concurrent invalidations.
+        */
+       if (unlikely(kvm->mmu_notifier_count) &&
+           hva >= kvm->mmu_notifier_range_start &&
+           hva < kvm->mmu_notifier_range_end)
+               return 1;
+       if (kvm->mmu_notifier_seq != mmu_seq)
+               return 1;
+       return 0;
+}
 #endif
 
 #ifdef CONFIG_HAVE_KVM_IRQ_ROUTING