[RFC PATCH] iommu: add domain->nested

Zhangfei Gao
2021-06-16T14:38:27Z

Add domain->nested to decide whether domain is in nesting mode,
since attr DOMAIN_ATTR_NESTING is removed in the patches:
7876a83 iommu: remove iommu_domain_{get,set}_attr
7e14754 iommu: remove DOMAIN_ATTR_NESTING

Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---

Nesting info is still required for vsva according to
https://patchwork.kernel.org/project/linux-arm-kernel/patch/20210301084257.945454-16-hch@lst.de/

drivers/iommu/iommu.c | 8 +++++++-
include/linux/iommu.h | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 808ab70..ba26ad0 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2684,11 +2684,17 @@ core_initcall(iommu_init);

int iommu_enable_nesting(struct iommu_domain *domain)
{
+ int ret;
+
if (domain->type != IOMMU_DOMAIN_UNMANAGED)
return -EINVAL;
if (!domain->ops->enable_nesting)
return -EINVAL;
- return domain->ops->enable_nesting(domain);
+ ret = domain->ops->enable_nesting(domain);
+ if (!ret)
+ domain->nested = 1;
+
+ return ret;
}
EXPORT_SYMBOL_GPL(iommu_enable_nesting);

diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 32d4480..179f849 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -87,6 +87,7 @@ struct iommu_domain {
void *handler_token;
struct iommu_domain_geometry geometry;
void *iova_cookie;
+ int nested;
};

enum iommu_cap {
--
2.7.4