android_kernel_google_msm/drivers/iommu
Alex Williamson 5593165455 intel-iommu: fix off-by-one in pagetable freeing
commit 08336fd218 upstream.

dma_pte_free_level() has an off-by-one error when checking whether a pte
is completely covered by a range.  Take for example the case of
attempting to free pfn 0x0 - 0x1ff, ie.  512 entries covering the first
2M superpage.

The level_size() is 0x200 and we test:

  static void dma_pte_free_level(...
	...

	if (!(0 > 0 || 0x1ff < 0 + 0x200)) {
		...
	}

Clearly the 2nd test is true, which means we fail to take the branch to
clear and free the pagetable entry.  As a result, we're leaking
pagetables and failing to install new pages over the range.

This was found with a PCI device assigned to a QEMU guest using vfio-pci
without a VGA device present.  The first 1M of guest address space is
mapped with various combinations of 4K pages, but eventually the range
is entirely freed and replaced with a 2M contiguous mapping.
intel-iommu errors out with something like:

  ERROR: DMA PTE for vPFN 0x0 already set (to 5c2b8003 not 849c00083)

In this case 5c2b8003 is the pointer to the previous leaf page that was
neither freed nor cleared and 849c00083 is the superpage entry that
we're trying to replace it with.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-13 11:51:08 -08:00
..
amd_iommu.c iommu/amd: Only unmap large pages from the first pte 2013-07-28 16:25:47 -07:00
amd_iommu_init.c iommu/amd: Initialize device table after dma_ops 2013-03-04 06:06:37 +08:00
amd_iommu_proto.h
amd_iommu_types.h iommu/amd: Re-enable IOMMU event log interrupt after handling. 2013-06-07 12:49:35 -07:00
amd_iommu_v2.c iommu/amd: Add missing spin_lock initialization 2012-08-09 08:31:31 -07:00
dmar.c iommu: Fix off by one in dmar_get_fault_reason() 2012-06-01 15:18:27 +08:00
intel-iommu.c intel-iommu: fix off-by-one in pagetable freeing 2014-02-13 11:51:08 -08:00
intr_remapping.c irq_remap: disable IRQ remapping if any IOAPIC lacks an IOMMU 2012-10-02 10:30:38 -07:00
intr_remapping.h
iommu.c Merge branches 'iommu/page-sizes' and 'iommu/group-id' into next 2012-01-09 13:06:28 +01:00
iova.c
Kconfig ARM: IOMMU: Tegra30: Add iommu_ops for SMMU driver 2012-01-26 13:59:02 +01:00
Makefile ARM: IOMMU: Tegra30: Add iommu_ops for SMMU driver 2012-01-26 13:59:02 +01:00
msm_iommu.c iommu/msm: Fix error handling in msm_iommu_unmap() 2012-01-30 12:53:14 +01:00
msm_iommu_dev.c
omap-iommu-debug.c simple_open: automatically convert to simple_open() 2012-04-05 15:25:50 -07:00
omap-iommu.c ARM: OMAP: make iommu subsys_initcall to fix builtin omap3isp 2012-02-27 14:18:42 +01:00
omap-iovmm.c Merge branches 'iommu/fixes', 'arm/omap' and 'x86/amd' into next 2012-01-09 13:04:05 +01:00
tegra-gart.c iommu/tegra-gart: fix spin_unlock in map failure path 2012-03-13 11:17:42 +01:00
tegra-smmu.c iommu/tegra: smmu: Fix deadly typo 2012-10-28 10:14:15 -07:00