iommu/amd: Init unity mappings only for dma_ops domains

commit b548e786ce upstream.

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: 0bb6e243d7 ('iommu/amd: Support IOMMU_DOMAIN_DMA type allocation')
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Joerg Roedel
2016-07-13 12:35:24 +02:00
committed by Greg Kroah-Hartman
parent 51e94ff8d9
commit df8eaed225

View File

@@ -352,9 +352,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);
}