All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] iommu: Avoid setting C-bit for MMIO addresses
@ 2025-11-13 15:54 Wei Wang
  2025-11-13 15:54 ` [PATCH v3 1/2] iommupt: Do not set C-bit on MMIO backed PTEs Wei Wang
  2025-11-13 15:54 ` [PATCH v3 2/2] vfio/type1: Set IOMMU_MMIO in dma->prot for MMIO-backed addresses Wei Wang
  0 siblings, 2 replies; 10+ messages in thread
From: Wei Wang @ 2025-11-13 15:54 UTC (permalink / raw)
  To: alex, jgg, thomas.lendacky, vasant.hegde, suravee.suthikulpanit,
	joro
  Cc: aik, kevin.tian, wei.w.wang, linux-kernel, iommu

AMD APM specifies that any pages corresponding to MMIO addresses must be
configured with the C-bit clear. The current iommu implementation sets
the C-bit on all PTEs in the IOMMU page tables. This is incorrect for PTEs
backed by MMIO, and can break PCIe peer-to-peer communication when IOVA is
used. Fix this by avoiding the C-bit for MMIO-backed mappings.

v2->v3 changes:
- re-implement the iommu part based on the iommu tree which has the
  iommupt patches merged.
  v2 link: https://lkml.org/lkml/2025/11/3/878

v1->v2 changes:
- 1 used page_is_ram() in the AMD IOMMU driver to detect non-RAM
  addresses, avoiding changes to upper-layer callers (vfio and iommufd).
  v2 instead lets upper layers explicitly indicate MMIO mappings via the
  IOMMU_MMIO prot flag. This avoids the potential overhead of
  page_is_ram(). (suggested by Jason Gunthorpe) 
  v1 link: https://lkml.org/lkml/2025/10/23/1211

Wei Wang (2):
  iommupt: Do not set C-bit on MMIO backed PTEs
  vfio/type1: Set IOMMU_MMIO in dma->prot for MMIO-backed addresses

 drivers/iommu/generic_pt/fmt/amdv1.h  |  3 ++-
 drivers/iommu/generic_pt/fmt/x86_64.h |  3 ++-
 drivers/vfio/vfio_iommu_type1.c       | 13 ++++++++-----
 3 files changed, 12 insertions(+), 7 deletions(-)

base-commit: d22ff9a783a792263baca22f80a64cfc7ec319ea
-- 
2.51.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-12-16  5:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-13 15:54 [PATCH v3 0/2] iommu: Avoid setting C-bit for MMIO addresses Wei Wang
2025-11-13 15:54 ` [PATCH v3 1/2] iommupt: Do not set C-bit on MMIO backed PTEs Wei Wang
2025-11-17 19:15   ` Jason Gunthorpe
2025-12-12  2:19   ` Tian, Kevin
2025-11-13 15:54 ` [PATCH v3 2/2] vfio/type1: Set IOMMU_MMIO in dma->prot for MMIO-backed addresses Wei Wang
2025-12-03  1:21   ` Wei Wang
2025-12-12  2:36   ` Tian, Kevin
2025-12-12  7:00     ` Jason Gunthorpe
2025-12-12  7:26       ` Tian, Kevin
2025-12-16  5:40         ` Wei Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.