aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Lendacky <thomas.lendacky@amd.com>2017-10-06 17:35:40 -0400
committerJoerg Roedel <jroedel@suse.de>2017-10-10 13:49:30 -0400
commitaba2d9a6385a5cc4f7a7e8eb5788e1ddbc213fc0 (patch)
tree6cfb500a8efede70d0f23bfa6de5364547afd41d
parent8a5776a5f49812d29fe4b2d0a2d71675c3facf3f (diff)
iommu/amd: Do not disable SWIOTLB if SME is active
When SME memory encryption is active it will rely on SWIOTLB to handle DMA for devices that cannot support the addressing requirements of having the encryption mask set in the physical address. The IOMMU currently disables SWIOTLB if it is not running in passthrough mode. This is not desired as non-PCI devices attempting DMA may fail. Update the code to check if SME is active and not disable SWIOTLB. Fixes: 2543a786aa25 ("iommu/amd: Allow the AMD IOMMU to work with memory encryption") Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r--drivers/iommu/amd_iommu.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 51f8215877f5..822679ac90a1 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2773,14 +2773,16 @@ int __init amd_iommu_init_api(void)
2773 2773
2774int __init amd_iommu_init_dma_ops(void) 2774int __init amd_iommu_init_dma_ops(void)
2775{ 2775{
2776 swiotlb = iommu_pass_through ? 1 : 0; 2776 swiotlb = (iommu_pass_through || sme_me_mask) ? 1 : 0;
2777 iommu_detected = 1; 2777 iommu_detected = 1;
2778 2778
2779 /* 2779 /*
2780 * In case we don't initialize SWIOTLB (actually the common case 2780 * In case we don't initialize SWIOTLB (actually the common case
2781 * when AMD IOMMU is enabled), make sure there are global 2781 * when AMD IOMMU is enabled and SME is not active), make sure there
2782 * dma_ops set as a fall-back for devices not handled by this 2782 * are global dma_ops set as a fall-back for devices not handled by
2783 * driver (for example non-PCI devices). 2783 * this driver (for example non-PCI devices). When SME is active,
2784 * make sure that swiotlb variable remains set so the global dma_ops
2785 * continue to be SWIOTLB.
2784 */ 2786 */
2785 if (!swiotlb) 2787 if (!swiotlb)
2786 dma_ops = &nommu_dma_ops; 2788 dma_ops = &nommu_dma_ops;