[PATCH v2 8/9] iommu/vt-d: Send IOASID bind/unbind notifications

From: Jacob Pan
Date: Sat Aug 22 2020 - 00:29:02 EST


On Intel Scalable I/O Virtualization (SIOV) enabled platforms with
ENQCMD in use by the guest, KVM must establish a guest-host PASID
translation table prior to the issuing of ENQCMD. PASID translation
table also depends on the IOMMU PASID entry, which is configured during
the guest page table bind time. This patch adds a notification event to
the IOMMU driver such that KVM can be notified when a new guest-host
PASID mapping is established or demolished.

Signed-off-by: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>
---
drivers/iommu/intel/svm.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
index 600e3ae5b656..d8a5efa75095 100644
--- a/drivers/iommu/intel/svm.c
+++ b/drivers/iommu/intel/svm.c
@@ -471,6 +471,11 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev,
}

mutex_unlock(&pasid_mutex);
+ /*
+ * Notify KVM new host-guest PASID bind is ready. KVM will set up
+ * PASID translation table to support guest ENQCMD.
+ */
+ ioasid_notify(data->hpasid, IOASID_BIND, IOASID_NOTIFY_SET);
return ret;
}

@@ -510,6 +515,8 @@ int intel_svm_unbind_gpasid(struct device *dev, int pasid)
* and perform cleanup.
*/
ioasid_attach_data(pasid, NULL);
+ ioasid_notify(pasid, IOASID_UNBIND,
+ IOASID_NOTIFY_SET);
kfree(svm);
}
}
--
2.7.4