[PATCH v3 0/3] iommu/amd: Invalidate IRT cache for DMA aliases

Magnus Kalland posted 3 patches 1 month, 2 weeks ago
There is a newer version of this series
drivers/iommu/amd/iommu.c | 52 +++++++++++++++++++++++++++++++++------
1 file changed, 45 insertions(+), 7 deletions(-)
[PATCH v3 0/3] iommu/amd: Invalidate IRT cache for DMA aliases
Posted by Magnus Kalland 1 month, 2 weeks ago
DMA aliasing causes interrupt remapping table entries (IRTEs) to be shared
between multiple device IDs. See commit 3c124435e8dd
("iommu/amd: Support multiple PCI DMA aliases in IRQ Remapping") for more
information on this. However, the AMD IOMMU driver currently invalidates
IRTE cache entries on a per-device basis whenever an IRTE is updated, not
for each alias.

This approach leaves stale IRTE cache entries when an IRTE is cached under
one DMA alias but later updated and invalidated through a different alias.
In such cases, the original device ID is never invalidated, since it is
programmed via aliasing.

This incoherency bug has been observed when IRTEs are cached for one
Non-Transparent Bridge (NTB) DMA alias, later updated via another.

Fix this by invalidating the interrupt remapping table cache for all DMA
aliases when updating an IRTE.

Changes since v2:
 - Look for aliases with pci_seg->alias_table instead of
   pci_for_each_dma_alias since we can't get the pdev (lockdep).
   Track the aliases in set_remap_table_entry_alias. Invalidate IRT cache
   for each BDF sharing alias with the given devid in
   iommu_flush_irt_and_complete.
 - Make iommu_table_lock a raw spinlock to use it when invalidating
   IRT caches.
 - Rebased and applied cleanly on the IOMMU development tree

Co-developed-by: Lars B. Kristiansen <larsk@dolphinics.com>
Signed-off-by: Lars B. Kristiansen <larsk@dolphinics.com>
Co-developed-by: Jonas Markussen <jonas@dolphinics.com>
Signed-off-by: Jonas Markussen <jonas@dolphinics.com>
Co-developed-by: Tore H. Larsen <torel@simula.no>
Signed-off-by: Tore H. Larsen <torel@simula.no>
Signed-off-by: Magnus Kalland <magnus@dolphinics.com>
Link: https://lore.kernel.org/linux-iommu/26cfa307-6c33-41f9-a7a0-fbf202b38a00@amd.com/

Magnus Kalland (3):
  iommu/amd: Use raw spinlock for interrupt remapping tables
  iommu/amd: Track PCIe DMA aliases in set_remap_table_entry_alias
  iommu/amd: Invalidate IRT cache for DMA aliases

 drivers/iommu/amd/iommu.c | 52 +++++++++++++++++++++++++++++++++------
 1 file changed, 45 insertions(+), 7 deletions(-)

-- 
2.43.0