Re: [PATCH v5 11/14] iommu/amd: Introduce gDomID-to-hDomID Mapping and handle parent domain invalidation

From: Nicolin Chen

Date: Tue Nov 18 2025 - 20:11:06 EST


On Tue, Nov 18, 2025 at 08:11:51PM -0400, Jason Gunthorpe wrote:
> On Wed, Nov 12, 2025 at 06:25:03PM +0000, Suravee Suthikulpanit wrote:
> > +static int iommu_flush_pages_v1_hdom_ids(struct protection_domain *pdom, u64 address, size_t size)
> > +{
> > + int ret = 0;
> > + struct amd_iommu_viommu *aviommu;
> > +
> > + list_for_each_entry(aviommu, &pdom->viommu_list, pdom_list) {
> > + unsigned long i;
> > + struct guest_domain_mapping_info *gdom_info;
> > + struct amd_iommu *iommu = container_of(aviommu->core.iommu_dev, struct amd_iommu, iommu);
> > +
> > + xa_for_each(&aviommu->gdomid_array, i, gdom_info) {

> This is kind of painfully slow for invalidation but OK for now, we
> don't really expect alot of parent invalidation traffic..
>
> I think after we get this landed:
>
> https://lore.kernel.org/r/cover.1762588839.git.nicolinc@xxxxxxxxxx
>
> We should take a serious run at trying to make it shared code and have
> AMD use it. That would resolve the performance concern..

Yea. I had the same feeling when looking at AMD's patch, and
realized that you did foresee all of these.

I've started work on the VMID sharing using the invs. Perhaps
I can add some patches prior to generalize those helpers.

Thanks
Nicolin