* [PATCH] kernel/dma/direct: Do not include SME mask in the DMA supported check
@ 2018-12-13 22:51 Lendacky, Thomas
2018-12-15 10:55 ` Christoph Hellwig
2018-12-17 14:39 ` [RESEND PATCH] " Lendacky, Thomas
0 siblings, 2 replies; 6+ messages in thread
From: Lendacky, Thomas @ 2018-12-13 22:51 UTC (permalink / raw)
To: iommu@lists.linux-foundation.org
Cc: Benjamin Herrenschmidt, linuxppc-dev@lists.ozlabs.org,
Alexander Duyck, linux-kernel@vger.kernel.org, Greg KH,
Robin Murphy, Christoph Hellwig, Guenter Roeck
The dma_direct_supported() function intends to check the DMA mask against
specific values. However, the phys_to_dma() function includes the SME
encryption mask, which defeats the intended purpose of the check. This
results in drivers that support less than 48-bit DMA (SME encryption mask
is bit 47) from being able to set the DMA mask successfully when SME is
active, which results in the driver failing to initialize.
Change the function used to check the mask from phys_to_dma() to
__phys_to_dma() so that the SME encryption mask is not part of the check.
Fixes: c1d0af1a1d5d ("kernel/dma/direct: take DMA offset into account in dma_direct_supported")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
kernel/dma/direct.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 22a12ab..375c77e 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -309,7 +309,12 @@ int dma_direct_supported(struct device *dev, u64 mask)
min_mask = min_t(u64, min_mask, (max_pfn - 1) << PAGE_SHIFT);
- return mask >= phys_to_dma(dev, min_mask);
+ /*
+ * This check needs to be against the actual bit mask value, so
+ * use __phys_to_dma() here so that the SME encryption mask isn't
+ * part of the check.
+ */
+ return mask >= __phys_to_dma(dev, min_mask);
}
int dma_direct_mapping_error(struct device *dev, dma_addr_t dma_addr)
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] kernel/dma/direct: Do not include SME mask in the DMA supported check
2018-12-13 22:51 [PATCH] kernel/dma/direct: Do not include SME mask in the DMA supported check Lendacky, Thomas
@ 2018-12-15 10:55 ` Christoph Hellwig
[not found] ` <20181215105510.GA1806-jcswGhMUV9g@public.gmane.org>
2018-12-17 14:39 ` [RESEND PATCH] " Lendacky, Thomas
1 sibling, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2018-12-15 10:55 UTC (permalink / raw)
To: Lendacky, Thomas
Cc: iommu@lists.linux-foundation.org, Benjamin Herrenschmidt,
linuxppc-dev@lists.ozlabs.org, Alexander Duyck,
linux-kernel@vger.kernel.org, Greg KH, Robin Murphy,
Christoph Hellwig, Guenter Roeck
The mail seems to be so oddly encoded so that git-am fails on it. Can
you resend as plain text?
^ permalink raw reply [flat|nested] 6+ messages in thread* [RESEND PATCH] kernel/dma/direct: Do not include SME mask in the DMA supported check
2018-12-13 22:51 [PATCH] kernel/dma/direct: Do not include SME mask in the DMA supported check Lendacky, Thomas
2018-12-15 10:55 ` Christoph Hellwig
@ 2018-12-17 14:39 ` Lendacky, Thomas
2018-12-17 17:02 ` Christoph Hellwig
1 sibling, 1 reply; 6+ messages in thread
From: Lendacky, Thomas @ 2018-12-17 14:39 UTC (permalink / raw)
To: iommu@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
Christoph Hellwig, Alexander Duyck, Robin Murphy,
Benjamin Herrenschmidt, Guenter Roeck, Greg KH
The dma_direct_supported() function intends to check the DMA mask against
specific values. However, the phys_to_dma() function includes the SME
encryption mask, which defeats the intended purpose of the check. This
results in drivers that support less than 48-bit DMA (SME encryption mask
is bit 47) from being able to set the DMA mask successfully when SME is
active, which results in the driver failing to initialize.
Change the function used to check the mask from phys_to_dma() to
__phys_to_dma() so that the SME encryption mask is not part of the check.
Fixes: c1d0af1a1d5d ("kernel/dma/direct: take DMA offset into account in dma_direct_supported")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
kernel/dma/direct.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 22a12ab..375c77e 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -309,7 +309,12 @@ int dma_direct_supported(struct device *dev, u64 mask)
min_mask = min_t(u64, min_mask, (max_pfn - 1) << PAGE_SHIFT);
- return mask >= phys_to_dma(dev, min_mask);
+ /*
+ * This check needs to be against the actual bit mask value, so
+ * use __phys_to_dma() here so that the SME encryption mask isn't
+ * part of the check.
+ */
+ return mask >= __phys_to_dma(dev, min_mask);
}
int dma_direct_mapping_error(struct device *dev, dma_addr_t dma_addr)
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [RESEND PATCH] kernel/dma/direct: Do not include SME mask in the DMA supported check
2018-12-17 14:39 ` [RESEND PATCH] " Lendacky, Thomas
@ 2018-12-17 17:02 ` Christoph Hellwig
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2018-12-17 17:02 UTC (permalink / raw)
To: Lendacky, Thomas
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, Christoph Hellwig, Alexander Duyck,
Robin Murphy, Benjamin Herrenschmidt, Guenter Roeck, Greg KH
Thanks,
applied to the dma-mapping for-linus tree.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-12-17 17:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-13 22:51 [PATCH] kernel/dma/direct: Do not include SME mask in the DMA supported check Lendacky, Thomas
2018-12-15 10:55 ` Christoph Hellwig
[not found] ` <20181215105510.GA1806-jcswGhMUV9g@public.gmane.org>
2018-12-16 23:41 ` Lendacky, Thomas
2018-12-17 14:49 ` Lendacky, Thomas
2018-12-17 14:39 ` [RESEND PATCH] " Lendacky, Thomas
2018-12-17 17:02 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox