[RFC PATCH v3 05/10] iommu/riscv: Add nested domain allocation
Andrew Jones
andrew.jones at linux.dev
Sat Nov 21 04:37:29 PST 2026
On Thu, Nov 19, 2026 at 09:27:39PM +0800, Gong Shuai wrote:
> From: Wu Fei <wu.fei9 at sanechips.com.cn>
>
> 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 at sanechips.com.cn>
> Co-developed-by: Gong Shuai <gong.shuai at sanechips.com.cn>
> Signed-off-by: Gong Shuai <gong.shuai at sanechips.com.cn>
> ---
> 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
More information about the linux-riscv
mailing list