Skip to content

Commit 9ad9f45

Browse files
yiliu1765willdeacon
authored andcommitted
iommu/vt-d: Move intel_iommu info from struct intel_svm to struct intel_svm_dev
'struct intel_svm' is shared by all devices bound to a give process, but records only a single pointer to a 'struct intel_iommu'. Consequently, cache invalidations may only be applied to a single DMAR unit, and are erroneously skipped for the other devices. In preparation for fixing this, rework the structures so that the iommu pointer resides in 'struct intel_svm_dev', allowing 'struct intel_svm' to track them in its device list. Fixes: 1c4f88b ("iommu/vt-d: Shared virtual address in scalable mode") Cc: Lu Baolu <baolu.lu@linux.intel.com> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Raj Ashok <ashok.raj@intel.com> Cc: David Woodhouse <dwmw2@infradead.org> Reported-by: Guo Kaijie <Kaijie.Guo@intel.com> Reported-by: Xin Zeng <xin.zeng@intel.com> Signed-off-by: Guo Kaijie <Kaijie.Guo@intel.com> Signed-off-by: Xin Zeng <xin.zeng@intel.com> Signed-off-by: Liu Yi L <yi.l.liu@intel.com> Tested-by: Guo Kaijie <Kaijie.Guo@intel.com> Cc: stable@vger.kernel.org # v5.0+ Acked-by: Lu Baolu <baolu.lu@linux.intel.com> Link: https://lore.kernel.org/r/1609949037-25291-2-git-send-email-yi.l.liu@intel.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent aded8c7 commit 9ad9f45

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

drivers/iommu/intel/svm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static void intel_flush_svm_range_dev (struct intel_svm *svm, struct intel_svm_d
142142
}
143143
desc.qw2 = 0;
144144
desc.qw3 = 0;
145-
qi_submit_sync(svm->iommu, &desc, 1, 0);
145+
qi_submit_sync(sdev->iommu, &desc, 1, 0);
146146

147147
if (sdev->dev_iotlb) {
148148
desc.qw0 = QI_DEV_EIOTLB_PASID(svm->pasid) |
@@ -166,7 +166,7 @@ static void intel_flush_svm_range_dev (struct intel_svm *svm, struct intel_svm_d
166166
}
167167
desc.qw2 = 0;
168168
desc.qw3 = 0;
169-
qi_submit_sync(svm->iommu, &desc, 1, 0);
169+
qi_submit_sync(sdev->iommu, &desc, 1, 0);
170170
}
171171
}
172172

@@ -211,7 +211,7 @@ static void intel_mm_release(struct mmu_notifier *mn, struct mm_struct *mm)
211211
*/
212212
rcu_read_lock();
213213
list_for_each_entry_rcu(sdev, &svm->devs, list)
214-
intel_pasid_tear_down_entry(svm->iommu, sdev->dev,
214+
intel_pasid_tear_down_entry(sdev->iommu, sdev->dev,
215215
svm->pasid, true);
216216
rcu_read_unlock();
217217

@@ -364,6 +364,7 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev,
364364
}
365365
sdev->dev = dev;
366366
sdev->sid = PCI_DEVID(info->bus, info->devfn);
367+
sdev->iommu = iommu;
367368

368369
/* Only count users if device has aux domains */
369370
if (iommu_dev_feature_enabled(dev, IOMMU_DEV_FEAT_AUX))
@@ -548,6 +549,7 @@ intel_svm_bind_mm(struct device *dev, unsigned int flags,
548549
goto out;
549550
}
550551
sdev->dev = dev;
552+
sdev->iommu = iommu;
551553

552554
ret = intel_iommu_enable_pasid(iommu, dev);
553555
if (ret) {
@@ -577,7 +579,6 @@ intel_svm_bind_mm(struct device *dev, unsigned int flags,
577579
kfree(sdev);
578580
goto out;
579581
}
580-
svm->iommu = iommu;
581582

582583
if (pasid_max > intel_pasid_max_id)
583584
pasid_max = intel_pasid_max_id;

include/linux/intel-iommu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ struct intel_svm_dev {
758758
struct list_head list;
759759
struct rcu_head rcu;
760760
struct device *dev;
761+
struct intel_iommu *iommu;
761762
struct svm_dev_ops *ops;
762763
struct iommu_sva sva;
763764
u32 pasid;
@@ -771,7 +772,6 @@ struct intel_svm {
771772
struct mmu_notifier notifier;
772773
struct mm_struct *mm;
773774

774-
struct intel_iommu *iommu;
775775
unsigned int flags;
776776
u32 pasid;
777777
int gpasid; /* In case that guest PASID is different from host PASID */

0 commit comments

Comments
 (0)