From patchwork Tue Nov 20 14:09:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 10690737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BAB515A7 for ; Tue, 20 Nov 2018 16:25:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A3792A9A2 for ; Tue, 20 Nov 2018 16:25:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E8B62A9DE; Tue, 20 Nov 2018 16:25:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE6E72A9A2 for ; Tue, 20 Nov 2018 16:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vvrxACiTvJpDMzZCJof0jEdsfY8VqmJcS/ci+cJqWL0=; b=j+dN3vjfdidAdk y38baHEBlUfFCxHkcw73u3qYJqGj7uk2WyeHx3lPdhLdxCARXTVpbQg/wvILoe2WM55uh/2hPZdWh nuYpNnNwLcP+wrsPr1tDfGczGfD53UVnjAfHjzvWV9mIi4od1KOkTez/5mtcBctGis8yySh78yOmn ajmmWNJvncLQFzImpBFAjGPu2KxaXBqQLdbHXWOJlZWe6bu96mhtn4jboRzUlnXXI6Ar0uTJaWIj8 x/9SYAzEcI0nF5JzM49tw0wFb+jW3agiF93MEwSzP2jkkkvrEYtI5yefyBRT/iwDDGvd+IGj2twsj t1G8JasaZJ8376Y0uT/g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP8q5-0005rD-HV; Tue, 20 Nov 2018 16:25:25 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP8kv-0001i9-VM for linux-arm-kernel@bombadil.infradead.org; Tue, 20 Nov 2018 16:20:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Yc+AFKZZS9ZF6dxGvUOAIgUzg0qEUVPxkMiwxTPjuyQ=; b=n5Vu/aOKiR7Q0oNUXL9AEYGLOu BLRXG8JDCqEWP4C1QkcPvM3RuN18QtCzrTqEGOvFjSOLjjwgNQEHhNe+tcomcJrNaumPv0sj5FRFb FdNk88edyT4cGB8gCGqFNboH0KAA1O3fZm74yGGn6veB1eGaFnb0GqqB1ji+FQQ2U18smNFWBvyZr 1xPw/8gHEFmxigoGGDYmKyDMuP3gu5thqOAcoRysQmofOwx15FuxwHdfbAIwgAA25OfbLb1nQVeqy 3RBM/FVNyTPdhrfgKtujEWQoz4Aow2MJYVmeun9hj3/o77j03UP7n+wNr1AHWv4Ivfj+W8XGNUXeY e4WppWTw==; Received: from foss.arm.com ([217.140.101.70]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP6jP-0007wn-Vu for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2018 14:10:25 +0000 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 DE81C15AB; Tue, 20 Nov 2018 06:10:10 -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 7E4FF3F5A0; Tue, 20 Nov 2018 06:10:09 -0800 (PST) From: Robin Murphy To: hch@lst.de, konrad.wilk@oracle.com Subject: [PATCH 1/2] swiotlb: Make DIRECT_MAPPING_ERROR viable Date: Tue, 20 Nov 2018 14:09:52 +0000 Message-Id: X-Mailer: git-send-email 2.19.1.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181120_141024_160602_B705D1D9 X-CRM114-Status: GOOD ( 12.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: iommu@lists.linux-foundation.org, john.stultz@linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 commonly-used all-bits-set value, 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 Signed-off-by: Robin Murphy --- 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..9de9c7ab39d6 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