summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2016-07-13 12:35:24 +0200
committerJoerg Roedel <jroedel@suse.de>2016-07-13 12:35:24 +0200
commitb548e786ce47017107765bbeb0f100202525ea83 (patch)
tree158fae78345a2ad96536115fe4929eee425f34e4
parentcf7513e759d19908c29cf2c129587ecda34a5c19 (diff)
downloadlinux-b548e786ce47017107765bbeb0f100202525ea83.tar.gz
linux-b548e786ce47017107765bbeb0f100202525ea83.tar.bz2
linux-b548e786ce47017107765bbeb0f100202525ea83.zip
iommu/amd: Init unity mappings only for dma_ops domains
The default domain for a device might also be identity-mapped. In this case the kernel would crash when unity mappings are defined for the device. Fix that by making sure the domain is a dma_ops domain. Fixes: 0bb6e243d7fb ('iommu/amd: Support IOMMU_DOMAIN_DMA type allocation') Cc: stable@vger.kernel.org # v4.2+ Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r--drivers/iommu/amd_iommu.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 921111e65c8c..b938a4ac3a37 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -467,9 +467,11 @@ static void init_iommu_group(struct device *dev)
if (!domain)
goto out;
- dma_domain = to_pdomain(domain)->priv;
+ if (to_pdomain(domain)->flags == PD_DMA_OPS_MASK) {
+ dma_domain = to_pdomain(domain)->priv;
+ init_unity_mappings_for_device(dev, dma_domain);
+ }
- init_unity_mappings_for_device(dev, dma_domain);
out:
iommu_group_put(group);
}