Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2511524rbb; Wed, 28 Feb 2024 04:23:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVVimNKtGfuzSV/WBelpdVp4eYHdm2zytzQKyTG34FgyEEzO4ADD/vxGDEh0KulKRvAdXfqEEYnOta2s3zLcalqNDzlqCqS8J2S0cvuQw== X-Google-Smtp-Source: AGHT+IHo3P03X/bJd85eIqjo7RNKz7bbKRKWeKh383KkiNfPSDQZkW2CZVI8yrQmmPosc9zzW93W X-Received: by 2002:a05:6a21:918b:b0:1a1:2138:b7a6 with SMTP id tp11-20020a056a21918b00b001a12138b7a6mr423201pzb.20.1709123018582; Wed, 28 Feb 2024 04:23:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709123018; cv=pass; d=google.com; s=arc-20160816; b=SoFkRyGo4kjX7m4H1QmZI8nAnhOpv2DUth+/hhGxZRfnphU/lLFcxHUKC3+lUYa3vv d7jKTAPM4323X2pidiEM6toJLj9T/r7BE/ys1aA5aZeTfzmBia5JJUj9uUCF1bDOLhWv sJhyYMcfYi5TjQC8Kwm2pI6MC5roC8SUmHIxYCIBvu9TSVAHDDnOyrTrF4ar1JCarRXQ k8NePrUsGV3Nz7xWCHua5vcZtZ0i5bRmSYw2eDktlI5FuK6Lj2LiEAsFjaBAVPjOjH2U UYuC7bo+lOn0L3u1VB69UCInFh6Aj+0fyIerXWbBiaLkSQhGx1pb6JgrKKgHoJMQ5Djx 23Fg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=RAe9u9eCiB2tRd1XpdrejSiOzVdYJjf569JxzUv6mwg=; fh=dTRDIwrORxC2gVOSSOGj2ebwcRyg2YyZK7MI+9TkdQc=; b=EvQz0TEt6f38sweY/YgdoWuIxC1Uf1COAKWVN1mEnxDSsS/kGbDasjY8dJ39GYNzut xu++WPMLqdWzlSz5v97VokWyYA4+N31Y8DsQHebyUmDeyZlVmQavt1zL6KJcOAshMdZG NwFusqIjlKNXoiFGh/AOzL3r86CvGQtei0R/ABOd48cqpPwcBx4ehR0zTSFK6t3HCBmk t333ukAChDVe00kDu9390hSavf8YkO6iFyPP9H4+YTlkWGLcXE1J27NGvzSz6fXVjN2C M+PM4lQxDJ3scxq/iJMQt4EjmM4oC355v/RzHKnIOrNqyoJ72mGcenGfW9pmx2vN3n58 muGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pi2YBY6d; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-84994-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84994-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id w9-20020a634749000000b005e42b4bb9dasi7128951pgk.213.2024.02.28.04.23.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 04:23:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84994-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pi2YBY6d; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-84994-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84994-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0112CB24037 for ; Wed, 28 Feb 2024 12:05:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DCA133BBCB; Wed, 28 Feb 2024 12:05:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Pi2YBY6d" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C28373501; Wed, 28 Feb 2024 12:05:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709121930; cv=none; b=mFGZE5puAl36xFns5ley+Xah+7c1BYo3tIHbz18r3QklUxjT5kMba2thPtmK7CurhxL39o5IDuXVzR52MaHNwFPXtuJ9M69fqP/IEYpG5nl6cn87qPUweZ5iRvRBw/VCyy+Lc5SENaVA2zmGS+HG1H6tv6+20EUOt6FTxKzRD9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709121930; c=relaxed/simple; bh=SU9EilANUxXGjBEPo0K/zUkP5ytJW6h7olNyIK9TmFE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jUx3DB2srBQDHMWZ/xdg+dDrcA3C8xSyMBtxsJKNKA9F74pjR8m3ey9gICa7lI383wVZWVPQyGhDZWdOsEMX2pK43fYKJekkXAOa50LpAE1hSB9e4D2v7IQV5M55i+KETUFKeECGKR4lMID74MnxVKo9ac9KPSEcD2ERE9IrST4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pi2YBY6d; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80324C433F1; Wed, 28 Feb 2024 12:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709121929; bh=SU9EilANUxXGjBEPo0K/zUkP5ytJW6h7olNyIK9TmFE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pi2YBY6daQjrwS2RlLYQDvKF110QllmzVuDJBm0iiG4NU+5kvOFBKcXs1NQsocdty op7bv2UvR80xWR9wIelLL8PLk1TYBUJC9Q/Ptte66JNOoMsEdGZ2TBULNfSxtuUAe9 sT8UdLi56LGCwFXNARDXCP3noKvhtXmNzQuOmshEvABbFstGte87DKbLLeljh+MVhC GszhgCQkWJ3QITLL0qo++/OE9yh1H1vmrKPYwYL9zpvok8Xw4zy+5LvvNRyDpFEknA 4w/H+bdehwnzcTN0YeRiJJ0yQyfzzd+3+z78SzRBz0iOmuBg4aWncKu3qD1Fm2faOA 5K/cmbD3psHbg== Date: Wed, 28 Feb 2024 12:05:23 +0000 From: Will Deacon To: Robin Murphy Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, kernel-team@android.com, iommu@lists.linux.dev, Christoph Hellwig , Marek Szyprowski , Petr Tesarik , Dexuan Cui , Nicolin Chen , Michael Kelley Subject: Re: [PATCH v4 5/5] iommu/dma: Force swiotlb_max_mapping_size on an untrusted device Message-ID: <20240228120523.GA15054@willie-the-truck> References: <20240221113504.7161-1-will@kernel.org> <20240221113504.7161-6-will@kernel.org> <57c928e6-14a4-4724-8c07-e985a2bce522@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57c928e6-14a4-4724-8c07-e985a2bce522@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) On Tue, Feb 27, 2024 at 03:53:05PM +0000, Robin Murphy wrote: > On 27/02/2024 3:40 pm, Christoph Hellwig wrote: > > On Wed, Feb 21, 2024 at 11:35:04AM +0000, Will Deacon wrote: > > > +static size_t iommu_dma_max_mapping_size(struct device *dev) > > > +{ > > > + if (is_swiotlb_active(dev) && dev_is_untrusted(dev)) > > > + return swiotlb_max_mapping_size(dev); > > > > Curious: do we really need both checks here? If swiotlb is active > > for a device (for whatever reason), aren't we then always bound > > by the max size? If not please add a comment explaining it. > > > > Oh, good point - if we have an untrusted device but SWIOTLB isn't > initialised for whatever reason, then it doesn't matter what > max_mapping_size returns because iommu_dma_map_page() is going to bail out > regardless. Makes sense. Since this is all internal to the IOMMU DMA code, I can just drop the first part of the check. I'll get a v5 out shortly. Will