Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2005099rbb; Tue, 27 Feb 2024 07:53:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUc+QeL40ors4MAdpCqmJm9JZIMOws3q6fiIsf6biEUFByVuusXEteOJeKLWClyvoN+o4Vlo+zpoE6iUIRC8ubdD1nkAjMCX5m1AOPMqQ== X-Google-Smtp-Source: AGHT+IGqwQt+aSugxS98/y9q95YE31QPcQx8vhlMM4WXS4LqZMDKOUMIn23ZJlRZKdxLhKrK7gc3 X-Received: by 2002:a0d:d54e:0:b0:609:1918:5c80 with SMTP id x75-20020a0dd54e000000b0060919185c80mr2591242ywd.42.1709049197405; Tue, 27 Feb 2024 07:53:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709049197; cv=pass; d=google.com; s=arc-20160816; b=cC6OummpUvD0QyijdCr/260qioxOLs3ZI20uXdFA9wLfLRCJ+Shs+tVzNiv94v8QnO ppaOJOoC98q3iZfXrV0lgbDo03j8mM8K/F1lCumjvn5R3GUry+Yf7bnXOKf5Ru4M+oHA BQl0/Z7C4L2dUvpayit7DDL4843SCcI2xjRfqYTnubmP3nm5tti6IPFFlJs8733W/ZEq jxEqZ8QMHZGy+GDaelX1LA2IGujQumLry1Pw9ll+e3ekBFEY5+r+L43PtnbYGjTUL9W6 mVD1WrWKxPOeQKhFLIZcIcRDqiFqoPf196MRcaih6rmt4BPOk8ykESW0d7/KRUMcsiFd L9Vw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=Qc2vWItm7eS9+cwvqndMfZZQLyy5ANJJ+VhwBauXX7g=; fh=Gh9iUA0Iby59PA/f0+y/2RqjwpYnQnm+oPmSRKJhEvQ=; b=UvCbE9AUJw4Ek+FAJV7n1lNY4NGxF8TVi8LBoWBBkXBTuAKkxD6VWixr5loXtwhsWj 7k3ExY1yw0vv1V6WkPRRFuPBS/ju80fuJcqkT9rrpBp3KR/d2xXaHjnIOVvuAnsah4ym O5pV52AWG5YwD8lM1W/LZaZgQ342D1TxnxIy9P9ZCf9xxgTRy8eBTS5X6VQ9wNfKJHTj fQe2e5ClAiopLL6t2QBSZyXO6iJYdckdhAzDOGxPRctvZZ4gjm+L9DkbghwcbQXyl4qL roGlcEki5Ibck+wHzKib6FNvg1SHk5itddPYeeaBuS5tNgPv5jIt5xwVHV4Ch2k61H3w 39xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-83544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83544-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i14-20020ac84f4e000000b0042e5f6ad275si7469390qtw.183.2024.02.27.07.53.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 07:53:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-83544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83544-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2C78C1C228F8 for ; Tue, 27 Feb 2024 15:53:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9FE91468E4; Tue, 27 Feb 2024 15:53:10 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67E0213DBA4 for ; Tue, 27 Feb 2024 15:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709049190; cv=none; b=ArtmjHRNWUuMSSOGMnM5dP23++SGB3hUJuXV1KBxgO56aqUnyC323PL4ElQyHxqtUtEWjPd21q9h2HNiV+i/iPeM8G/dauvV3/y+7IZHFWS99vmxPVkIJ4sCV3pET1WCkHhj2TaO1wv9XH6PdcFmP0dJKZWX9A9X8PLqiaNK9CQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709049190; c=relaxed/simple; bh=20LAPwHAALBc7f1xxFAOBHsiasE4WVaDzQaiCUGjsmg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ljcxiphRlWLxnk8n9y/GZG8vAACtpO0GKBA7ZRAzqERYLQ6ikge4loH8UNg2nOZqXUCFwwLhrj4x7gQMMvgUl3+vSvIYK0xG7L7vPGXYAt8pj8LMXoLpmQqNDcW4sv4IH85REqya7NX41eAhX3K1sRlL8mVkiuqS8jCy7AiGP9U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 133C8DA7; Tue, 27 Feb 2024 07:53:46 -0800 (PST) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4D3503F762; Tue, 27 Feb 2024 07:53:06 -0800 (PST) Message-ID: <57c928e6-14a4-4724-8c07-e985a2bce522@arm.com> Date: Tue, 27 Feb 2024 15:53:05 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 5/5] iommu/dma: Force swiotlb_max_mapping_size on an untrusted device Content-Language: en-GB To: Christoph Hellwig , Will Deacon Cc: 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 References: <20240221113504.7161-1-will@kernel.org> <20240221113504.7161-6-will@kernel.org> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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. Thanks, Robin.