[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20260130190655.1622261-1-n7l8m4@u.northwestern.edu>
Date: Fri, 30 Jan 2026 19:06:55 +0000
From: Ziyi Guo <n7l8m4@...orthwestern.edu>
To: David Woodhouse <dwmw2@...radead.org>,
Lu Baolu <baolu.lu@...ux.intel.com>
Cc: Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>,
iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org,
Ziyi Guo <n7l8m4@...orthwestern.edu>
Subject: [PATCH] iommu/vt-d: fix missing lock in intel_pasid_replace_*() functions
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@...orthwestern.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
Powered by blists - more mailing lists