Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp994353imu; Tue, 20 Nov 2018 09:57:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wg5ZLX1rgz4WkXicsaPh1KdSCguBHDsHHphvDs+p1ONi9dFIIm3X9M/PWGm2wXrLfT7rI0 X-Received: by 2002:a17:902:59d6:: with SMTP id d22mr3317133plj.10.1542736631926; Tue, 20 Nov 2018 09:57:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542736631; cv=none; d=google.com; s=arc-20160816; b=o0GObBUH3BKjPmMeWYjDiwXk4NwCA7itOUxCyW1gq4LZRp+Aer3kgQRUlcoxPRGHNM Z5J5tfPgv9gFUor7Lfs5sCatsASrRnu0C28WkxxIDEcAanz2E/S5no8snOdRUZLsr4Eg pvlPgRNgB0XnbunyfUkzzxTsDqY36dwmrye+gQ/qv8sMSQKAl0dORDopqUBNKvCEhnSp LJlrrGQYCQrwPXBZNCxJVFyy3IDLSGW3bnzujOkfhZuHw9rMk2Kciy1An3OO5O5OwcMy XQANKZWgpjo15Cew5JjtmNVm9kac+b7bXRtvAkJc/QxDgzjH7O+kIlJjqJdcMtRlgyFP uajw== 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=jF3sCPpUCsdPqjWZUWYWtYftJopG9PXAOUUC7dH2OW0=; b=sy70NA6Kvkp8q1rezUGf/JOnji9NGXrv4jJS5F7eiD4W7ckEWXQBXexSVuNAc4Gqsn n50ygEJpQukZL+TqzOqYHyp4LxVKSWCF9jIUl4o3M7EDtDoB0Lcsc7FP/9TJG8Y19BP5 UHYbwf5tJI1Afd/uotklx+LSFonvTKpWdSdXiwZUct1D1qzGsrztfyHiQtS7xVUdDYS8 /lCdW8oRCPq+4tIS6YakMxrhmyex1NjRPkYW3BzMyBUbhvI5OjbOPZUzZP+a6SKhVnNw fZoBjOEUpdN9KtHgRFR1oUSl6UkNhiAmdDCft8umRz3TT1tNUtiPAIvDDbKst2rxQHfA U5vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=QYUiMWUk; 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 i6si28168223pgq.207.2018.11.20.09.56.57; Tue, 20 Nov 2018 09:57:11 -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=QYUiMWUk; 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 S1729797AbeKUDFF (ORCPT + 99 others); Tue, 20 Nov 2018 22:05:05 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:54976 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbeKUDFF (ORCPT ); Tue, 20 Nov 2018 22:05:05 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAKGY8Nk097476; Tue, 20 Nov 2018 16:34:30 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=jF3sCPpUCsdPqjWZUWYWtYftJopG9PXAOUUC7dH2OW0=; b=QYUiMWUkKOplW25OW7OKf9cPSagLLRuNa5NmoyndCbp/h3GeiSjXaYpbcmsviuYT64dA McoWPD6za2yR1/bLP3B3Nx9qKJo3hYpOGav0yeodJookSH2r7oArXg6NVozVSb1Es4e1 koAMTUUwOATLsuWYfUm4vvJz41fYGBVe7KLqUr81KCuVlWKQ15sso8AvAs8bR0SF7+jI i/mh4oLEG2pu2sXuB3AmjrPFQIP8Xl0+lCwnUM4Xl/HYZsjBSgY0h5xdR5mJnM6peQNv Ms5Ns3yxVntBZKXYc9kjFnEhUNhZhcna4FN6midvdv5ap9zXPJzzAuz2X1/ZHitmNNqE MQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2ntadtw0jt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Nov 2018 16:34:30 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wAKGYTob017211 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Nov 2018 16:34:29 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wAKGYK7e007847; Tue, 20 Nov 2018 16:34:21 GMT Received: from char.us.oracle.com (/10.152.32.25) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Nov 2018 08:34:17 -0800 Received: by char.us.oracle.com (Postfix, from userid 1000) id 36A0C6A00D4; Tue, 20 Nov 2018 11:34:16 -0500 (EST) Date: Tue, 20 Nov 2018 11:34:16 -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: <20181120163416.GC31199@char.us.oracle.com> References: <20181120144918.GH10917@char.us.oracle.com> <7ea5809e-1e1d-6bac-b723-9f55fafeaaae@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7ea5809e-1e1d-6bac-b723-9f55fafeaaae@arm.com> 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811200147 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 03:01:33PM +0000, Robin Murphy wrote: > On 20/11/2018 14:49, Konrad Rzeszutek Wilk wrote: > > 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)) ? > > dma_direct_map_page() and dma_direct_mapping_error() were already doing the > right thing, and external callers must rely on the latter via > dma_mapping_error() rather than trying to inspect the actual value > themselves, since that varies between implementations anyway. AFAICS all the > new return paths from swiotlb_map_page() are also robust in referencing the > macro explicitly, so I think we're good. Cool! Thank you for checking. Acked-by: Konrad Rzeszutek Wilk Thank you! > > Thanks, > Robin. > > > > 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 > > >