Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp292793lqh; Sat, 4 May 2024 01:17:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXu9f0D68PIsQIS6Ytx278kayipLnXgyyjy3zwvCK934wx+HIl+BKeWswqxBgW0biT41R71N/i933uHSSG0gJbK2WbiRygrx6wgsNrKbQ== X-Google-Smtp-Source: AGHT+IGZQKNOI6NiDIUt4Tj3RL+g1IqmW38OWR+5W/Gxi7uOBBugsfM+Jt9D1U243sS41Grkavv8 X-Received: by 2002:a17:902:ecc6:b0:1e2:9aa7:fd21 with SMTP id a6-20020a170902ecc600b001e29aa7fd21mr6021527plh.54.1714810631204; Sat, 04 May 2024 01:17:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714810631; cv=pass; d=google.com; s=arc-20160816; b=r1Z6S7E1FtAuA/Nl7cB+b1U/4AKmY5X8tT7TrFy8hUrA6T8j4zgsidfsxvcGjsnHGo 0LYy5/B0mLYuC1/4L5Bessf0ayIKtqMqO613D1Xv/uXP8dsw6pGTKaurfrn+Et5kzHZs K0Y8EW++NZv0OvBITdpTKYx0Kp/a/H770QF+xn9hmKPcvqK629Hkf7Dj6/ELNcuKyq16 cGh6BHX66o/5ZYP61VMJNa7lfWOyMBT/IQ6urvA7K+VDsMThmU3OcgP4A9/P7r1XQpWv JBqhkLlyfGCAJlBykl1E/+b5RrhBLdaFDQ52fgXBVB+POPtNufviEgkFik6WQ7e/U++Z VaPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=HIQTiZruIzF8K/sYeFSJkzkfpUCRGh0NaHzc0R77M4g=; fh=JsItueBXiCq2fJYesxOWAkQjdkTxTD7Nmo1LJ1NY4zs=; b=pXex0Lqx+b/t7zc0cHcxCevGAURXilWIYKMT36XK6oZ620VkC3jBYx+WdTtfamlkA5 P7OMmcLK80PXrZmZR4+mE7R4BWbqP83ta6RfIzdRWNfCnGaJoTtm5qd9ZRm3PKht+E6+ EiOEMorVsY8Md9WClJeszPLtXoSGqx1nXIWJD4vqPNJ16vHVhfzokwB0ht8ogCE2R+Ga L9rLLMwv05HGYyO5ysaGul3YP2jaI1jeSAd3YjBpUmhs9wpxs2djDMADcXM2B3wW9ErG 5e3Yv71JGU7kW2Z0Ws14G5zC2NNpHmQM0lP93b23i8cshooYse/MtEDk1+7AuSxIrhyr 6rAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=DV+Xe+9J; arc=pass (i=1 spf=pass spfdomain=tesarici.cz dkim=pass dkdomain=tesarici.cz dmarc=pass fromdomain=tesarici.cz); spf=pass (google.com: domain of linux-kernel+bounces-168551-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168551-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tesarici.cz Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s17-20020a17090302d100b001eb790bd913si1776707plk.479.2024.05.04.01.17.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 01:17:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168551-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=DV+Xe+9J; arc=pass (i=1 spf=pass spfdomain=tesarici.cz dkim=pass dkdomain=tesarici.cz dmarc=pass fromdomain=tesarici.cz); spf=pass (google.com: domain of linux-kernel+bounces-168551-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168551-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tesarici.cz 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CEC632826ED for ; Sat, 4 May 2024 08:17:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D9A1111AA; Sat, 4 May 2024 08:17:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tesarici.cz header.i=@tesarici.cz header.b="DV+Xe+9J" Received: from bee.tesarici.cz (bee.tesarici.cz [37.205.15.56]) (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 2512110A0A; Sat, 4 May 2024 08:16:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.205.15.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714810624; cv=none; b=MC+VdhPh6q9RxGZ4hVTgEdCw/GSyc2Amdv5BH389AnmXZNqNx0wb0lP6Oa1epkNLT10HvJAq9kCCvQidYohZm25sfEC7d2wRVv8wYhTF0o1EqmfAujw0SilTN/hmm7laXgyO9MfEnnp4woSzO3VubXFuIh5pzu2/j3uUBwR26yQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714810624; c=relaxed/simple; bh=5KLQ5djW6HtWwiT2B9Pb+poWNF+1A6VF1v+gQJIH0bM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZJtZlIiTiJffFwPtaJdjmvC4zbZliemBUPGCs9HmX2Z4qv/kT7kHMYaSU7GfNZ9C1frr6rXFTpEbzlrxwPSo3f/J5J3MMKUa7XNoPbgqeDAstwjrOZROPdR8kNqeWhZGQ+HtfjvrjnHUeiox7M3oRoIrpkMGovpmZivJ45mlgVU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tesarici.cz; spf=pass smtp.mailfrom=tesarici.cz; dkim=pass (2048-bit key) header.d=tesarici.cz header.i=@tesarici.cz header.b=DV+Xe+9J; arc=none smtp.client-ip=37.205.15.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tesarici.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tesarici.cz Received: from meshulam.tesarici.cz (dynamic-2a00-1028-83b8-1e7a-4427-cc85-6706-c595.ipv6.o2.cz [IPv6:2a00:1028:83b8:1e7a:4427:cc85:6706:c595]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bee.tesarici.cz (Postfix) with ESMTPSA id 060441BA1D9; Sat, 4 May 2024 10:16:52 +0200 (CEST) Authentication-Results: mail.tesarici.cz; dmarc=fail (p=quarantine dis=none) header.from=tesarici.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tesarici.cz; s=mail; t=1714810612; bh=HIQTiZruIzF8K/sYeFSJkzkfpUCRGh0NaHzc0R77M4g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DV+Xe+9JkNy6B/5oNxKh9ZDZSsY1jtZZ6kQwSp+2wLf2OuF0HFTOw0w6z1Tv3OR80 TQwBP6j/fwqAkMrg3Lj8JimDRpkYlqN2czE6jNikZSWzP1pyAPH+ua+LXisk7VSxSw mbQ+hP4l7EITxV7zt8BWkJ/Yz66kC/tONhSyjc+Lse3YhEDmbpvu04Q5dlEPVtrb3v NJ5EeEnAHeizDOUwfAMZp2LN1QK5HTOTpNM9C7FFh+hUroQgFYLU9Y6zT5Z2EHhkBi eJxhMDU6HNDsFn6vXteIH4jxFShl3PTMyYf4LP46W2ZTs33hXWxssYzDlFlef0eaHF 0d+1+JigElsDA== Date: Sat, 4 May 2024 10:16:51 +0200 From: Petr =?UTF-8?B?VGVzYcWZw61r?= To: "T.J. Mercier" Cc: Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , hch@infradead.org, robin.murphy@arm.com, joro@8bytes.org, will@kernel.org, akpm@linux-foundation.org, isaacmanjarres@google.com, iommu@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Kelley Subject: Re: [PATCH] swiotlb: iommu/dma: Clarify swiotlb options apply only to dma-direct Message-ID: <20240504101651.7de5106f@meshulam.tesarici.cz> In-Reply-To: <20240503183527.1548119-1-tjmercier@google.com> References: <20240503183527.1548119-1-tjmercier@google.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-suse-linux-gnu) 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-Transfer-Encoding: 7bit On Fri, 3 May 2024 18:35:26 +0000 "T.J. Mercier" wrote: > IOMMU implementations now sometimes bounce memory through SWIOTLB to > achieve cacheline alignment [1], or prevent DMA attacks by untrusted > devices [2]. These uses of SWIOTLB differ conceptually from historical > use which was a solution to the problem of device addressing > limitations that prevent DMA to some portion of system memory > (typically beyond 4 GiB). IOMMUs also solve the problem of device > addressing limitations and therefore eliminate the need for SWIOTLB for > that purpose. However as mentioned, IOMMUs can use SWIOTLB for other > purposes. > > The swiotlb kernel command line parameter does not impact IOMMU related > use of SWIOTLB, and that is intentional. IOMMUs cannot be forced to use > SWIOTLB for all buffers. Update the documentation for the swiotlb > parameter to clarify that SWIOTLB use can only be forced in scenarios > where an IOMMU is not involved. > > [1] https://lore.kernel.org/all/20230612153201.554742-16-catalin.marinas@arm.com > [2] https://lore.kernel.org/all/20190906061452.30791-1-baolu.lu@linux.intel.com/ > Signed-off-by: T.J. Mercier > --- > Documentation/admin-guide/kernel-parameters.txt | 1 + > Documentation/arch/x86/x86_64/boot-options.rst | 2 +- > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 213d0719e2b7..84c582ac246c 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -6486,6 +6486,7 @@ > to a power of 2. > force -- force using of bounce buffers even if they > wouldn't be automatically used by the kernel > + where a hardware IOMMU is not involved > noforce -- Never use bounce buffers (for debugging) > > switches= [HW,M68k,EARLY] Yes, this part is correct. SWIOTLB cannot be forced if there is an IOMMU. > diff --git a/Documentation/arch/x86/x86_64/boot-options.rst b/Documentation/arch/x86/x86_64/boot-options.rst > index 137432d34109..066b4bc81583 100644 > --- a/Documentation/arch/x86/x86_64/boot-options.rst > +++ b/Documentation/arch/x86/x86_64/boot-options.rst > @@ -285,7 +285,7 @@ iommu options only relevant to the AMD GART hardware IOMMU: > Always panic when IOMMU overflows. > > iommu options only relevant to the software bounce buffering (SWIOTLB) IOMMU > -implementation: > +implementation where a hardware IOMMU is not involved: > > swiotlb=[,force,noforce] > But this part needs some improvement. The "swiotlb" option is not entirely ignored if there is a hardware IOMMU. For example, the size of the SWIOTLB can be adjusted using "swiotlb=", and since SWIOTLB can be used by IOMMUs for other purposes (as you correctly note in the commit message), this setting is relevant even where a hardware IOMMU is involved. Petr T