* [PATCH] iommu/vt-d: fix missing lock in intel_pasid_replace_*() functions
@ 2026-01-30 19:06 Ziyi Guo
2026-02-02 2:31 ` Baolu Lu
0 siblings, 1 reply; 2+ messages in thread
From: Ziyi Guo @ 2026-01-30 19:06 UTC (permalink / raw)
To: David Woodhouse, Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, iommu, linux-kernel, Ziyi Guo
intel_pasid_replace_first_level(), intel_pasid_replace_second_level(),
intel_pasid_replace_pass_through(), and intel_pasid_replace_nested()
call their respective pasid_pte_config_*() helpers before acquiring
iommu->lock. However, each config function has
lockdep_assert_held(&iommu->lock).
The corresponding intel_pasid_setup_*() functions correctly acquire
iommu->lock before calling the config helpers.
Let spin_lock(&iommu->lock) before the pasid_pte_config_*() calls to
fix the lockdep assertions and ensure consistent access to IOMMU state.
Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
---
drivers/iommu/intel/pasid.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
index 3e2255057079..dd4c8287d354 100644
--- a/drivers/iommu/intel/pasid.c
+++ b/drivers/iommu/intel/pasid.c
@@ -431,9 +431,8 @@ int intel_pasid_replace_first_level(struct intel_iommu *iommu,
return -EINVAL;
}
- pasid_pte_config_first_level(iommu, &new_pte, fsptptr, did, flags);
-
spin_lock(&iommu->lock);
+ pasid_pte_config_first_level(iommu, &new_pte, fsptptr, did, flags);
pte = intel_pasid_get_entry(dev, pasid);
if (!pte) {
spin_unlock(&iommu->lock);
@@ -542,9 +541,8 @@ int intel_pasid_replace_second_level(struct intel_iommu *iommu,
did = domain_id_iommu(domain, iommu);
- pasid_pte_config_second_level(iommu, &new_pte, domain, did);
-
spin_lock(&iommu->lock);
+ pasid_pte_config_second_level(iommu, &new_pte, domain, did);
pte = intel_pasid_get_entry(dev, pasid);
if (!pte) {
spin_unlock(&iommu->lock);
@@ -686,9 +684,8 @@ int intel_pasid_replace_pass_through(struct intel_iommu *iommu,
struct pasid_entry *pte, new_pte;
u16 did = FLPT_DEFAULT_DID;
- pasid_pte_config_pass_through(iommu, &new_pte, did);
-
spin_lock(&iommu->lock);
+ pasid_pte_config_pass_through(iommu, &new_pte, did);
pte = intel_pasid_get_entry(dev, pasid);
if (!pte) {
spin_unlock(&iommu->lock);
@@ -882,9 +879,8 @@ int intel_pasid_replace_nested(struct intel_iommu *iommu,
return -EINVAL;
}
- pasid_pte_config_nestd(iommu, &new_pte, s1_cfg, s2_domain, did);
-
spin_lock(&iommu->lock);
+ pasid_pte_config_nestd(iommu, &new_pte, s1_cfg, s2_domain, did);
pte = intel_pasid_get_entry(dev, pasid);
if (!pte) {
spin_unlock(&iommu->lock);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] iommu/vt-d: fix missing lock in intel_pasid_replace_*() functions
2026-01-30 19:06 [PATCH] iommu/vt-d: fix missing lock in intel_pasid_replace_*() functions Ziyi Guo
@ 2026-02-02 2:31 ` Baolu Lu
0 siblings, 0 replies; 2+ messages in thread
From: Baolu Lu @ 2026-02-02 2:31 UTC (permalink / raw)
To: Ziyi Guo, David Woodhouse
Cc: Joerg Roedel, Will Deacon, Robin Murphy, iommu, linux-kernel
On 1/31/26 03:06, Ziyi Guo wrote:
> intel_pasid_replace_first_level(), intel_pasid_replace_second_level(),
> intel_pasid_replace_pass_through(), and intel_pasid_replace_nested()
> call their respective pasid_pte_config_*() helpers before acquiring
> iommu->lock. However, each config function has
> lockdep_assert_held(&iommu->lock).
>
> The corresponding intel_pasid_setup_*() functions correctly acquire
> iommu->lock before calling the config helpers.
>
> Let spin_lock(&iommu->lock) before the pasid_pte_config_*() calls to
> fix the lockdep assertions and ensure consistent access to IOMMU state.
>
> Signed-off-by: Ziyi Guo<n7l8m4@u.northwestern.edu>
> ---
> drivers/iommu/intel/pasid.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
Thanks for the patch. It looks like this was addressed by commit
c3b1edea3791 ("iommu/vt-d: Fix race condition during PASID entry
replacement"), currently in iommu/next. Let me know if you think there
is still something missing.
Thanks,
baolu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-02 2:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-30 19:06 [PATCH] iommu/vt-d: fix missing lock in intel_pasid_replace_*() functions Ziyi Guo
2026-02-02 2:31 ` Baolu Lu
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®