diff mbox series

[v4,05/14] iommufd/hw_pagetable: Enforce cache invalidation op on vIOMMU-based hwpt_nested

Message ID a59b99a85c1294775b6ea2850cb34111eacab8d9.1729555967.git.nicolinc@nvidia.com (mailing list archive)
State New
Headers show
Series iommufd: Add vIOMMU infrastructure (Part-2: vDEVICE) | expand

Commit Message

Nicolin Chen Oct. 22, 2024, 12:20 a.m. UTC
A vIOMMU-based hwpt_nested requires a cache invalidation op too, either
using the one in iommu_domain_ops or the one in viommu_ops. Enforce that
upon the allocated hwpt_nested.

Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 drivers/iommu/iommufd/hw_pagetable.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c
index 5314cd486ddb..7af6cbe6dbf2 100644
--- a/drivers/iommu/iommufd/hw_pagetable.c
+++ b/drivers/iommu/iommufd/hw_pagetable.c
@@ -300,7 +300,9 @@  iommufd_hwpt_nested_alloc_for_viommu(struct iommufd_viommu *viommu,
 	}
 	hwpt->domain->owner = viommu->iommu_dev->ops;
 
-	if (WARN_ON_ONCE(hwpt->domain->type != IOMMU_DOMAIN_NESTED)) {
+	if (WARN_ON_ONCE(hwpt->domain->type != IOMMU_DOMAIN_NESTED ||
+			 (!viommu->ops->cache_invalidate &&
+			  !hwpt->domain->ops->cache_invalidate_user))) {
 		rc = -EINVAL;
 		goto out_abort;
 	}