Re: [RFCv2 PATCH 1/7] iommu/amd: Introduce struct gcr3_tbl_info.giov

From: Jason Gunthorpe
Date: Fri Mar 08 2024 - 08:49:26 EST


On Thu, Jan 11, 2024 at 06:06:40PM -0600, Suravee Suthikulpanit wrote:
> To track DTE[GIOV] programming during IOMMU domain attach, also add logic
> to determine if the GIOV is required, and set the variable accordinglly.
>
> This is also a preparation for adding nested domain support, where the GIOV
> setting is determined by the child domain.
>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
> ---
> drivers/iommu/amd/amd_iommu_types.h | 1 +
> drivers/iommu/amd/iommu.c | 11 +++++++++--
> 2 files changed, 10 insertions(+), 2 deletions(-)

I really think the DTE handling needs to be cleaned up before nesting
will be easy.

Various bits of the DTE should just flow directly through from the
VM's version of the DTE, it is going to be a mess to do that in this
manner

> @@ -2067,6 +2066,14 @@ static int do_attach(struct iommu_dev_data *dev_data,
> free_gcr3_table(dev_data);
> return ret;
> }
> +
> + /*
> + * GIOV is required for PD_MODE_V2 because we need
> + * to support the case where the end-point device
> + * does not have PASID in the TLP prefix when setting
> + * up to use the v2 table.
> + */
> + dev_data->gcr3_info.giov = true;

Ie who clears this once you set it ? :(

Jason