[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 4 Apr 2022 11:47:06 -0500
From: Mario Limonciello <mario.limonciello@....com>
To: Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>
CC: Christoph Hellwig <hch@...radead.org>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Robin Murphy <robin.murphy@....com>,
"open list:IOMMU DRIVERS" <iommu@...ts.linux-foundation.org>,
Suthikulpanit Suravee <Suravee.Suthikulpanit@....com>,
Hegde Vasant <Vasant.Hegde@....com>,
"open list" <linux-kernel@...r.kernel.org>,
Mario Limonciello <mario.limonciello@....com>
Subject: [PATCH 1/2] swiotlb: Check that slabs have been allocated when requested
If the IOMMU is in use and an untrusted device is connected to an external
facing port but the address requested isn't page aligned will cause the
kernel to attempt to use bounce buffers.
If the bounce buffers have not been allocated however, this leads
to messages like this:
swiotlb buffer is full (sz: 4096 bytes), total 0 (slots), used 0 (slots)
Clarify the error message because the buffer isn't full, it doesn't
exist!
Signed-off-by: Mario Limonciello <mario.limonciello@....com>
---
kernel/dma/swiotlb.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index 73a41cec9e38..d2a20cedf0d2 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -591,6 +591,11 @@ phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr,
if (!mem)
panic("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer");
+ if (!mem->nslabs) {
+ dev_warn_once(dev, "No slabs have been configured, unable to use SWIOTLB buffer");
+ return (phys_addr_t)DMA_MAPPING_ERROR;
+ }
+
if (cc_platform_has(CC_ATTR_MEM_ENCRYPT))
pr_warn_once("Memory encryption is active and system is using DMA bounce buffers\n");
--
2.34.1
Powered by blists - more mailing lists