Skip to contentSkip to conversation

iommu/amd: Init unity mappings only for dma_ops domains

PATCH New Joerg Roedel 1 participant 1 message Jul 13, 2016 IOMMU

lore
Share & tools
lore

Joerg Roedel

author maintainer
#0 lore raw

PATCH 1/1 iommu/amd: Init unity mappings only for dma_ops domains

From: Joerg Roedel <[email protected]>

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')
---
 drivers/iommu/amd_iommu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iommu/amd_iommu.c +4 -2
index 921111e..b938a4a 100644
@@ -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);
 }
Signature · 1 line
2.6.6