On Wed, Jul 15, 2020 at 12:03:57PM +0200, Jan Beulich wrote: > Instead of checking inside the hook whether any non-coherent IOMMUs are > present, simply install the hook only when this is the case. > > To prove that there are no other references to the now dynamically > updated ops structure (and hence that its updating happens early > enough), make it static and rename it at the same time. > > Note that this change implies that sync_cache() shouldn't be called > directly unless there are unusual circumstances, like is the case in > alloc_pgtable_maddr(), which gets invoked too early for iommu_ops to > be set already (and therefore we also need to be careful there to > avoid accessing vtd_ops later on, as it lives in .init). > > Signed-off-by: Jan Beulich <jbeul...@suse.com>
I think this is slightly better than what we currently have: Reviewed-by: Roger Pau Monné <roger....@citrix.com> I would however prefer if we also added a check to assert that alloc_pgtable_maddr is never called before iommu_alloc. We could maybe poison the .sync_cache field, and then either set to NULL or to sync_cache in iommu_alloc? Maybe I'm just overly paranoid with this. Thanks.