From: Wencheng Yang <east.moutain.yang@gmail.com>
To: east.moutain.yang@gmail.com, alex.williamson@redhat.com, jgg@ziepe.ca
Cc: iommu@lists.linux.dev, joro@8bytes.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, robin.murphy@arm.com,
suravee.suthikulpanit@amd.com, will@kernel.org
Subject: [PATCH v3 2/3] vfio/vfio_iommu_type1:convert VFIO_DMA_MAP_FLAG_MMIO to IOMMU_MMIO flag
Date: Tue, 21 Jan 2025 19:28:35 +0800 [thread overview]
Message-ID: <20250121112836.525046-2-east.moutain.yang@gmail.com> (raw)
In-Reply-To: <20250121112836.525046-1-east.moutain.yang@gmail.com>
Refer to commit: 31e6850e0fdb iommu: Add MMIO mapping type (Robin Murphy),
IOMMU needs to know the type of mapping to setup IOMMU page table,
if the mapping is for device MMIO region, on some platforms, IOMMU page
table entry attrs should be different versus regular memory.
Signed-off-by: Wencheng Yang <east.moutain.yang@gmail.com>
---
drivers/vfio/vfio_iommu_type1.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 50ebc9593c9d..08be1ef8514b 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -1557,6 +1557,8 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
prot |= IOMMU_WRITE;
if (map->flags & VFIO_DMA_MAP_FLAG_READ)
prot |= IOMMU_READ;
+ if (map->flags & VFIO_DMA_MAP_FLAG_MMIO)
+ prot |= IOMMU_MMIO;
if ((prot && set_vaddr) || (!prot && !set_vaddr))
return -EINVAL;
@@ -2801,7 +2803,7 @@ static int vfio_iommu_type1_map_dma(struct vfio_iommu *iommu,
struct vfio_iommu_type1_dma_map map;
unsigned long minsz;
uint32_t mask = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE |
- VFIO_DMA_MAP_FLAG_VADDR;
+ VFIO_DMA_MAP_FLAG_VADDR | VFIO_DMA_MAP_FLAG_MMIO;
minsz = offsetofend(struct vfio_iommu_type1_dma_map, size);
--
2.43.0
next prev parent reply other threads:[~2025-01-21 11:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-17 7:14 [PATCH v2] drviers/iommu/amd: support P2P access through IOMMU when SME is enabled Wencheng Yang
2025-01-17 13:44 ` Alex Williamson
2025-01-21 11:07 ` Wencheng Yang
2025-01-21 11:28 ` [PATCH v3 1/3] uapi/linux/vfio:Add VFIO_DMA_MAP_FLAG_MMIO flag Wencheng Yang
2025-01-21 11:28 ` Wencheng Yang [this message]
2025-01-21 11:28 ` [PATCH v3 3/3] iommu/amd:Clear encryption bit if the mapping is for device MMIO Wencheng Yang
2025-01-21 14:05 ` [PATCH v3 1/3] uapi/linux/vfio:Add VFIO_DMA_MAP_FLAG_MMIO flag Jason Gunthorpe
2025-01-21 15:34 ` [PATCH v2] drviers/iommu/amd: support P2P access through IOMMU when SME is enabled Alex Williamson
2025-01-21 20:47 ` Jason Gunthorpe
2025-01-20 13:59 ` Jason Gunthorpe
2025-01-21 9:27 ` Wencheng Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250121112836.525046-2-east.moutain.yang@gmail.com \
--to=east.moutain.yang@gmail.com \
--cc=alex.williamson@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox