> From: Peter Xu <peterx@xxxxxxxxxx> > Sent: Thursday, March 26, 2020 9:23 PM > To: Liu, Yi L <yi.l.liu@xxxxxxxxx> > Subject: Re: [PATCH v1 20/22] intel_iommu: propagate PASID-based iotlb > invalidation to host > > On Thu, Mar 26, 2020 at 09:02:48AM -0400, Peter Xu wrote: > > [...] > > > > > > > +static inline bool vtd_pasid_cache_valid( > > > > > > + VTDPASIDAddressSpace *vtd_pasid_as) { > > > > > > + return vtd_pasid_as->iommu_state && > > ^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > > > > > > > > > This check can be dropped because always true? > > > > > > > > > > If you agree with both the changes, please add: > > > > > > > > > > Reviewed-by: Peter Xu <peterx@xxxxxxxxxx> > > > > > > > > I think the code should ensure all the pasid_as in hash table is > > > > valid. And we can since all the operations are under protection of iommu_lock. > > > > > > > Peter, > > > > > > I think my reply was wrong. pasid_as in has table may be stale since > > > the per pasid_as cache_gen may be not identical with the cache_gen > > > in iommu_state. e.g. vtd_pasid_cache_reset() only increases the > > > cache_gen in iommu_state. So there will be pasid_as in hash table > > > which has cached pasid entry but its cache_gen is not equal to the > > > one in iommu_state. For such pasid_as, we should treat it as stale. > > > So I guess the vtd_pasid_cache_valid() is still necessary. > > > > I guess you misread my comment. :) > > > > I was saying the "vtd_pasid_as->iommu_state" check is not needed, > > because iommu_state was always set if the address space is created. > > vtd_pasid_cache_valid() is needed. > > > > Also, please double confirm that vtd_pasid_cache_reset() should drop > > all the address spaces (as I think it should), not "only increase the > > cache_gen". IMHO you should only increase the cache_gen in the PSI > > hook (vtd_pasid_cache_psi()) only. > > Sorry, I mean GSI (vtd_pasid_cache_gsi), not PSI. Got it.. Really confused me. :-) Regards, Yi Liu