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

From: Andrew Jones

Date: Sat Nov 21 2026 - 07:38:12 EST


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,
drew