Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2371218imu; Wed, 21 Nov 2018 10:32:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/U1YGberImEkcRj5CZUNorZEyzZsOKYd3VP9Wpv9DL65iyey077WlfCbKg1d1QqT4iWfmdX X-Received: by 2002:a17:902:bc43:: with SMTP id t3mr2306271plz.124.1542825166395; Wed, 21 Nov 2018 10:32:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542825166; cv=none; d=google.com; s=arc-20160816; b=cX9qXgbJ3BvodXsnz//sg1j4sDzgTWyLd8/axKngaEWteYYKqkpW8MrB0X/rtNZ/2S BUZdkGo9xFtLbT5Qw6XKl8KC5WEAwDloRbqtw90KWUhEFHh056wM8jaWe2gs79WdMIbN 9lNieLDVAEuSBpccqypq+ZlwA91J64HgsFGvBW9FApBormMUBt93wLO+l+MHXr+xUS55 YAaxiYMjqfHDZOd4MG8xYaTSpzwgKACacY5EdwXMisoBK7Bf0dtcI2g5j76iZ+F/imD8 nOLBZsrgX3FmIHTP8rCa+MHLI6By8KS/aUMpHax5Vn4HjsKzh/y9Z+boG0eTCprXYdV/ Ol+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kiPuq/GoC373I3Dsk+LEyd4wHf2PvyQLWfmOhIQQALg=; b=wqaxbDkNffbIPyv0So88sOidSIqvnzoa3dOum1KDoQBxnAxYEJO/rLgSiUwUXhtrlU mBy2dUHCY4NymZQ6HI8TBvh9VWQpsugk85JdJAQpJC/RTqyy0soF8O8AoeqMZXN10ybM xuDajpxfQwIMYG/ZBrxbvHYMrJTPdtwxygkOxwaYTWPR1JX60yQ+jUh+r4WuTwTUoCXZ vbe5joK5Jab3lf9Sbz4UstTooIHp0DHa5sM5uvoZNMetwUcsqOtbhnwI0iWXCWeM4o7N m/u5u7qhUlP9fPS/KzXd3dEh1EOEASoM608gUgPljjXuERwNrrpHK7FYs+X52SZY18RK iYLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cd16si20423431plb.47.2018.11.21.10.32.30; Wed, 21 Nov 2018 10:32:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731604AbeKVCgA (ORCPT + 99 others); Wed, 21 Nov 2018 21:36:00 -0500 Received: from foss.arm.com ([217.140.101.70]:53628 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730072AbeKVCf7 (ORCPT ); Wed, 21 Nov 2018 21:35:59 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 33BA53610; Wed, 21 Nov 2018 08:00:58 -0800 (PST) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AE97A3F5CF; Wed, 21 Nov 2018 08:00:56 -0800 (PST) From: Robin Murphy To: hch@lst.de, konrad.wilk@oracle.com Cc: m.szyprowski@samsung.com, john.stultz@linaro.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sstabellini@kernel.org Subject: [PATCH v2 1/2] dma-direct: Make DIRECT_MAPPING_ERROR viable for SWIOTLB Date: Wed, 21 Nov 2018 16:00:50 +0000 Message-Id: <0b969e82ff750c50587550c55cb46c4025d35f39.1542812807.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.19.1.dirty In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 Tested-by: John Stultz Acked-by: Konrad Rzeszutek Wilk Reviewed-by: Christoph Hellwig Signed-off-by: Robin Murphy --- v2: Add parentheses, tweak commit message, collect tags 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 #include -#define DIRECT_MAPPING_ERROR 0 +#define DIRECT_MAPPING_ERROR (~(dma_addr_t)0) #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA #include -- 2.19.1.dirty