aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Pan <[email protected]>2019-05-08 12:22:46 -0700
committerJoerg Roedel <[email protected]>2019-05-27 11:54:56 +0200
commitd7af4d987dfa31c5d715e940a447ea959f89e575 (patch)
treee876a96729aa4334e46a3b0b79861a96ee3e4e13
parentcd6c84d8f0cdc911df435bb075ba22ce3c605b07 (diff)
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. Signed-off-by: Jacob Pan <[email protected]> Reported-by: Mike Campin <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
-rw-r--r--drivers/iommu/intel-svm.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
index 8f87304f915c..421e4145a823 100644
--- a/drivers/iommu/intel-svm.c
+++ b/drivers/iommu/intel-svm.c
@@ -374,6 +374,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);