diff for duplicates of <20191105162856.GA15402@lst.de> diff --git a/a/1.txt b/N1/1.txt index eb63c5f..53f9577 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -21,57 +21,3 @@ Can you send me the .config and a dmesg? And in the meantime try the patch below? --- -From 4d659b7311bd4141fdd3eeeb80fa2d7602ea01d4 Mon Sep 17 00:00:00 2001 -From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> -Date: Fri, 18 Oct 2019 13:00:43 +0200 -Subject: dma-direct: check for overflows on 32 bit DMA addresses - -As seen on the new Raspberry Pi 4 and sta2x11's DMA implementation it is -possible for a device configured with 32 bit DMA addresses and a partial -DMA mapping located at the end of the address space to overflow. It -happens when a higher physical address, not DMAable, is translated to -it's DMA counterpart. - -For example the Raspberry Pi 4, configurable up to 4 GB of memory, has -an interconnect capable of addressing the lower 1 GB of physical memory -with a DMA offset of 0xc0000000. It transpires that, any attempt to -translate physical addresses higher than the first GB will result in an -overflow which dma_capable() can't detect as it only checks for -addresses bigger then the maximum allowed DMA address. - -Fix this by verifying in dma_capable() if the DMA address range provided -is at any point lower than the minimum possible DMA address on the bus. - -Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> ---- - include/linux/dma-direct.h | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h -index adf993a3bd58..6ad9e9ea7564 100644 ---- a/include/linux/dma-direct.h -+++ b/include/linux/dma-direct.h -@@ -3,6 +3,7 @@ - #define _LINUX_DMA_DIRECT_H 1 - - #include <linux/dma-mapping.h> -+#include <linux/memblock.h> /* for min_low_pfn */ - #include <linux/mem_encrypt.h> - - #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA -@@ -27,6 +28,13 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) - if (!dev->dma_mask) - return false; - -+#ifndef CONFIG_ARCH_DMA_ADDR_T_64BIT -+ /* Check if DMA address overflowed */ -+ if (min(addr, addr + size - 1) < -+ __phys_to_dma(dev, (phys_addr_t)(min_low_pfn << PAGE_SHIFT))) -+ return false; -+#endif -+ - return addr + size - 1 <= - min_not_zero(*dev->dma_mask, dev->bus_dma_mask); - } --- -2.20.1 diff --git a/a/content_digest b/N1/content_digest index 08e7f30..38ed6fe 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -42,60 +42,6 @@ "Can you send me the .config and a dmesg? And in the meantime try the\n" "patch below?\n" "\n" - "---\n" - "From 4d659b7311bd4141fdd3eeeb80fa2d7602ea01d4 Mon Sep 17 00:00:00 2001\n" - "From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>\n" - "Date: Fri, 18 Oct 2019 13:00:43 +0200\n" - "Subject: dma-direct: check for overflows on 32 bit DMA addresses\n" - "\n" - "As seen on the new Raspberry Pi 4 and sta2x11's DMA implementation it is\n" - "possible for a device configured with 32 bit DMA addresses and a partial\n" - "DMA mapping located at the end of the address space to overflow. It\n" - "happens when a higher physical address, not DMAable, is translated to\n" - "it's DMA counterpart.\n" - "\n" - "For example the Raspberry Pi 4, configurable up to 4 GB of memory, has\n" - "an interconnect capable of addressing the lower 1 GB of physical memory\n" - "with a DMA offset of 0xc0000000. It transpires that, any attempt to\n" - "translate physical addresses higher than the first GB will result in an\n" - "overflow which dma_capable() can't detect as it only checks for\n" - "addresses bigger then the maximum allowed DMA address.\n" - "\n" - "Fix this by verifying in dma_capable() if the DMA address range provided\n" - "is at any point lower than the minimum possible DMA address on the bus.\n" - "\n" - "Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>\n" - "---\n" - " include/linux/dma-direct.h | 8 ++++++++\n" - " 1 file changed, 8 insertions(+)\n" - "\n" - "diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h\n" - "index adf993a3bd58..6ad9e9ea7564 100644\n" - "--- a/include/linux/dma-direct.h\n" - "+++ b/include/linux/dma-direct.h\n" - "@@ -3,6 +3,7 @@\n" - " #define _LINUX_DMA_DIRECT_H 1\n" - " \n" - " #include <linux/dma-mapping.h>\n" - "+#include <linux/memblock.h> /* for min_low_pfn */\n" - " #include <linux/mem_encrypt.h>\n" - " \n" - " #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA\n" - "@@ -27,6 +28,13 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)\n" - " \tif (!dev->dma_mask)\n" - " \t\treturn false;\n" - " \n" - "+#ifndef CONFIG_ARCH_DMA_ADDR_T_64BIT\n" - "+\t/* Check if DMA address overflowed */\n" - "+\tif (min(addr, addr + size - 1) <\n" - "+\t\t__phys_to_dma(dev, (phys_addr_t)(min_low_pfn << PAGE_SHIFT)))\n" - "+\t\treturn false;\n" - "+#endif\n" - "+\n" - " \treturn addr + size - 1 <=\n" - " \t\tmin_not_zero(*dev->dma_mask, dev->bus_dma_mask);\n" - " }\n" - "-- \n" - 2.20.1 + --- -909a521ed2f18d149b79d1423f31aa19174e2cf8b5b009e4728a6de52f36ebb9 +f5a6c0cff1ee70482c0f14325c51e94882af9051acce6ca3f10924c8cb6d125c
diff --git a/a/1.txt b/N2/1.txt index eb63c5f..481d586 100644 --- a/a/1.txt +++ b/N2/1.txt @@ -75,3 +75,8 @@ index adf993a3bd58..6ad9e9ea7564 100644 } -- 2.20.1 + +_______________________________________________ +iommu mailing list +iommu@lists.linux-foundation.org +https://lists.linuxfoundation.org/mailman/listinfo/iommu diff --git a/a/content_digest b/N2/content_digest index 08e7f30..5316677 100644 --- a/a/content_digest +++ b/N2/content_digest @@ -12,12 +12,11 @@ "Subject\0Re: Bug 205201 - overflow of DMA mask and bus mask\0" "Date\0Tue, 5 Nov 2019 17:28:56 +0100\0" "To\0Christian Zigotzky <chzigotzky@xenosoft.de>\0" - "Cc\0Christoph Hellwig <hch@lst.de>" - linux-arch@vger.kernel.org + "Cc\0linux-arch@vger.kernel.org" linux-kernel@vger.kernel.org linux-mm@kvack.org iommu@lists.linux-foundation.org - " Olof Johansson <olof@lixom.net>\0" + " Christoph Hellwig <hch@lst.de>\0" "\00:1\0" "b\0" "On Tue, Nov 05, 2019 at 08:56:27AM +0100, Christian Zigotzky wrote:\n" @@ -96,6 +95,11 @@ " \t\tmin_not_zero(*dev->dma_mask, dev->bus_dma_mask);\n" " }\n" "-- \n" - 2.20.1 + "2.20.1\n" + "\n" + "_______________________________________________\n" + "iommu mailing list\n" + "iommu@lists.linux-foundation.org\n" + https://lists.linuxfoundation.org/mailman/listinfo/iommu -909a521ed2f18d149b79d1423f31aa19174e2cf8b5b009e4728a6de52f36ebb9 +edf8e5180316c5734ea55f4fd770ba43b6c5e5dfecd7f8e3fc32a81c93b08972
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.