linux/drivers/iommu
Alex Williamson 08336fd218 intel-iommu: fix off-by-one in pagetable freeing
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>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-01-21 16:19:41 -08:00
..
Kconfig Don't try to compile shmobile-iommu outside of ARM 2013-11-15 18:57:42 -08:00
Makefile iommu: Add event tracing feature to iommu 2013-09-24 12:35:24 +02:00
amd_iommu.c iommu/amd: Fix resource leak in iommu_init_device() 2013-08-14 22:15:46 +02:00
amd_iommu_init.c iommu/amd: Clean up unnecessary MSI/MSI-X capability find 2013-08-14 12:18:52 +02:00
amd_iommu_proto.h
amd_iommu_types.h
amd_iommu_v2.c
arm-smmu.c iommu/arm-smmu: fix error return code in arm_smmu_device_dt_probe() 2013-12-06 16:44:25 +00:00
dmar.c IOMMU Updates for Linux v3.13 2013-11-15 14:02:18 +09:00
exynos-iommu.c
fsl_pamu.c iommu/fsl: Remove unnecessary 'fsl-pamu' prefixes 2013-08-14 11:44:30 +02:00
fsl_pamu.h
fsl_pamu_domain.c iommu/fsl: Fix whitespace problems noticed by git-am 2013-08-14 11:42:29 +02:00
fsl_pamu_domain.h
intel-iommu.c intel-iommu: fix off-by-one in pagetable freeing 2014-01-21 16:19:41 -08:00
intel_irq_remapping.c IOMMU Updates for Linux v3.13 2013-11-15 14:02:18 +09:00
iommu-traces.c iommu: Add iommu_error class event to iommu trace 2013-09-25 11:07:04 +02:00
iommu.c Merge branches 'iommu/fixes', 'tracing', 'core', 'arm/tegra', 'x86/vt-d', 'arm/smmu' and 'arm/shmobile' into next 2013-11-01 14:44:25 +01:00
iova.c
irq_remapping.c
irq_remapping.h
msm_iommu.c
msm_iommu.h
msm_iommu_dev.c drivers/iommu: remove unnecessary platform_set_drvdata() 2013-09-11 15:56:24 -07:00
msm_iommu_hw-8xxx.h
of_iommu.c
omap-iommu-debug.c
omap-iommu.c drivers/iommu: remove unnecessary platform_set_drvdata() 2013-09-11 15:56:24 -07:00
omap-iommu.h
omap-iommu2.c
omap-iopgtable.h drivers/iommu/omap-iopgtable.h: remove unneeded cast of void* 2013-11-13 12:09:00 +09:00
omap-iovmm.c
pci.h
shmobile-iommu.c
shmobile-ipmmu.c
shmobile-ipmmu.h
tegra-gart.c iommu/tegra-gart: Staticize tegra_gart_pm_ops 2013-11-01 14:23:20 +01:00
tegra-smmu.c iommu/tegra-smmu: Staticize tegra_smmu_pm_ops 2013-11-01 14:23:33 +01:00