Re: [PATCH v5 13/14] iommu/amd: Refactor logic to program the host page table in DTE

From: Jason Gunthorpe

Date: Tue Nov 18 2025 - 19:18:13 EST


On Wed, Nov 12, 2025 at 06:25:05PM +0000, Suravee Suthikulpanit wrote:

> @@ -2097,35 +2115,29 @@ static void set_dte_entry(struct amd_iommu *iommu,
> old_domid = READ_ONCE(dte->data[1]) & DTE_DOMID_MASK;
> - new.data[1] |= domid;
> -
> - set_dte_gcr3_table(iommu, dev_data, &new);
> + if (gcr3_info && gcr3_info->gcr3_tbl)
> + set_dte_gcr3_table(dev_data, &new);
> + else if (domain->domain.type == IOMMU_DOMAIN_IDENTITY)
> + set_dte_passthrough(dev_data, domain, &new);
> + else if (domain->domain.type & __IOMMU_DOMAIN_PAGING &&

() around the & is kernel style I think

Otherwise this looks OK

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

In some future the set_dte_xx should be called from the domain attach
function that knows what kind of domain it is attaching already - ie
identity, v1, v2 all should have different attach functions.

Jason