public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-alpha-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-parisc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Linus Torvalds
	<torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	xen-devel-GuqFBffKawtpuQazS67q72D2FQJk+8+b@public.gmane.org,
	David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH 01/24] dma-direct: Make DIRECT_MAPPING_ERROR viable for SWIOTLB
Date: Thu, 22 Nov 2018 15:02:57 +0100	[thread overview]
Message-ID: <20181122140320.24080-2-hch@lst.de> (raw)
In-Reply-To: <20181122140320.24080-1-hch-jcswGhMUV9g@public.gmane.org>

From: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>

With the overflow buffer removed, we no longer have a unique address
which is guaranteed not to be a valid DMA target to use as an error
token. The DIRECT_MAPPING_ERROR value of 0 tries to at least represent
an unlikely DMA target, but unfortunately there are already SWIOTLB
users with DMA-able memory at physical address 0 which now gets falsely
treated as a mapping failure and leads to all manner of misbehaviour.

The best we can do to mitigate that is flip DIRECT_MAPPING_ERROR to the
other commonly-used error value of all-bits-set, since the last single
byte of memory is by far the least-likely-valid DMA target.

Fixes: dff8d6c1ed58 ("swiotlb: remove the overflow buffer")
Reported-by: John Stultz <john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Tested-by: John Stultz <john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 include/linux/dma-direct.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index bd73e7a91410..9e66bfe369aa 100644
--- a/include/linux/dma-direct.h
+++ b/include/linux/dma-direct.h
@@ -5,7 +5,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/mem_encrypt.h>
 
-#define DIRECT_MAPPING_ERROR		0
+#define DIRECT_MAPPING_ERROR		(~(dma_addr_t)0)
 
 #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA
 #include <asm/dma-direct.h>
-- 
2.19.1

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: iommu@lists.linux-foundation.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Jon Mason <jdmason@kudzu.us>, Joerg Roedel <joro@8bytes.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Robin Murphy <robin.murphy@arm.com>,
	x86@kernel.org, linux-alpha@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org,
	linux-parisc@vger.kernel.org, xen-devel@lists.xenproject.org,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 01/24] dma-direct: Make DIRECT_MAPPING_ERROR viable for SWIOTLB
Date: Thu, 22 Nov 2018 15:02:57 +0100	[thread overview]
Message-ID: <20181122140320.24080-2-hch@lst.de> (raw)
Message-ID: <20181122140257.8rJREQDA16iZEou9kt2Q7sG45zCKR9dxgXMDjLyaz5Q@z> (raw)
In-Reply-To: <20181122140320.24080-1-hch@lst.de>

From: Robin Murphy <robin.murphy@arm.com>

With the overflow buffer removed, we no longer have a unique address
which is guaranteed not to be a valid DMA target to use as an error
token. The DIRECT_MAPPING_ERROR value of 0 tries to at least represent
an unlikely DMA target, but unfortunately there are already SWIOTLB
users with DMA-able memory at physical address 0 which now gets falsely
treated as a mapping failure and leads to all manner of misbehaviour.

The best we can do to mitigate that is flip DIRECT_MAPPING_ERROR to the
other commonly-used error value of all-bits-set, since the last single
byte of memory is by far the least-likely-valid DMA target.

Fixes: dff8d6c1ed58 ("swiotlb: remove the overflow buffer")
Reported-by: John Stultz <john.stultz@linaro.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/dma-direct.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index bd73e7a91410..9e66bfe369aa 100644
--- a/include/linux/dma-direct.h
+++ b/include/linux/dma-direct.h
@@ -5,7 +5,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/mem_encrypt.h>
 
-#define DIRECT_MAPPING_ERROR		0
+#define DIRECT_MAPPING_ERROR		(~(dma_addr_t)0)
 
 #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA
 #include <asm/dma-direct.h>
