Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1998695rbb; Tue, 27 Feb 2024 07:40:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXx6aE22GvgYoTKQ4bJTNhVimSwM7h+ADbfpcieKQwugael/wvSjPupDhfVM7cDR53gcOUV5VGrQdyvWq68Mq4He3iBxyytypa+gXwQfA== X-Google-Smtp-Source: AGHT+IFqFWxYQ6OoYRt6w6pd4xyRH5kJsX4OK7c1zoW9grNt+6eUIOqfaowUUJBHW4TFe97+eT9A X-Received: by 2002:a17:906:ce30:b0:a3f:bd94:4d80 with SMTP id sd16-20020a170906ce3000b00a3fbd944d80mr6672649ejb.76.1709048442852; Tue, 27 Feb 2024 07:40:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709048442; cv=pass; d=google.com; s=arc-20160816; b=sjmBAqvvdgoSBz89E2JiArs/Qa8Liw+th19nMGtD2NqS5z22b252j5HpZokMyDMZny Ie7SmlFvPF64983wm/MWWcY1S1qkZUac8STvwg81I8RzWYnHSxe6rt78gaTjtS5VkOtD UAnWkaZS/9ZC9kuJW1c7roga+yw6TLt9A5rgy2gUxD9J0GMxOO6bx4EkGRgbWkMQyO4R im7ALuVOR9algqBw40AEg+3rBRWdHFzhRYe8S6W9IrxIy1/C6gyF1fSwEvMfa/pvjcc+ qA8zR69p83QhRyvl+L6whf/J9IPeiKgQMEbXrAssslnQCNmL0amHS9ANDoHTnlueErGA uFlQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=r3ZEbWsCJHgCVJ0r8he9VWyoedSF99TnfaCfGUy0RzA=; fh=CB6POrSIkdk+RyfbFm+yqa9KLR3zsLngk1fk1KLAoy0=; b=jUM5K4B18HHdDfg3FtwMuTu6clbp/kmIk/FkGG2XzOmUZay+vTFfbKLujwaswm+01R 6R6a1l0Aa2OmLxBVXQGNrs0tIKQOcLdC9ynO1/+x3OiNFa2iY75BvxEmVrcHfv87D2VO gvAH0knWUB1H6za14qysZTl8572B+KEhiV8FQxXIQ9PTTbJogGLSWl+zZQpb+BFXIzOU K1nFMF4xpL4UD/Oek82vQrMxy3LEYg6a8i8L6CfZj+Gl/7YusZtgW7zYbv+zmcBSJxAN sN6MtylA4TiI5ukAPRe6LHxZbgYdlwjVYFnQSeUDlTM5D+3rA8VYVdcy264pQqXNTy3B xR/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=dFpLYTJH; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-83518-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83518-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i8-20020a170906a28800b00a3fd13eb0b6si796161ejz.418.2024.02.27.07.40.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 07:40:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83518-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=dFpLYTJH; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-83518-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83518-linux.lists.archive=gmail.com@vger.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9AB141F23DF8 for ; Tue, 27 Feb 2024 15:40:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFDC4145FEF; Tue, 27 Feb 2024 15:40:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="dFpLYTJH" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 05718145351; Tue, 27 Feb 2024 15:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709048436; cv=none; b=fAQMS3x63QfYClnqo9iJPHHWzJ6cJsTdnUAdXf1Fz6eqG8ohLIQ47jta3rl0GQh43j9CUR9Dg7X8wRpDVF+BDwAHZnF/6U1Vc0NhqbBpX81NcW4NM5zP7FiEQUFrpzbnVri1u3Uly/J1QMQLD34Xhz2AhqB5ALiixNcjnjMQjkQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709048436; c=relaxed/simple; bh=lBLIuciUfLLdhMU8sA8OeS0LAgcXIgpkhNbhKryepEw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jWqrD6pclLI6xGT3JxHh41/lNudkQIPNGjId+IG5KDogjx2oPtVu0RKXqfN2zAh2i/lyAlbcXxSyLuHtF1WQNpJslTT2W9FGCGdXRAIrftlay88xu0eDYihvaoZsdBcBj8e+Jqsk8fLtGzVysv9Rj+PUHIQxHXEPoxk09jYqRO0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=dFpLYTJH; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=r3ZEbWsCJHgCVJ0r8he9VWyoedSF99TnfaCfGUy0RzA=; b=dFpLYTJHypNqkRcwjKNx3n26Dd D+ZsaJT/6nPEiWlbZe9DtgWSHqAwI4HfF4rb4sA6BRu3iznLrsRk4QJOEHzd5Sj0ahPH5GJFekTPH h2AAAgK9+pgzypZHzeR8kIy7N36rn9ciusynwb89QxKoG2O5JqkX3Wrdt/qPMnRCNWN4JuTJVQMnJ AiK+Ml28K63mmZ7CaHBrDJMp2TFniMy5gqdpOJc1gFU4WOYo8psOBy5sN/ZGREHj6JkFNpxjOLbui 5CX1RuI4G6QefI7+ERYX0VMhkIRaMJlCTkc9unqKrvKt9LJoWtuj56NVTiW0SQXPI7f/aMmEIuBQ5 SYj91vDg==; Received: from [12.229.247.3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rezZJ-00000005oXH-1yMi; Tue, 27 Feb 2024 15:40:33 +0000 Date: Tue, 27 Feb 2024 07:40:32 -0800 From: Christoph Hellwig To: Will Deacon Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, iommu@lists.linux.dev, Christoph Hellwig , Marek Szyprowski , Robin Murphy , 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: References: <20240221113504.7161-1-will@kernel.org> <20240221113504.7161-6-will@kernel.org> 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: <20240221113504.7161-6-will@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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.