KVM: IOMMU: hva align mapping page size
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / virt / kvm / iommu.c
index 72a130bc448aa97adb1ca35a2dfff09a102b717d..c329c8fc57f45807ad16729c97d5fa21d0fc81e8 100644 (file)
@@ -103,6 +103,10 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
                while ((gfn << PAGE_SHIFT) & (page_size - 1))
                        page_size >>= 1;
 
+               /* Make sure hva is aligned to the page size we want to map */
+               while (__gfn_to_hva_memslot(slot, gfn) & (page_size - 1))
+                       page_size >>= 1;
+
                /*
                 * Pin all pages we are about to map in memory. This is
                 * important because we unmap and unpin in 4kb steps later.