summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLendacky, Thomas <Thomas.Lendacky@amd.com>2018-12-17 14:39:16 +0000
committerChristoph Hellwig <hch@lst.de>2018-12-17 18:02:11 +0100
commitc92a54cfa0257e8ffd66b2a17d49e9c0bd4b769f (patch)
tree2f8219da4e77366fc8ad432b8894b7911f98af2b
parent6531e115b7ab84f563fcd7f0d2d05ccf971aaaf9 (diff)
downloadlinux-stable-c92a54cfa0257e8ffd66b2a17d49e9c0bd4b769f.tar.gz
linux-stable-c92a54cfa0257e8ffd66b2a17d49e9c0bd4b769f.tar.bz2
linux-stable-c92a54cfa0257e8ffd66b2a17d49e9c0bd4b769f.zip
dma-direct: do not include SME mask in the DMA supported check
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> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--kernel/dma/direct.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 22a12ab5a5e9..375c77e8d52f 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)