remarkable-linux/drivers/iommu
David Woodhouse ea8ea460c9 iommu/vt-d: Clean up and fix page table clear/free behaviour
There is a race condition between the existing clear/free code and the
hardware. The IOMMU is actually permitted to cache the intermediate
levels of the page tables, and doesn't need to walk the table from the
very top of the PGD each time. So the existing back-to-back calls to
dma_pte_clear_range() and dma_pte_free_pagetable() can lead to a
use-after-free where the IOMMU reads from a freed page table.

When freeing page tables we actually need to do the IOTLB flush, with
the 'invalidation hint' bit clear to indicate that it's not just a
leaf-node flush, after unlinking each page table page from the next level
up but before actually freeing it.

So in the rewritten domain_unmap() we just return a list of pages (using
pg->freelist to make a list of them), and then the caller is expected to
do the appropriate IOTLB flush (or tear down the domain completely,
whatever), before finally calling dma_free_pagelist() to free the pages.

As an added bonus, we no longer need to flush the CPU's data cache for
pages which are about to be *removed* from the page table hierarchy anyway,
in the non-cache-coherent case. This drastically improves the performance
of large unmaps.

As a side-effect of all these changes, this also fixes the fact that
intel_iommu_unmap() was neglecting to free the page tables for the range
in question after clearing them.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2014-03-19 17:21:41 +00:00
..
amd_iommu.c iommu/amd: Use dev_is_pci() to check whether it is pci device 2014-01-07 15:21:32 +01:00
amd_iommu_init.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
amd_iommu_proto.h
amd_iommu_types.h
amd_iommu_v2.c
arm-smmu.c arm/smmu: Use irqsafe spinlock for domain lock 2014-02-20 13:04:47 +01:00
dmar.c iommu/vt-d: Unify the way to process DMAR device scope array 2014-03-04 17:51:06 +01:00
exynos-iommu.c iommu/exynos: Remove dead code (set_prefbuf) 2013-08-14 11:28:45 +02:00
fsl_pamu.c iommu/fsl: Remove unnecessary 'fsl-pamu' prefixes 2013-08-14 11:44:30 +02:00
fsl_pamu.h iommu/fsl: Freescale PAMU driver and iommu implementation. 2013-08-14 11:38:34 +02:00
fsl_pamu_domain.c iommu/fsl_pamu: Use dev_is_pci() to check whether it is pci device 2014-01-07 15:23:08 +01:00
fsl_pamu_domain.h iommu/fsl: Freescale PAMU driver and iommu implementation. 2013-08-14 11:38:34 +02:00
intel-iommu.c iommu/vt-d: Clean up and fix page table clear/free behaviour 2014-03-19 17:21:41 +00:00
intel_irq_remapping.c iommu/vt-d: Introduce a rwsem to protect global data structures 2014-03-04 17:51:05 +01: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 iommu/vt-d: Update IOMMU state when memory hotplug happens 2014-03-04 17:51:06 +01:00
irq_remapping.c iommu/vt-d, trivial: clean sparse warnings 2014-01-09 12:44:16 +01:00
irq_remapping.h
Kconfig iommu: shmobile: Enable driver compilation with COMPILE_TEST 2014-01-07 15:10:11 +01:00
Makefile iommu: Add event tracing feature to iommu 2013-09-24 12:35:24 +02:00
msm_iommu.c iommu/msm: Move mach includes to iommu directory 2013-08-06 11:18:03 -07:00
msm_iommu.h iommu/msm: Move mach includes to iommu directory 2013-08-06 11:18:03 -07:00
msm_iommu_dev.c drivers/iommu: remove unnecessary platform_set_drvdata() 2013-09-11 15:56:24 -07:00
msm_iommu_hw-8xxx.h iommu/msm: Move mach includes to iommu directory 2013-08-06 11:18:03 -07:00
of_iommu.c iommu: add missing include 2014-01-07 15:16:27 +01:00
omap-iommu-debug.c drivers/iommu/omap-iommu-debug.c: fix decimal permissions 2014-02-25 15:25:42 -08:00
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 iommu/shmobile: Allocate archdata with kzalloc() 2014-01-07 15:35:25 +01:00
shmobile-ipmmu.c iommu/shmobile: Turn the flush_lock mutex into a spinlock 2014-01-07 15:35:25 +01:00
shmobile-ipmmu.h iommu/shmobile: Turn the flush_lock mutex into a spinlock 2014-01-07 15:35:25 +01:00
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