From: Baolu Lu <baolu.lu@linux.intel.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: baolu.lu@linux.intel.com, iommu@lists.linux.dev,
Kevin Tian <kevin.tian@intel.com>, Joerg Roedel <joro@8bytes.org>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Danny Gonzalez <digonzal@google.com>,
David Decotigny <decot@google.com>,
Sheena Mohan <sheenamo@google.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Pranjal Shrivastava <praan@google.com>,
Nicolin Chen <nicolinc@nvidia.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] iommu/vt-d: Fix WARN_ON in iommu probe path
Date: Wed, 18 Nov 2026 15:49:30 +0800 [thread overview]
Message-ID: <19551f22-84cd-4256-a24b-f26c61502368@linux.intel.com> (raw)
In-Reply-To: <20261117180122.GA427856@bhelgaas>
On 11/18/2026 2:01 AM, Bjorn Helgaas wrote:
> [+cc Danny and others because this is related to ongoing work at
> https://lore.kernel.org/all/20261020181053.2646782-1-digonzal@google.com/]
>
> On Sun, Apr 07, 2024 at 09:14:29AM +0800, Lu Baolu wrote:
>> Commit 1a75cc710b95 ("iommu/vt-d: Use rbtree to track iommu probed
>> devices") adds all devices probed by the iommu driver in a rbtree
>> indexed by the source ID of each device. It assumes that each device
>> has a unique source ID. This assumption is incorrect and the VT-d
>> spec doesn't state this requirement either.
>> ...
>
>> +++ b/drivers/iommu/intel/iommu.c
>> @@ -4299,9 +4299,11 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
>> }
>>
>> dev_iommu_priv_set(dev, info);
>> - ret = device_rbtree_insert(iommu, info);
>> - if (ret)
>> - goto free;
>> + if (pdev && pci_ats_supported(pdev)) {
>> + ret = device_rbtree_insert(iommu, info);
>> + if (ret)
>> + goto free;
>> + }
>
> This change is upstream as 89436f4f5412 ("iommu/vt-d: Fix WARN_ON in
> iommu probe path"), but I think there's a problem here. Previously
> the rbtree insertion was unconditional, so the unconditional remove in
> the error path was correct.
>
> After 89436f4f5412, the rbtree insertion is conditional. If
> intel_pasid_alloc_table() fails, we try to remove it even though it
> may never have been inserted:
info->node is initialized with RB_CLEAR_NODE() before the insertion, and
the remove helper checks RB_EMPTY_NODE() before erasing. If insertion
was skipped, removal is a no-op, so this error path does not need
another state check.
>
>> if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev)) {
>> ret = intel_pasid_alloc_table(dev);
> if (ret) {
> dev_err(dev, "PASID table allocation failed\n");
> goto clear_rbtree;
> }
> ...
> clear_rbtree:
> device_rbtree_remove(info);
> free:
> kfree(info);
>
>> @@ -4336,7 +4338,8 @@ static void intel_iommu_release_device(struct device *dev)
>> struct intel_iommu *iommu = info->iommu;
>>
>> mutex_lock(&iommu->iopf_lock);
>> - device_rbtree_remove(info);
>> + if (dev_is_pci(dev) && pci_ats_supported(to_pci_dev(dev)))
>> + device_rbtree_remove(info);
>
> This is also somewhat problematic because it relies on the assumption
> that pci_ats_supported(X) always returns the same value it returned in
> intel_iommu_probe_device(). That may be true today, but I don't think
> you should rely on it.
Agreed. The release path should not re-evaluate pci_ats_supported().
> I think both issues could be solved if intel/iommu.c kept track of the
> rbtree insertion itself, e.g., with a bit in struct
> device_domain_info.
Sure. I will address this with a follow-up patch.
>
>> mutex_unlock(&iommu->iopf_lock);
>>
>> if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev) &&
>> --
>> 2.34.1
>>
Thanks,
baolu
prev parent reply other threads:[~2026-11-18 7:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-07 1:14 Lu Baolu
2024-04-08 3:52 ` Tian, Kevin
2024-04-08 7:15 ` Baolu Lu
2024-04-08 9:12 ` Tian, Kevin
2024-04-11 12:29 ` Ethan Zhao
2024-04-11 2:47 ` Baolu Lu
2024-04-11 6:53 ` Tian, Kevin
2026-11-17 18:01 ` Bjorn Helgaas
2026-11-18 7:49 ` Baolu Lu [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=19551f22-84cd-4256-a24b-f26c61502368@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=decot@google.com \
--cc=digonzal@google.com \
--cc=helgaas@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=praan@google.com \
--cc=robin.murphy@arm.com \
--cc=sheenamo@google.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
all inboxes | Powered by JetHome®