alistair23-linux/drivers/iommu
David Dillow f7116e115a iommu/vt-d: Don't over-free page table directories
dma_pte_free_level() recurses down the IOMMU page tables and frees
directory pages that are entirely contained in the given PFN range.
Unfortunately, it incorrectly calculates the starting address covered
by the PTE under consideration, which can lead to it clearing an entry
that is still in use.

This occurs if we have a scatterlist with an entry that has a length
greater than 1026 MB and is aligned to 2 MB for both the IOMMU and
physical addresses. For example, if __domain_mapping() is asked to map a
two-entry scatterlist with 2 MB and 1028 MB segments to PFN 0xffff80000,
it will ask if dma_pte_free_pagetable() is asked to PFNs from
0xffff80200 to 0xffffc05ff, it will also incorrectly clear the PFNs from
0xffff80000 to 0xffff801ff because of this issue. The current code will
set level_pfn to 0xffff80200, and 0xffff80200-0xffffc01ff fits inside
the range being cleared. Properly setting the level_pfn for the current
level under consideration catches that this PTE is outside of the range
being cleared.

This patch also changes the value passed into dma_pte_free_level() when
it recurses. This only affects the first PTE of the range being cleared,
and is handled by the existing code that ensures we start our cursor no
lower than start_pfn.

This was found when using dma_map_sg() to map large chunks of contiguous
memory, which immediatedly led to faults on the first access of the
erroneously-deleted mappings.

Fixes: 3269ee0bd6 ("intel-iommu: Fix leaks in pagetable freeing")
Reviewed-by: Benjamin Serebrin <serebrin@google.com>
Signed-off-by: David Dillow <dillow@google.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
2017-01-31 12:50:05 +01:00
..
amd_iommu.c iommu/amd: Fix the left value check of cmd buffer 2017-01-04 15:22:22 +01:00
amd_iommu_init.c More ACPI updates for v4.10-rc1 2016-12-22 10:19:32 -08:00
amd_iommu_proto.h Merge branch 'x86/amd-avic' into x86/amd 2016-09-05 12:43:16 +02:00
amd_iommu_types.h KVM updates for v4.9-rc1 2016-10-06 10:49:01 -07:00
amd_iommu_v2.c iommu/amd: Missing error code in amd_iommu_init_device() 2016-11-29 17:39:44 +01:00
arm-smmu-v3.c iommu/arm-smmu-v3: Add IORT configuration 2016-11-29 15:57:46 +00:00
arm-smmu.c Merge branches 'arm/mediatek', 'arm/smmu', 'x86/amd', 's390', 'core' and 'arm/exynos' into next 2016-12-06 17:32:16 +01:00
dma-iommu.c iommu/dma: Implement dma_{map,unmap}_resource() 2016-11-14 16:58:36 +01:00
dmar.c ACPI / DMAR: Avoid passing NULL to acpi_put_table() 2017-01-05 15:10:52 +01:00
exynos-iommu.c iommu/exynos: Use device dependency links to control runtime pm 2016-11-14 17:11:59 +01:00
fsl_pamu.c powerpc/fsl: Move fsl_guts.h out of arch/powerpc 2015-10-21 18:05:50 -05:00
fsl_pamu.h
fsl_pamu_domain.c iommu/fsl: Convert to device_group call-back 2015-10-22 00:00:49 +02:00
fsl_pamu_domain.h
intel-iommu.c iommu/vt-d: Don't over-free page table directories 2017-01-31 12:50:05 +01:00
intel-svm.c iommu/vt-d: Fix PASID table allocation 2016-11-19 09:42:35 -08:00
intel_irq_remapping.c SVM fixes for Linux 4.5 2016-02-16 08:04:06 -08:00
io-pgtable-arm-v7s.c iommu/io-pgtable-arm: Use for_each_set_bit to simplify the code 2016-11-29 15:57:40 +00:00
io-pgtable-arm.c iommu/io-pgtable-arm: Use const and __initconst for iommu_gather_ops structures 2016-11-29 15:57:41 +00:00
io-pgtable.c iommu/io-pgtable: Fix a brace coding style issue. 2016-04-05 15:34:29 +02:00
io-pgtable.h iommu/io-pgtable: Add MTK 4GB mode in Short-descriptor 2016-04-05 15:39:37 +02:00
iommu-sysfs.c
iommu-traces.c
iommu.c Merge branches 'arm/mediatek', 'arm/smmu', 'x86/amd', 's390', 'core' and 'arm/exynos' into next 2016-12-06 17:32:16 +01:00
iova.c iommu/iova: Extend cached node lookup condition 2016-11-15 12:39:52 +01:00
ipmmu-vmsa.c iommu/ipmmu-vmsa: Fix wrong error handle of ipmmu_add_device 2016-09-05 12:53:58 +02:00
irq_remapping.c x86/cpufeature: Replace cpu_has_apic with boot_cpu_has() usage 2016-04-13 11:37:41 +02:00
irq_remapping.h
Kconfig iommu/arm-smmu: Support non-PCI devices with SMMUv3 2016-09-16 09:34:17 +01:00
Makefile Merge branches 'x86/amd', 'x86/vt-d', 'arm/exynos', 'arm/mediatek', 'arm/msm', 'arm/rockchip', 'arm/smmu' and 'core' into next 2016-07-26 16:02:37 +02:00
msm_iommu.c iommu/msm: use generic ARMV7S short descriptor pagetable ops 2016-06-21 13:57:13 +02:00
msm_iommu.h iommu/msm: Add DT adaptation 2016-06-21 13:56:00 +02:00
msm_iommu_hw-8xxx.h
mtk_iommu.c Merge branches 'arm/mediatek', 'arm/smmu', 'x86/amd', 's390', 'core' and 'arm/exynos' into next 2016-12-06 17:32:16 +01:00
mtk_iommu.h iommu/mediatek: Convert DT component matching to component_match_add_release() 2016-11-10 12:25:16 +01:00
mtk_iommu_v1.c Merge branches 'arm/mediatek', 'arm/smmu', 'x86/amd', 's390', 'core' and 'arm/exynos' into next 2016-12-06 17:32:16 +01:00
of_iommu.c iommu: Make of_iommu_set/get_ops() DT agnostic 2016-11-29 15:57:43 +00:00
omap-iommu-debug.c iommu/omap: Align code with open parenthesis 2016-04-05 17:53:20 +02:00
omap-iommu.c iommu/omap: Use WARN_ON for page table alignment check 2016-04-05 17:53:20 +02:00
omap-iommu.h iommu/omap: Add support for configuring dsp iommus on DRA7xx 2015-10-14 14:35:47 +02:00
omap-iopgtable.h
rockchip-iommu.c iommu/rockchip: Prepare to support generic DMA mapping 2016-06-27 14:50:08 +02:00
s390-iommu.c iommu/s390: Drop duplicate header pci.h 2016-11-29 17:37:58 +01:00
tegra-gart.c
tegra-smmu.c