-- 
2.19.1

  parent reply	other threads:[~2018-11-22 14:02 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-22 14:02 remove the ->mapping_error method from dma_map_ops V2 Christoph Hellwig
2018-11-22 14:02 ` Christoph Hellwig
     [not found] ` <20181122140320.24080-1-hch-jcswGhMUV9g@public.gmane.org>
2018-11-22 14:02   ` Christoph Hellwig [this message]
2018-11-22 14:02     ` [PATCH 01/24] dma-direct: Make DIRECT_MAPPING_ERROR viable for SWIOTLB Christoph Hellwig
2018-11-22 14:02   ` [PATCH 02/24] swiotlb: Skip cache maintenance on map error Christoph Hellwig
2018-11-22 14:02     ` Christoph Hellwig
2018-11-22 14:02 ` [PATCH 03/24] dma-mapping: provide a generic DMA_MAPPING_ERROR Christoph Hellwig
2018-11-22 14:02   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 04/24] dma-direct: remove the mapping_error dma_map_ops method Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 05/24] arm: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 06/24] powerpc/iommu: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 07/24] mips/jazz: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 08/24] s390: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 09/24] sparc: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 10/24] parisc/ccio: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 11/24] parisc/sba_iommu: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 12/24] arm64: remove the dummy_dma_ops mapping_error method Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 13/24] alpha: remove the mapping_error dma_map_ops method Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 14/24] ia64/sba_iommu: improve internal map_page users Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 15/24] ia64/sba_iommu: remove the mapping_error dma_map_ops method Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 16/24] ia64/sn: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 17/24] x86/amd_gart: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 18/24] x86/calgary: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 19/24] iommu: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 20/24] iommu/intel: small map_page cleanup Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 21/24] iommu/vt-d: remove the mapping_error dma_map_ops method Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 22/24] iommu/dma-iommu: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 23/24] xen-swiotlb: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 14:03 ` [PATCH 24/24] dma-mapping: " Christoph Hellwig
2018-11-22 14:03   ` Christoph Hellwig
2018-11-22 16:50 ` remove the ->mapping_error method from dma_map_ops V2 Linus Torvalds
2018-11-22 16:50   ` Linus Torvalds
2018-11-22 17:07   ` Russell King - ARM Linux
2018-11-22 17:07     ` Russell King - ARM Linux
     [not found]     ` <20181122170715.GI30658-l+eeeJia6m9URfEZ8mYm6t73F7V6hmMc@public.gmane.org>
2018-11-22 17:09       ` Linus Torvalds
2018-11-22 17:09         ` Linus Torvalds
2018-11-22 17:14         ` Russell King - ARM Linux
2018-11-22 17:14           ` Russell King - ARM Linux
2018-11-22 17:52         ` Robin Murphy
2018-11-22 17:52           ` Robin Murphy
     [not found]           ` <11829e3c-7302-f821-cf5c-863e5267a17b-5wv7dgnIgG8@public.gmane.org>
2018-11-22 17:55             ` Linus Torvalds
2018-11-22 17:55               ` Linus Torvalds
2018-11-22 18:05               ` Russell King - ARM Linux
2018-11-22 18:05                 ` Russell King - ARM Linux
     [not found]                 ` <20181122180526.GL30658-l+eeeJia6m9URfEZ8mYm6t73F7V6hmMc@public.gmane.org>
2018-11-23  6:57                   ` Christoph Hellwig
2018-11-23  6:57                     ` Christoph Hellwig
     [not found]               ` <CAHk-=whxf0zqutExPr_j1A625Z3gcL6k_ABzKo1BtzN4F93hkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-11-23  6:55                 ` Christoph Hellwig
2018-11-23  6:55                   ` Christoph Hellwig
2018-11-28  7:41                   ` Christoph Hellwig
2018-11-28  7:41                     ` Christoph Hellwig
     [not found]                     ` <20181128074117.GA21126-jcswGhMUV9g@public.gmane.org>
2018-11-28 16:47                       ` Linus Torvalds
2018-11-28 16:47                         ` Linus Torvalds
2018-11-28 17:45                         ` Russell King - ARM Linux
2018-11-28 17:45                           ` Russell King - ARM Linux
2018-11-28 18:00                           ` Linus Torvalds
2018-11-28 18:00                             ` Linus Torvalds
2018-11-28 18:08                             ` Russell King - ARM Linux
2018-11-28 18:08                               ` Russell King - ARM Linux
     [not found]                               ` <20181128180841.GM30658-l+eeeJia6m9URfEZ8mYm6t73F7V6hmMc@public.gmane.org>
2018-11-28 19:19                                 ` Linus Torvalds
2018-11-28 19:31                                   ` Russell King - ARM Linux
2018-11-28 19:31                                     ` Russell King - ARM Linux
2018-11-29 16:23                                   ` Christoph Hellwig
2018-11-29 16:23                                     ` Christoph Hellwig
2018-11-29 17:44                                     ` Linus Torvalds
2018-11-29 17:44                                       ` Linus Torvalds
2018-11-29 18:31                                       ` Christoph Hellwig
2018-11-29 18:31                                         ` Christoph Hellwig
2018-11-29 18:53                                         ` Linus Torvalds
2018-11-29 18:53                                           ` Linus Torvalds
2018-11-29 18:55                                           ` Christoph Hellwig
2018-11-29 18:55                                             ` Christoph Hellwig
2018-11-28 19:23                               ` Russell King - ARM Linux
2018-11-28 19:23                                 ` Russell King - ARM Linux
2018-11-28 19:27                             ` David Miller
2018-11-28 19:27                               ` David Miller
2018-11-28 19:47                               ` Russell King - ARM Linux
2018-11-28 19:47                                 ` Russell King - ARM Linux
     [not found]                                 ` <20181128194708.GP30658-l+eeeJia6m9URfEZ8mYm6t73F7V6hmMc@public.gmane.org>
2018-11-28 23:01                                   ` Shuah Khan
2018-11-28 23:01                                     ` Shuah Khan
2018-11-23 10:49           ` Joerg Roedel
2018-11-23 10:49             ` Joerg Roedel
2018-11-23 11:01             ` Russell King - ARM Linux
2018-11-23 11:01               ` Russell King - ARM Linux
2018-11-23 13:03               ` Joerg Roedel
2018-11-23 13:03                 ` Joerg Roedel
2018-11-23 13:20                 ` Russell King - ARM Linux
2018-11-23 13:20                   ` Russell King - ARM Linux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181122140320.24080-2-hch@lst.de \
    --to=hch-jcswghmuv9g@public.gmane.org \
    --cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=linux-alpha-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-parisc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robin.murphy-5wv7dgnIgG8@public.gmane.org \
    --cc=torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=xen-devel-GuqFBffKawtpuQazS67q72D2FQJk+8+b@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox