Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp35868lqh; Mon, 6 May 2024 10:23:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUhj5wMMwvh0Z9BAz7WfbB4y0OUjBseGtR+rbYVflPUYuYBsY7xD+1rNhoLM/oQsh/qLIsO0YyoyZjM+wFKuarAhrdzNaAPX3pJTvKGlg== X-Google-Smtp-Source: AGHT+IG+jQtnfjfPIBk6EGXw4+RTSzTbJxJTR/I6H2jk/xpTwOHpWnJstajiJVz1u8zNRbQl7rTy X-Received: by 2002:a17:90a:a516:b0:2ae:e1e0:3d8f with SMTP id a22-20020a17090aa51600b002aee1e03d8fmr8687294pjq.2.1715016194569; Mon, 06 May 2024 10:23:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715016194; cv=pass; d=google.com; s=arc-20160816; b=kOkYpWBX4eK6m+rhnbEtQFJFPrfYsaMYAH/jfd5LCp0hgbhc6F6tG0IYHhksICUiaX eAd3U5ni+Jem+y0II/Zp2K1H0GxM3SbZm4BwtCGXWCglpfFX007U20522Dn72CVxZBol XPc4Vx6B4lXfRWBgVX8P1Bs89fz+oPUnESK8EIcqMXN7QBivnh1eHBNyQAZFOS6lK2tJ +mWfzj47sYswpDNNiiHAUSL0X/QK28XARzcrkLVIqX3Se+M3/Wl1tT8TYWztYI4NXAUT IQWnqWQDTj0LdL0pd489uqycQnStrwLDVj2onNHnbiIwKu661HGuTmAcbAz1QL5Q6StR Nnow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=PCrwSzubKtvsGNfMW8E9OfepfV+lPFMQFEMiDBoSQgk=; fh=FKl+7Qs85E6oMB8HOUutgUUVPkD0p2mwmwEq5fVORF8=; b=akhiQVn8TmbyH/NcsrA4j/hbe3AujQy6NyVCndF8kbh2V1ieCykrPb530n8suhJiSA 6tEtydZzRlBcGe0+kYE7EilYEDzW3QJRtirnmYTTYj5CPLE16uy0K++xCawRhIqBV91L E25fdn8kQo0OTcJ0HEuEBzHI6kL9q+anKjBpo7WzSF1w90+2jMiZs0r2OKLf3y6mZ/D2 63nSMr3GudFafZUeXkzy1LECv4HCOOcxIkjeDGU3Nonx+p7jZ2VcHgS+PoaHAiqPvTc7 8RQpduLBX9J1q9K2kTuOM9/5wCrt+0m3P9liHFmmHhF2lJpXY3O/7x2aRC+8KmjFuzMD R2sg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="VNVL/gB+"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-170227-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170227-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id pg4-20020a17090b1e0400b002b20c2de966si9101411pjb.56.2024.05.06.10.23.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 10:23:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170227-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="VNVL/gB+"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-170227-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170227-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id F2FFC28547D for ; Mon, 6 May 2024 17:23:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8CEF157497; Mon, 6 May 2024 17:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VNVL/gB+" Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6776315746B for ; Mon, 6 May 2024 17:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715016184; cv=none; b=ecS/tsfA+ORKtds4cVtvNIcEQfQFs3IHruKwliZpP0iHe5Pb+HjodOcujC5kY3Kb/lUQhC8F7du2209FWFlsYz6XTVOFD2sJt/PzC6zhbFX1Fvnj9U18hQAJZNYWx0RY4I8JmRnKUhSxM/+zj8fJ17Dxe4u3gJD9B7T5EowpZqo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715016184; c=relaxed/simple; bh=WZrKW9lX4tg3tPxy5c0NpUNmhHAib2hOo3+Fq/V8re4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=nM+ClXZoKNKXySF1Lcr1ETxc5P33mkuwhOXflF7SJJwhAwmywtGJRftiKbiyqPUDGrUUv+1SWsybDtG+DgZT9xMwK+P5f5YdEunMItNnyr8fK0j7qe9OO6MIvMTPtTfmzuUMTv2SLrsWN1vQWXGQtmMUN6XNfL39m3KIHZ7tmrM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VNVL/gB+; arc=none smtp.client-ip=209.85.219.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-de604ca3cfcso2153992276.3 for ; Mon, 06 May 2024 10:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715016182; x=1715620982; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PCrwSzubKtvsGNfMW8E9OfepfV+lPFMQFEMiDBoSQgk=; b=VNVL/gB+Mg3B76MU83sheUjwbFvS4E1RgsoxRRe2uYyjNcfotwatf2tP1++SzDAj1Z /AP3O6W364YroxdCGCSumXiNeyK/oo58xm8wIe9mDqDKX8Hkn3m8ZoH+aLZdZ9b/N7es B4zjd//3VsudDXRd7OYirgWwdqHUjAii+mQf7RHE3/ARu20IPAa7OeNrsbYafLj3NjLK 7IKQgCwKC7GsMlGuAWGW0M0caQj18NYeTL10cVaA6/Hv0yih2YDGxjpGDMEVwfa78tcn qba31ACO8v21Az56qrJDco3A0LTrew8Fd2D1HY7/uXL1xHRqMUA1yFuExSRrh7+BW2cp PJUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715016182; x=1715620982; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PCrwSzubKtvsGNfMW8E9OfepfV+lPFMQFEMiDBoSQgk=; b=wU8IUdhNb/J5Ox4gk9m3zH/oN9DfgUktnjkhP1cbGp93xsaeJspQRtckO/w3XAUiZ2 qPYhY0oyeA+PWTx8skyl7OZqFagVeIfIXeBCZQMHiwO03ai8QapkT2f88yUg0oKF1ST4 6x5AMPJLzlTXgGSy7Bv7HByTQcCcLzqTNf11b/0AZvEw7V7//aXBMbpoOsOs5H+0njtV 9FicLnvJwM/gJgnG9N4gQrddepAaEB+j3lvf7N8dBUynQ0KFNDItKWIoUKK7w9g7syjL Ul3uGvzYbKkROt0KnniAp0bE9AQSaHvylh2pEuWMIrYsZhDaP4lch9hbEtb8n3GsXczq pf2w== X-Forwarded-Encrypted: i=1; AJvYcCW1WxlcTtlcq0aHxV2tNM6gOSKQGai7JWTn+17sgMPCdtBArOYzKzHe2RBaxT5AlY1kUQa6d7lEaq/oGIBo/0bUU/AiRqHoU7Jc9961 X-Gm-Message-State: AOJu0YymZDa5h37/gWEXPjJusi+bZOXYe6mSdYRpWgVbwkWo49yCTcMN FRSHKzziCq1EcEYGFHDefE9WFDkt9yGMBb4zuQurVtNCHEDVu9bq2vcxLvA4q0ntHIctNNGZYcM SdukqUme5HKmvL8vEqxKXD61ats1SPsQrtQ0T X-Received: by 2002:a05:6902:2747:b0:dc7:465d:c06d with SMTP id ea7-20020a056902274700b00dc7465dc06dmr12341901ybb.28.1715016182087; Mon, 06 May 2024 10:23:02 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240503183527.1548119-1-tjmercier@google.com> <20240504101651.7de5106f@meshulam.tesarici.cz> In-Reply-To: <20240504101651.7de5106f@meshulam.tesarici.cz> From: "T.J. Mercier" Date: Mon, 6 May 2024 10:22:50 -0700 Message-ID: Subject: Re: [PATCH] swiotlb: iommu/dma: Clarify swiotlb options apply only to dma-direct To: =?UTF-8?B?UGV0ciBUZXNhxZnDrWs=?= 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, May 4, 2024 at 1:16=E2=80=AFAM Petr Tesa=C5=99=C3=ADk wrote: > > 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.marina= s@arm.com > > [2] https://lore.kernel.org/all/20190906061452.30791-1-baolu.lu@linux.i= ntel.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/Document= ation/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 th= ey > > wouldn't be automatically used by the ke= rnel > > + where a hardware IOMMU is not involved > > noforce -- Never use bounce buffers (for debuggin= g) > > > > switches=3D [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/Documenta= tion/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 hardwar= e 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=3D[,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=3D", 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 Thanks. I think I should also update the commit message: "The swiotlb=3Dforce kernel command line parameter does not impact IOMMU related use of SWIOTLB" and title: "Clarify swiotlb=3Dforce option applies only to dma-direct" As for fixing boot-options.txt, I think it makes the most sense to expand on just the force option rather than the section summary like above: force Force all IO through the software TLB. + Hardware IOMMU implementations can use SWIOTLB bounce buffering in + some circumstances, but they cannot be forced to always use them, = so + this option only has an effect when no hardware IOMMU is involved. noforce