From mboxrd@z Thu Jan 1 00:00:00 1970 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.