Blob Blame History Raw
From: Joerg Roedel <jroedel@suse.de>
Date: Mon, 24 Aug 2020 12:54:14 +0200
Subject: iommu/amd: Do not force direct mapping when SME is active
Git-commit: 7cad554887f1c5fd77e57e6bf4be38370c2160cb
Patch-mainline: v5.9-rc4
References: bsc#1174358

Do not force devices supporting IOMMUv2 to be direct mapped when memory
encryption is active. This might cause them to be unusable because their
DMA mask does not include the encryption bit.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Link: https://lore.kernel.org/r/20200824105415.21000-2-joro@8bytes.org
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/amd_iommu.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2372,7 +2372,12 @@ static int amd_iommu_add_device(struct d
 
 	BUG_ON(!dev_data);
 
-	if (dev_data->iommu_v2)
+	/*
+	 * Do not identity map IOMMUv2 capable devices when memory encryption is
+	 * active, because some of those devices (AMD GPUs) don't have the
+	 * encryption bit in their DMA-mask and require remapping.
+	 */
+	if (!mem_encrypt_active() && dev_data->iommu_v2)
 		iommu_request_dm_for_dev(dev);
 
 	/* Domains are initialized for this device - have a look what we ended up with */