From: Pranjal Shrivastava <praan@google.com>
To: dmatlack@google.com
Cc: aleksander.lobakin@intel.com, andriy.shevchenko@linux.intel.com,
baolu.lu@linux.intel.com, bartosz.pawlowski@intel.com,
bhelgaas@google.com, dwmw2@infradead.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
rananta@google.com, Pranjal Shrivastava <praan@google.com>
Subject: Re: [PATCH v3] PCI: Ensure ATS disabled via quirk before notifying IOMMU drivers
Date: Fri, 29 May 2026 20:11:05 +0000 [thread overview]
Message-ID: <20260529201105.1239477-1-praan@google.com> (raw)
In-Reply-To: <20260403222750.1215002-1-dmatlack@google.com>
On Fri, Apr 03, 2026 at 10:27:50PM +0000, David Matlack wrote:
> Ensure that PCI devices always have ATS disable via quirk before IOMMU
> drivers are notified about the device. Fix this by converting the
> existing quirks from final to header fixups and changing the quirk logic
> to set a new no_ats bit in struct pci_dev that prevents pci_dev.ats_cap
> from ever getting set.
>
> Use header fixups instead of early fixups since not enough of struct
> pci_dev is set up in during early fixups: quirk_amd_harvest_no_ats()
> needs subsystem_device and subsystem_vendor to be set.
>
> This change ensures that pci_ats_supported() always takes quirks into
> account during iommu_ops.probe_device(), when IOMMU drivers are notified
> about devices, and that pci_ats_supported() returns the same value when
> the device is released in iommu_ops.release_device().
>
> Notably, the Intel IOMMU driver uses pci_ats_supported() in
> probe/release to determine whether to add/remove a device from a data
> structure, which easily leads to a use-after-free without this fix.
>
> This change also makes disabling ATS via quirk behave the same way as
> the pci=noats command line option, in that pci_ats_init() bails
> immediately and never initializes pci_dev.ats_cap.
>
> Note: In practice this fix only matters for PCI devices created after
> IOMMU bus notifiers are set up (e.g. hot-plugged devices and VFs).
>
> Fixes: a18615b1cfc0 ("PCI: Disable ATS for specific Intel IPU E2000 devices")
> Closes: https://lore.kernel.org/linux-iommu/aYUQ_HkDJU9kjsUl@google.com/
> Signed-off-by: David Matlack <dmatlack@google.com>
> ---
> v3:
> - Clarify in commit message that only devices added after boot are
> affected (Baolu)
> - Use header fixups instead of early to avoid breaking
> quirk_amd_harvest_no_ats() (Sashiko)
> - Use u8 instead of unsigned int for no_ats to avoid affecting the
> offsets of existing fields in struct pci_dev (me)
>
> v2: https://lore.kernel.org/linux-pci/20260327211649.3816010-1-dmatlack@google.com/
>
> v1: https://lore.kernel.org/linux-pci/20260223184017.688212-1-dmatlack@google.com/
>
> Cc: Raghavendra Rao Ananta <rananta@google.com>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: Lu Baolu <baolu.lu@linux.intel.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> drivers/pci/ats.c | 2 +-
> drivers/pci/quirks.c | 50 ++++++++++++++++++++++----------------------
> include/linux/pci.h | 1 +
> 3 files changed, 27 insertions(+), 26 deletions(-)
>
Applying ATS quirks during the HEADER phase seems correct for the IOMMU
drivers to get the right view. I observed side effects due to the quirks
being applied in the FINAL phase [1] which seem to go away with this fix.
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Tested-by: Pranjal Shrivastava <praan@google.com>
Thanks,
Praan
[1] https://lore.kernel.org/all/20260504163842.2692314-1-praan@google.com/
next prev parent reply other threads:[~2026-05-29 20:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 22:27 David Matlack
2026-05-29 20:11 ` Pranjal Shrivastava [this message]
2026-06-12 21:55 ` David Matlack
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=20260529201105.1239477-1-praan@google.com \
--to=praan@google.com \
--cc=aleksander.lobakin@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=bartosz.pawlowski@intel.com \
--cc=bhelgaas@google.com \
--cc=dmatlack@google.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rananta@google.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
all inboxes | Powered by JetHome®