[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID:
<SEZPR01MB4399D06A044791DEA8BE43CBDCAAA@SEZPR01MB4399.apcprd01.prod.exchangelabs.com>
Date: Wed, 17 Dec 2025 00:13:45 +0800
From: Wei Wang <wei.w.wang@...mail.com>
To: jgg@...dia.com,
kevin.tian@...el.com,
alex@...zbot.org,
joro@...tes.org,
thomas.lendacky@....com,
vasant.hegde@....com,
suravee.suthikulpanit@....com,
aik@....com
Cc: iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org,
wei.w.wang@...mail.com
Subject: [PATCH v4 0/2] iommu: Avoid setting C-bit for MMIO addresses
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.
v3->v4 change:
- In the 2nd patch, moved the VM_IO check into the
if (is_invalid_reserved_pfn(*pfn)) {} code block to avoid checking it on
error paths.
v3 link: https://lore.kernel.org/lkml/SI2PR01MB439337D5513729BAC122F526DCCDA@SI2PR01MB4393.apcprd01.prod.exchangelabs.com/
v2->v3 changes:
- re-implement the iommu part based on the iommu tree which has the
iommupt patches merged.
v2 link: https://lore.kernel.org/lkml/SI2PR01MB439373CA7A023D8EC4C42040DCC7A@SI2PR01MB4393.apcprd01.prod.exchangelabs.com/
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://lore.kernel.org/lkml/SI2PR01MB439358422CCAABADBEB21D7CDCF0A@SI2PR01MB4393.apcprd01.prod.exchangelabs.com/
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 | 14 +++++++++-----
3 files changed, 13 insertions(+), 7 deletions(-)
--
2.51.0
Powered by blists - more mailing lists