Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1442332 > unrolled thread

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

Started byJoerg Roedel <joro@8bytes.org>
First post2016-07-13 12:50 +0200
Last post2016-07-13 12:50 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] iommu/amd: Init unity mappings only for dma_ops domains Joerg Roedel <joro@8bytes.org> - 2016-07-13 12:50 +0200

#1442332 — [PATCH] iommu/amd: Init unity mappings only for dma_ops domains

FromJoerg Roedel <joro@8bytes.org>
Date2016-07-13 12:50 +0200
Subject[PATCH] iommu/amd: Init unity mappings only for dma_ops domains
Message-ID<rUpTQ-1UQ-27@gated-at.bofh.it>
From: Joerg Roedel <jroedel@suse.de>

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>
---
 drivers/iommu/amd_iommu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 921111e..b938a4a 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);
 }
-- 
2.6.6

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web