Re: [PATCH v2 1/2] iommu/amd: Add IOMMU_PROT_IE flag for memory encryption
From: Jason Gunthorpe
Date: Thu Nov 06 2025 - 20:02:26 EST
On Mon, Nov 03, 2025 at 10:00:33PM +0800, Wei Wang wrote:
> Introduce the IOMMU_PROT_IE flag to allow callers of iommu_v1_map_pages()
> to explicitly request memory encryption for specific mappings.
>
> With SME enabled, the C-bit (encryption bit) in IOMMU page table entries
> is now set only when IOMMU_PROT_IE is specified. This provides
> fine-grained control over which IOVAs are encrypted through the IOMMU
> page tables.
>
> Current PCIe devices and switches do not interpret the C-bit, so applying
> it to MMIO mappings would break PCIe peer‑to‑peer communication. Update
> the implementation to restrict C-bit usage to non‑MMIO backed IOVAs.
>
> Fixes: 2543a786aa25 ("iommu/amd: Allow the AMD IOMMU to work with memory encryption")
> Suggested-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Signed-off-by: Wei Wang <wei.w.wang@xxxxxxxxxxx>
> ---
> drivers/iommu/amd/amd_iommu_types.h | 3 ++-
> drivers/iommu/amd/io_pgtable.c | 7 +++++--
> drivers/iommu/amd/iommu.c | 2 ++
> 3 files changed, 9 insertions(+), 3 deletions(-)
Since Joerg took the iommupt patches this will need to be rebased on
his tree, I think it will be simpler..
Jason