All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Do not disable SWIOTLB if SME is active
@ 2017-10-06 21:35 Tom Lendacky
       [not found] ` <20171006213540.19038.84350.stgit-qCXWGYdRb2BnqfbPTmsdiZQ+2ll4COg0XqFh9Ls21Oc@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Lendacky @ 2017-10-06 21:35 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA; +Cc: Borislav Petkov

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.

Signed-off-by: Tom Lendacky <thomas.lendacky-5C7GfCeVMHo@public.gmane.org>
---
 drivers/iommu/amd_iommu.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 51f8215..822679a 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2773,14 +2773,16 @@ int __init amd_iommu_init_api(void)
 
 int __init amd_iommu_init_dma_ops(void)
 {
-	swiotlb        = iommu_pass_through ? 1 : 0;
+	swiotlb        = (iommu_pass_through || sme_me_mask) ? 1 : 0;
 	iommu_detected = 1;
 
 	/*
 	 * In case we don't initialize SWIOTLB (actually the common case
-	 * when AMD IOMMU is enabled), make sure there are global
-	 * dma_ops set as a fall-back for devices not handled by this
-	 * driver (for example non-PCI devices).
+	 * when AMD IOMMU is enabled and SME is not active), make sure there
+	 * are global dma_ops set as a fall-back for devices not handled by
+	 * this driver (for example non-PCI devices). When SME is active,
+	 * make sure that swiotlb variable remains set so the global dma_ops
+	 * continue to be SWIOTLB.
 	 */
 	if (!swiotlb)
 		dma_ops = &nommu_dma_ops;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-10 19:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-06 21:35 [PATCH] iommu/amd: Do not disable SWIOTLB if SME is active Tom Lendacky
     [not found] ` <20171006213540.19038.84350.stgit-qCXWGYdRb2BnqfbPTmsdiZQ+2ll4COg0XqFh9Ls21Oc@public.gmane.org>
2017-10-06 21:39   ` Tom Lendacky
     [not found]     ` <800bd17c-475b-c5b2-c4d1-776c655f084a-5C7GfCeVMHo@public.gmane.org>
2017-10-10  9:58       ` Joerg Roedel
     [not found]         ` <20171010095814.ux7nrtsnylz573hh-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-10-10 15:00           ` Tom Lendacky
     [not found]             ` <3117832f-db8f-a0db-c825-f97e3e097b1b-5C7GfCeVMHo@public.gmane.org>
2017-10-10 17:50               ` Joerg Roedel
     [not found]                 ` <20171010175011.GB30803-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-10-10 19:24                   ` Tom Lendacky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.