public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [PATCH topic/core-for-CI] iommu: Do not call drivers for empty gathers
Date: Thu, 09 Apr 2026 10:43:32 +0200	[thread overview]
Message-ID: <8ad654540c17a0ad8314545fe6c0ed9907671ac0.camel@linux.intel.com> (raw)
In-Reply-To: <20260402092506.2612595-2-janusz.krzysztofik@linux.intel.com>

On Thu, 2026-04-02 at 11:23 +0200, Janusz Krzysztofik wrote:
> From: Jason Gunthorpe <jgg@nvidia.com>
> 
> An empty gather is coded with start=U64_MAX, end=0 and several drivers go
> on to convert that to a size with:
> 
>  end - start + 1
> 
> Which gives 2 for an empty gather. This then causes Weird Stuff to
> happen (for example an UBSAN splat in VT-d) that is hopefully harmless,
> but maybe not.
> 
> Prevent drivers from being called right in iommu_iotlb_sync().
> 
> Auditing shows that AMD, Intel, Mediatek and RSIC-V drivers all do things
> on these empty gathers.
> 
> Further, there are several callers that can trigger empty gathers,
> especially in unusual conditions. For example iommu_map_nosync() will call
> a 0 size unmap on some error paths. Also in VFIO, iommupt and other
> places.
> 
> Cc: stable@vger.kernel.org
> Reported-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> Closes: https://lore.kernel.org/r/11145826.aFP6jjVeTY@jkrzyszt-mobl2.ger.corp.intel.com
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
> Reviewed-by: Samiullah Khawaja <skhawaja@google.com>
> Reviewed-by: Robin Murphy <robin.murphy@arm.com>
> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> (cherry picked from commit 90c5def10bea574b101b7a520c015ca81742183f)

That commit is already in mainline, no need to pull it into core-for-CI 
any longer.

Thanks,
Janusz


> Link: https://lore.kernel.org/all/1-v1-13a02eb0e031+a5-iommu_gather_jgg@nvidia.com
> Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/work_items/15478
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> ---
>  include/linux/iommu.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index 54b8b48c762e8..555597b54083c 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -980,7 +980,8 @@ static inline void iommu_flush_iotlb_all(struct iommu_domain *domain)
>  static inline void iommu_iotlb_sync(struct iommu_domain *domain,
>  				  struct iommu_iotlb_gather *iotlb_gather)
>  {
> -	if (domain->ops->iotlb_sync)
> +	if (domain->ops->iotlb_sync &&
> +	    likely(iotlb_gather->start < iotlb_gather->end))
>  		domain->ops->iotlb_sync(domain, iotlb_gather);
>  
>  	iommu_iotlb_gather_init(iotlb_gather);

      parent reply	other threads:[~2026-04-09  8:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02  9:23 [PATCH topic/core-for-CI] iommu: Do not call drivers for empty gathers Janusz Krzysztofik
2026-04-02 10:33 ` ✓ i915.CI.BAT: success for " Patchwork
2026-04-03  6:19 ` ✗ i915.CI.Full: failure " Patchwork
2026-04-08 19:30 ` ✓ i915.CI.BAT: success for iommu: Do not call drivers for empty gathers (rev2) Patchwork
2026-04-08 22:48 ` ✓ i915.CI.Full: " Patchwork
2026-04-09  8:43 ` Janusz Krzysztofik [this message]

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=8ad654540c17a0ad8314545fe6c0ed9907671ac0.camel@linux.intel.com \
    --to=janusz.krzysztofik@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=rodrigo.vivi@intel.com \
    /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