Re: [RFC PATCH v3 05/10] iommu/riscv: Add nested domain allocation

From: Gong Shuai

Date: Mon Nov 23 2026 - 07:33:20 EST


Hi Andrew,

On 11/21/2026 8:37 PM, Andrew Jones wrote:
On Thu, Nov 19, 2026 at 09:27:39PM +0800, Gong Shuai wrote:
From: Wu Fei <wu.fei9@xxxxxxxxxxxxxxxx>

A nested domain describes two-stage translation through guest and
host page tables. Iommufd exposes this domain as a nested hwpt.

User space needs to provide the guest stage 1 configuration when
allocating a nested hwpt. Validate the configuration before storing
it for use in a physical device context.

Signed-off-by: Wu Fei <wu.fei9@xxxxxxxxxxxxxxxx>
Co-developed-by: Gong Shuai <gong.shuai@xxxxxxxxxxxxxxxx>
Signed-off-by: Gong Shuai <gong.shuai@xxxxxxxxxxxxxxxx>
---
drivers/iommu/riscv/iommu.c | 153 ++++++++++++++++++++++++++++++++++++
1 file changed, 153 insertions(+)

diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
index f2305b953f71..4f8ce579ef08 100644
--- a/drivers/iommu/riscv/iommu.c
+++ b/drivers/iommu/riscv/iommu.c
@@ -1698,8 +1698,161 @@ static void riscv_viommu_destroy(struct iommufd_viommu *viommu)
ida_free(&riscv_iommu_gscids, rv_viommu->gscid);
}
+struct riscv_iommu_nested_domain {
+ struct iommu_domain domain;
+ struct riscv_viommu *viommu;
+
+ u64 tc;
+ u64 ta;
+ u64 iosatp;
+};
+
+#define to_riscv_iommu_nested_domain(domain) \
+ container_of(domain, struct riscv_iommu_nested_domain, domain)
+

Please rename the macro parameter so it doesn't collide with the domain
member name, otherwise macro expansion replaces the member name too.

Thanks for catching this, silly mistake on my part:)
I'll rename it in the next version.

Best regards,
Shuai


Thanks,
drew

_______________________________________________
linux-riscv mailing list
linux-riscv@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/linux-riscv