android_kernel_google_msm/virt/kvm
Greg Edwards f7741e3b3f KVM: IOMMU: hva align mapping page size
commit 27ef63c7e9 upstream.

When determining the page size we could use to map with the IOMMU, the
page size should also be aligned with the hva, not just the gfn.  The
gfn may not reflect the real alignment within the hugetlbfs file.

Most of the time, this works fine.  However, if the hugetlbfs file is
backed by non-contiguous huge pages, a multi-huge page memslot starts at
an unaligned offset within the hugetlbfs file, and the gfn is aligned
with respect to the huge page size, kvm_host_page_size() will return the
huge page size and we will use that to map with the IOMMU.

When we later unpin that same memslot, the IOMMU returns the unmap size
as the huge page size, and we happily unpin that many pfns in
monotonically increasing order, not realizing we are spanning
non-contiguous huge pages and partially unpin the wrong huge page.

Ensure the IOMMU mapping page size is aligned with the hva corresponding
to the gfn, which does reflect the alignment within the hugetlbfs file.

Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Greg Edwards <gedwards@ddn.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
[bwh: Backported to 3.2: s/__gfn_to_hva_memslot/gfn_to_hva_memslot/]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-11 16:10:03 -07:00
..
assigned-dev.c KVM: Convert intx_mask_lock to spin lock 2012-03-20 12:41:24 +02:00
async_pf.c
async_pf.h
coalesced_mmio.c KVM: return an error code in kvm_vm_ioctl_register_coalesced_mmio() 2014-02-22 10:32:46 -08:00
coalesced_mmio.h KVM: Make coalesced mmio use a device per zone 2011-09-25 19:17:57 +03:00
eventfd.c KVM: Intelligent device lookup on I/O bus 2011-09-25 19:17:59 +03:00
ioapic.c KVM: Fix bounds checking in ioapic indirect register reads (CVE-2013-1798) 2013-04-25 21:19:55 -07:00
ioapic.h
iodev.h
iommu.c KVM: IOMMU: hva align mapping page size 2014-03-11 16:10:03 -07:00
irq_comm.c KVM: Fix buffer overflow in kvm_set_irq() 2014-02-20 10:45:33 -08:00
Kconfig
kvm_main.c KVM: Improve create VCPU parameter (CVE-2013-4587) 2013-12-20 07:34:19 -08:00