Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp120454lqh; Mon, 6 May 2024 13:17:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUA66L5wkMfjYKKNthQPD18Zg3p22u5OGYnF8ZAd+Jbqt2to3tgrSN7g8qO7NELoK7swCTLKuGEPyw92+ZHqtawTfesEbXOVHiS12JOuw== X-Google-Smtp-Source: AGHT+IGykGENWRFbN1umb7B1Y2u8G9EBq32eBccxsaJDpJ4f2bsYAVxRAlCLsH924wyLh8IvwXkn X-Received: by 2002:ac2:5a11:0:b0:51e:bc4f:ed2a with SMTP id q17-20020ac25a11000000b0051ebc4fed2amr6580643lfn.37.1715026630243; Mon, 06 May 2024 13:17:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715026630; cv=pass; d=google.com; s=arc-20160816; b=bg/IxYiGYZkc5uLfEjRwcslD5/ez6vcNqb+dBotx5++ziCloq/SKZj5InKP8MasBkv zO2In2CuZIpaBU5EDjxf/J6+77U8AEncpgMwT6lAnMsQpVJSzY4HADXDcyJvsYPPAev0 mqeMBM6RF7xTiwA7VLwvC8MHuKjLQZkG3+gRi5HKSvDihQaubsK3t2ejqHhGw6WLZ8NK oPpr4Bbx440PQHNXz8r30uCxtYM719iWeqhtY6XGhoMkNvdSiM3uzWr6aiEdMCAOeXsU UWHH+taGmK5iFSzHSZT2HfsN42XlhHhK+hvlaKJy7J3vsFkKND2e1vsSloKGxNJwI6nb MaIA== 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=5fr3FvzBZJmUemTYZLBAlTUKyWusYtW7x1D9jX3o6JY=; fh=eRfgSJ3G0VZWRBtugsopbHc3WWXLCZIVKZrv3il5mkg=; b=kjiVbTNHwLBuZG2z0AGrBAMyGQ+XoJOmXNTVhDLE2iF6x04xCM52zLcJHoPqXXw1S6 jxIHFDAniUF2opUuuIRcOTsw1fyX4VTKrkVq+Oxg08hDjdLbvLymheMWBo7MhfNS2sf6 nWnLEn70/KrRIj0xau8DTICoqmAccuhPpOccydriq9cozm8LIkFd7Rx984QZumhsdVo5 aAYAXOZottzS8QhvaSTldv3ZHT2dnlyoIFW8cRSshglPZKafq4XlUsvTvWGJFazyzbXO R7ytJotVmRLvIRgO1H/q4yeVcqs4sS7OQf9yHIUqxSmqDUxezeL+9kUOx//BuehGTDXr sI/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xHEPVmdP; 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-170383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170383-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p23-20020a1709061b5700b00a59dd9790f3si751456ejg.29.2024.05.06.13.17.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 13:17:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xHEPVmdP; 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-170383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170383-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 870491F241FD for ; Mon, 6 May 2024 20:17:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28A2315B0FE; Mon, 6 May 2024 20:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="xHEPVmdP" Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (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 A02E615AAB1 for ; Mon, 6 May 2024 20:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715026620; cv=none; b=eNGNSOXbnk6gTOiCUjQL78GoGDw4QRXIh112hnY28uu8IS2ohBNVz+jn1j5331oSra3F8kDaXmcH15vEChWJv5CoTMGomaOOw1L8Rbl0TJCr0fiXW/zTHUj329RanknX3X0yVttJTaFSo7EYnWjNOXcu4mkuBfkKT3vgjy6bcaA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715026620; c=relaxed/simple; bh=O4m3D6QJkpCyIotiPkNx41gI4the4mNBM6wP0C8Edm8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=CEWIKIoZdJmuf6FvS2SyW0OB314678loPItqXcKjo5JAKirNzeg2e1yCFchiYsBjnC3HUnj1RH1AL4UTHbIbgzOkMoM+/Nsi2wLOdwHm/ObfTxCAFBSkjeEAI/HV7KzL7p+EGQMvsbbFVrK2FIvE21oJDmAlQFg0zN9sTOnC/Y4= 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=xHEPVmdP; arc=none smtp.client-ip=209.85.219.169 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-f169.google.com with SMTP id 3f1490d57ef6-de45dba157cso1886171276.3 for ; Mon, 06 May 2024 13:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715026618; x=1715631418; 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=5fr3FvzBZJmUemTYZLBAlTUKyWusYtW7x1D9jX3o6JY=; b=xHEPVmdPMeKAN+gJoQ0mTk50Lp43ayUaIeubdfAEUB1IHwXW+iy1lKM4GbT02Ub27K qB2p81ViCnuMHh5wOa9Zl0mDfWmYmjr3dauxd605yt/WI5dVUDN9wd0E5WQyqF7k2IaS VVkmUfkDg0ADCfhi/UjkPsYZIqZO0GQh85nmJwWjQY3UR3tx53ViMVkvHnaYYXAVtgDm ZGz5KVY/UtSgATSvQLH8BMXDV9trviaDvffUPnQ1xC9xVNsmQ0ZfX6zkQ/P+l1NGugYq tTcaPAqW4qg4pncb3ToynARu+L6IzHeVrVkoUPfZrE74onZ9DVmn8ikrmbH7A+qoTESm NJhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715026618; x=1715631418; 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=5fr3FvzBZJmUemTYZLBAlTUKyWusYtW7x1D9jX3o6JY=; b=TNdojE7quIhiX2GRtGnnQeFBhziFtPdOLRkNodNaHECtflgmskHf21CJ3k5AjV/KQf jZkT9AM7HYFWzBKCHjLMhjQfgAgMIUuVM1hWJQH9P8BvssGt9vog13xS3J8WYJkn/eRb 0jvJbnMD2AQkg6hVYkEtxA+KhZ7yDmFGvuyTDs7qB1aNNFjTO5qG+HEEpWlS6WVHRlYR c1JdIIe4o8eh/pVZ3iPo+kZa+1LHFZ7e8I6LDZSqYIzICJKTC882wPg/7Ix29mykLWaN B7fWnBdpSiI10B0kJ47Ckombf16WsRy2d8codiXljzjzGBFlcdH+K2YCSyDOor4iiamx Nheg== X-Forwarded-Encrypted: i=1; AJvYcCXhlixmkhmn/RRc3YdHkpvcecZlyiAcXY24Z+HKv9fHLc95KcBcLdH7LUIrS/fjBD4LEJQsU9N2A6nPJiMHog2Qf0sV9oUsTkaW6wi/ X-Gm-Message-State: AOJu0YxUtQyR8poMGzaRga3Y+VhP1f+S7J9MgK2bmIUr8rTAWItIB/5Y RWw/aN7TDCf90lPOd6HGzEefXfQD8dRquz8x+5Ak92CFAt9NIueY8HPXnPW3SDC4qS13UmLgUh0 igQCs1rT+CezTh4x6KaZtPJjuPkTyMZX/GZgV X-Received: by 2002:a5b:a0d:0:b0:de5:9f30:e40c with SMTP id k13-20020a5b0a0d000000b00de59f30e40cmr10782095ybq.4.1715026617408; Mon, 06 May 2024 13:16:57 -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: From: "T.J. Mercier" Date: Mon, 6 May 2024 13:16:45 -0700 Message-ID: Subject: Re: [PATCH] swiotlb: iommu/dma: Clarify swiotlb options apply only to dma-direct To: Michael Kelley Cc: =?UTF-8?B?UGV0ciBUZXNhxZnDrWs=?= , 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" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 6, 2024 at 12:58=E2=80=AFPM Michael Kelley wrote: > > From: T.J. Mercier Sent: Monday, May 6, 2024 10:23= AM > > > > 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 t= o > > > > achieve cacheline alignment [1], or prevent DMA attacks by untruste= d > > > > devices [2]. These uses of SWIOTLB differ conceptually from histori= cal > > > > 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 othe= r > > > > purposes. > > > > > > > > The swiotlb kernel command line parameter does not impact IOMMU rel= ated > > > > 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 scenari= os > > > > where an IOMMU is not involved. > > > > > > > > [1] https://lore.kernel.org/all/20230612153201.554742-16-catalin.ma= rinas@arm.com/ > > > > [2] https://lore.kernel.org/all/20190906061452.30791-1-baolu.lu@lin= ux.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/Docu= mentation/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 i= f they > > > > wouldn't be automatically used by th= e kernel > > > > + where a hardware IOMMU is not involv= ed > > > > noforce -- Never use bounce buffers (for debu= gging) > > > > > > > > switches=3D [HW,M68k,EARLY] > > > > > > Yes, this part is correct. SWIOTLB cannot be forced if there is an IO= MMU. > > > > > > > diff --git a/Documentation/arch/x86/x86_64/boot-options.rst b/Docum= entation/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 har= dware IOMMU: > > > > Always panic when IOMMU overflows. > > > > > > > > iommu options only relevant to the software bounce buffering (SWIO= TLB) 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 SWIO= TLB > > > can be used by IOMMUs for other purposes (as you correctly note in th= e > > > 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 IOMM= U > > 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 bufferin= g in > > + some circumstances, but they cannot be forced to always use th= em, so > > + this option only has an effect when no hardware IOMMU is invol= ved. > > noforce > > Note also that the documentation for swiotlb=3D in boot-options.rst is so= mewhat > out-of-date. It doesn't have the optional second integer parameter to sp= ecify > the number of "areas" that have their own lock. Perhaps that could be fi= xed > at the same time? > > Michael Thanks, I could add this as a second patch. I also noticed that several of the iommu options (soft, allowed, nofullflush, panic) are not listed in the set of possible options at the top of the IOMMU section. Rebooting is the only other section that does that, so I'm wondering if we're better off getting rid of it to be like other sections.