Re: [PATCH v2 12/26] iommu/amd: Add per-VM private IPA alloc/map helpers

From: Weinan Liu

Date: Mon Jun 01 2026 - 14:26:26 EST


On Mon, Jun 1, 2026 at 6:11 AM Jason Gunthorpe <jgg@xxxxxxxxxx> wrote:
>
> On Thu, May 28, 2026 at 05:17:24AM +0000, Suravee Suthikulpanit wrote:
> > Export amd_iommu_iotlb_sync() and use it for nested domain
> > iotlb_sync so nested attach paths can flush gathered IOTLB state.
>
> [ ..]
>
> > --- a/drivers/iommu/amd/nested.c
> > +++ b/drivers/iommu/amd/nested.c
> > @@ -291,4 +291,5 @@ static void nested_domain_free(struct iommu_domain *dom)
> > static const struct iommu_domain_ops nested_domain_ops = {
> > .attach_dev = nested_attach_device,
> > .free = nested_domain_free,
> > + .iotlb_sync = amd_iommu_iotlb_sync,
> > };
>
>
> I don't get it, what is all of this for?
>
> iotlb_sync should never be called on an IOMMU_DOMAIN_NESTED.
>
> "nested attach paths" should never have gathered IOTLB state.
>
> Jason

BTW, amd_iommu_iotlb_sync() is designed to flush a protection_domain and cannot be used for a nested_domain.

Specifically, the current implementation explicitly casts the domain to a protection_domain:

```
void amd_iommu_iotlb_sync(struct iommu_domain *domain,
struct iommu_iotlb_gather *gather)
{
struct protection_domain *dom = to_pdomain(domain);
```