RE: [PATCH] iommu/vt-d: Fix PASID directory pointer coherency

From: Tian, Kevin
Date: Mon Feb 06 2023 - 19:41:29 EST


> From: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>
> Sent: Tuesday, February 7, 2023 1:25 AM
>
> > > @@ -1976,6 +1976,12 @@ static int
> domain_context_mapping_one(struct
> > > dmar_domain *domain, pds = context_get_sm_pds(table);
> > > context->lo = (u64)virt_to_phys(table->table) |
> > > context_pdts(pds);
> > > + /*
> > > + * Scalable-mode PASID directory pointer is not
> > > snooped if the
> > > + * coherent bit is not set.
> > > + */
> > > + if (!ecap_coherent(iommu->ecap))
> > > + clflush_cache_range(table->table, sizeof(void
> > > *));
> >
> > This isn't comprehensive. The clflush should be called whenever the
> > pasid directory table is allocated or updated.
> >
> allocate a pasid table does not mean it gets used by iommu hw, not until it
> is programmed into context entry.
>

this is insufficient.

Even after this point the PASID directory entry could be changed when
a new PASID table is allocated, e.g. in intel_pasid_get_entry().