Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp809047imu; Tue, 20 Nov 2018 07:17:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/UUj7Tb+I0dmzAHNBHKZwX0pmDUN80P0V9tQmMo7OOQLSc4WLCQzYwX1C6KtuUcyzd0jIUE X-Received: by 2002:a63:cd4c:: with SMTP id a12mr2317506pgj.252.1542727036862; Tue, 20 Nov 2018 07:17:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542727036; cv=none; d=google.com; s=arc-20160816; b=fo33RqDd9auMlQzDSBkUcp8uZ1Do52+9fNs65m0UUegLoJPgwAak41sLD5iO9YH4Vp /4OCoILl7Rwzsej0r/ThWbz5n5fYRXq5ECX/4scM8qV6ZSUEpHpxFPlWH0Mm5PnYqC+h rPnOqIFbLmMiPKuIbsre3qyzlI7MU+UGlP7mUxkx3h/ZDI0piGOS4Q6IRI5jMppdDGNq 85BZOb3lcyCvb/D3qKlbrFuGS5DgZqPwXhC+k59oVbhdZTkBGO00cuyZ4N+CVjIftvm+ XERqFD7agCGAfwijLg/hvk4i5KV0aCFaGsjtjPEqn9ZIf22Wgh+0wVwMpG0SMRELzCyg 4+hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=O1WGBOqujV4t0MJM3uCoAt6text/TbUo8RLfeEkbOAg=; b=lEoeIlE92HIJztCO6kmtM0F0pe6tQ7h1HJdIW1XKN10T9Nw2yDzb8N69Wdr8aPUIfR 9hcnfV6mi0n9rMPW8/AIl+t4sHBFDi69MuFG5mvFgFGWcNgmQ7A7tUU/u1FzF4wrGvIw VEw5Szd3q+5cZ4n5BZ+Rzrs+ZC/5XFFFHPqiuC4NrirNgToKFD4nEJxxXiMW+FFY+8Oa rEpYBkMfdgWizpUcdV+9W2jCshleeplyEGcRI1hgz0qN5nUk93GWcT/LZI8w6McmVpt5 RqyJJtEq9ct1X9xMD/1G0Lp0aaaHnyiFBTyscGITfSinMfbHEBUr5CgZK7gg3oQ9tjVB 6P3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=OoXC0kWh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si9600865pln.355.2018.11.20.07.16.56; Tue, 20 Nov 2018 07:17:16 -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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=OoXC0kWh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729875AbeKUBTY (ORCPT + 99 others); Tue, 20 Nov 2018 20:19:24 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:33432 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725899AbeKUBTW (ORCPT ); Tue, 20 Nov 2018 20:19:22 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAKEhqHn161269; Tue, 20 Nov 2018 14:49:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=O1WGBOqujV4t0MJM3uCoAt6text/TbUo8RLfeEkbOAg=; b=OoXC0kWhO8MtzD/w87HtcoHTghYpgRuAKtpbuxvMhGzhgx4bCBjpYhMTiyrMiVxdGEdj Z+910as3ly5Wq3V69ULMgpcH2BD4X+QF/r4JPp18B+b18HeY2ZZz+ddVhBGsjKmpt/aY wn9C55+9UihAo7tOhyqOXK97xALVVC1466ef/zQ8K5hcPVL8qYO0Ue/LTZf/cea6bzJR IPFgPrpCAdXG41i+zcPy8diF68wuC6/wVJWsX6peH5HkV/Bin0iCF374k9RqPrNm91aE ak2tL0a4YIKGaUOuuZ2D6Z40jbbX5agB0KAhfP23KrZ6PDXoiqcEFmUjZQGN0yd855As rQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2ntaxq4b1s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Nov 2018 14:49:21 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAKEnKn0002939 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Nov 2018 14:49:20 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wAKEnJe9007473; Tue, 20 Nov 2018 14:49:19 GMT Received: from char.us.oracle.com (/10.152.32.25) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Nov 2018 06:49:19 -0800 Received: by char.us.oracle.com (Postfix, from userid 1000) id 368C56A00D4; Tue, 20 Nov 2018 09:49:18 -0500 (EST) Date: Tue, 20 Nov 2018 09:49:18 -0500 From: Konrad Rzeszutek Wilk To: Robin Murphy Cc: hch@lst.de, 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: Re: [PATCH 1/2] swiotlb: Make DIRECT_MAPPING_ERROR viable Message-ID: <20181120144918.GH10917@char.us.oracle.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9082 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=945 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811200133 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 20, 2018 at 02:09:52PM +0000, Robin Murphy wrote: > 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. Are all the callers checking for DIRECT_MAPPING_ERROR or is it more of a comparison (as in if (!ret)) ? > > 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 >