iommu/vt-d: Fix bind svm with multiple devices
PATCH 1/1 iommu/vt-d: Fix bind svm with multiple devices
If multiple devices try to bind to the same mm/PASID, we need to set up first level PASID entries for all the devices. The current code does not consider this case which results in failed DMA for devices after the first bind.
--- drivers/iommu/intel-svm.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/iommu/intel-svm.c +15 -0
@@ -357,6 +357,21 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ }list_add_tail (&svm->list, &global_svm_list); + }else { +/* +* Binding a new device with existing PASID, need to setup +* the PASID entry. +*/ +spin_lock (&iommu->lock); + ret =intel_pasid_setup_first_level (iommu, dev, + mm ? mm->pgd : init_mm.pgd, + svm->pasid,FLPT_DEFAULT_DID , + mm ?0 :PASID_FLAG_SUPERVISOR_MODE ); +spin_unlock (&iommu->lock); +if (ret) { +kfree (sdev); + goto out; + } }list_add_rcu (&sdev->list, &svm->devs);
Signature · 6 lines
2.7.4 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Hi Joerg & David,
Any feedback on this one? Thanks.
Quoted 34 lines · On Wed, 8 May 2019 12:22:46 -0700 Jacob Pan <[email protected]>…
If multiple devices try to bind to the same mm/PASID, we need to set up first level PASID entries for all the devices. The current code does not consider this case which results in failed DMA for devices after the first bind.
Signed-off-by Jacob Pan <[email protected]>Reported-by Mike Campin <[email protected]>--- drivers/iommu/intel-svm.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)drivers/iommu/intel-svm.c +3
-0@@ -357,6 +357,21 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ }list_add_tail (&svm->list, &global_svm_list); + }else { +/* +* Binding a new device with existing PASID, need to setup
drivers/iommu/intel-svm.c +5
-0+* the PASID entry. +*/ +spin_lock (&iommu->lock); + ret = intel_pasid_setup_first_level(iommu, dev, + mm ? mm->pgd :init_mm.pgd,
drivers/iommu/intel-svm.c +1
-0+ svm->pasid,
FLPT_DEFAULT_DID,drivers/iommu/intel-svm.c +1
-0+ mm ? 0 :
PASID_FLAG_SUPERVISOR_MODE);
drivers/iommu/intel-svm.c int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ · line 376
Quoted 7 lines
drivers/iommu/intel-svm.c +5
-0+spin_unlock (&iommu->lock); +if (ret) { +kfree (sdev); + goto out; + } }list_add_rcu (&sdev->list, &svm->devs);
[Jacob Pan]
Joerg Roedel
maintainerQuoted 10 lines · Jacob Pan
If multiple devices try to bind to the same mm/PASID, we need to set up first level PASID entries for all the devices. The current code does not consider this case which results in failed DMA for devices after the first bind.
Signed-off-by Jacob Pan <[email protected]>Reported-by Mike Campin <[email protected]>--- drivers/iommu/intel-svm.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Applied for v5.3, thanks.