public inbox for iommu@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Jon Hunter <jonathanh@nvidia.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
	joro@8bytes.org, will@kernel.org, jgg@nvidia.com,
	iommu@lists.linux.dev, linux-tegra@vger.kernel.org
Subject: Re: [PATCH] iommu: Ensure .iotlb_sync is called correctly
Date: Wed, 8 Apr 2026 20:55:18 +0100	[thread overview]
Message-ID: <adayppUjhjNZNSeY@shell.armlinux.org.uk> (raw)
In-Reply-To: <bdad8adc-5c20-4fb5-90b0-b7ca4199a7a8@nvidia.com>

On Wed, Apr 08, 2026 at 06:28:55PM +0100, Jon Hunter wrote:
> 
> On 08/04/2026 15:40, Robin Murphy wrote:
> > Many drivers have no reason to use the iotlb_gather mechanism, but do
> > still depend on .iotlb_sync being called to properly complete an unmap.
> > Since the core code is now relying on the gather to detect when there
> > is legitimately something to sync, it should also take care of encoding
> > a successful unmap when the driver does not touch the gather itself.
> > 
> > Fixes: 90c5def10bea ("iommu: Do not call drivers for empty gathers")
> > Reported-by: Jon Hunter <jonathanh@nvidia.com>
> > Closes: https://lore.kernel.org/r/8800a38b-8515-4bbe-af15-0dae81274bf7@nvidia.com
> > Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> > ---
> >   drivers/iommu/iommu.c | 6 ++++++
> >   1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> > index 50718ab810a4..ee83850c7060 100644
> > --- a/drivers/iommu/iommu.c
> > +++ b/drivers/iommu/iommu.c
> > @@ -2717,6 +2717,12 @@ static size_t __iommu_unmap(struct iommu_domain *domain,
> >   		pr_debug("unmapped: iova 0x%lx size 0x%zx\n",
> >   			 iova, unmapped_page);
> > +		/*
> > +		 * If the driver itself isn't using the gather, make sure
> > +		 * it looks non-empty so iotlb_sync will still be called.
> > +		 */
> > +		if (iotlb_gather->start >= iotlb_gather->end)
> > +			iommu_iotlb_gather_add_range(iotlb_gather, iova, size);
> >   		iova += unmapped_page;
> >   		unmapped += unmapped_page;
> 
> 
> Tested-by: Jon Hunter <jonathanh@nvidia.com>

Tested-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

I think the commit message needs to spell out that the blamed commit
causes random memory corruption which leads to data corruption and
kernel oopses.

Thanks!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2026-04-08 19:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-08 14:40 [PATCH] iommu: Ensure .iotlb_sync is called correctly Robin Murphy
2026-04-08 16:28 ` Jason Gunthorpe
2026-04-08 17:28 ` Jon Hunter
2026-04-08 19:55   ` Russell King (Oracle) [this message]
2026-04-09 13:01 ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adayppUjhjNZNSeY@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox