Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp733296imu; Tue, 20 Nov 2018 06:12:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/UMDtcUr2pJ9oR26c5hgmRAadDvoy9YI3abrVzmT1GdARG26npfsGo67+GJr1jn1xBJgyOs X-Received: by 2002:a63:62c3:: with SMTP id w186mr2039504pgb.345.1542723124362; Tue, 20 Nov 2018 06:12:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542723124; cv=none; d=google.com; s=arc-20160816; b=P0RtctlaNxDMlgxJ7agN65CYsazpc+uHMJZUUjpZe5EQuKadA7knY7fQd4511tVHHy IFwtT13g7O8pOM/8quLWzoTw4kZF7+3g9MfjY9pP/sxQn0kXv4k3Rr+9nPSQjdXqB+df F/gSJru6Wj3BB3VewyLT4CmYi2osHeLoidSutG7H9KUAy/RR0vc1at43OoCzvgM4EyaJ RFaOW47Ld2laLaxGw2nKbW8WiM0YftGwQ9iTKSmk/zOKxTQ/Molp9H2wsCt9CoIO9aLs OxE0g7k28lZgpjJWqsvfzWeCedm671k/KNE+t1ZSQvQiXsD/PVeR02a3gs3tW9NC9zJ7 bgHw== 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=Yc+AFKZZS9ZF6dxGvUOAIgUzg0qEUVPxkMiwxTPjuyQ=; b=Ikz/rwXlDBOd7XdeLNa16K/A0rI/GtWKwDLEikp20R4lMj99vKGtzuziIyLLNfobuc iOBuIWrnNFi525VefS1HynGoJen83daujgYfVEveQkOD4yrtszy0pnRtU4xSfTg2KmrK spUYnEiQ4YzM8p8P9s0X7ifuZ5t3t1kNsW/GhjfBV75jqClNgR2c1DBxIUB2wEoZo3FM MumpLFeLvwUnwVUHfeXe480vDPL+0bGkwypaaJlwCTuCDBVl/OC5dP6MjFAYhxS8ptOJ y5Y1dl7Gr2OSWYHZ2le7W15Lv4xX/o+omok7uY47G1g9JVZTWDXGIK8d/uV+w9NaKwP3 3omw== 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 e184si10764340pfg.185.2018.11.20.06.11.25; Tue, 20 Nov 2018 06:12:04 -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 S1728985AbeKUAjb (ORCPT + 99 others); Tue, 20 Nov 2018 19:39:31 -0500 Received: from foss.arm.com ([217.140.101.70]:49414 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728395AbeKUAja (ORCPT ); Tue, 20 Nov 2018 19:39:30 -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 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 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 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 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 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 -- 2.19.1.dirty