Messages in this thread Patch in this message | | | From | Mario Limonciello <> | Subject | [PATCH 1/2] swiotlb: Check that slabs have been allocated when requested | Date | Mon, 4 Apr 2022 11:47:06 -0500 |
| |
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@amd.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
| |