[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v3 07/10] Add EXEC_FLAG to VFIO DMA mappings
From: |
Eric Auger |
Subject: |
[Qemu-devel] [RFC v3 07/10] Add EXEC_FLAG to VFIO DMA mappings |
Date: |
Mon, 2 Jun 2014 08:49:31 +0100 |
From: Alvise Rigo <address@hidden>
The flag is mandatory for the ARM SMMU so we always add it if the MMIO
handles it.
Signed-off-by: Alvise Rigo <address@hidden>
---
hw/vfio/common.c | 9 +++++++++
hw/vfio/vfio-common.h | 1 +
linux-headers/linux/vfio.h | 2 ++
3 files changed, 12 insertions(+)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 28d29de..8b25380 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -82,6 +82,11 @@ static int vfio_dma_map(VFIOContainer *container, hwaddr
iova,
map.flags |= VFIO_DMA_MAP_FLAG_WRITE;
}
+ /* add exec flag */
+ if (container->iommu_data.has_exec_cap) {
+ map.flags |= VFIO_DMA_MAP_FLAG_EXEC;
+ }
+
/*
* Try the mapping, if it fails with EBUSY, unmap the region and try
* again. This shouldn't be necessary, but we sometimes see it in
@@ -327,6 +332,10 @@ static int vfio_connect_container(VFIOGroup *group)
return -errno;
}
+ if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_IOMMU_PROT_EXEC)) {
+ container->iommu_data.has_exec_cap = true;
+ }
+
container->iommu_data.type1.listener = vfio_memory_listener;
container->iommu_data.release = vfio_listener_release;
diff --git a/hw/vfio/vfio-common.h b/hw/vfio/vfio-common.h
index 5412acd..dcd7ddd 100644
--- a/hw/vfio/vfio-common.h
+++ b/hw/vfio/vfio-common.h
@@ -100,6 +100,7 @@ typedef struct VFIOContainer {
union {
VFIOType1 type1;
};
+ bool has_exec_cap; /* support of exec capability by the IOMMU */
void (*release)(struct VFIOContainer *);
} iommu_data;
QLIST_HEAD(, VFIOGroup) group_list;
diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
index ef4815d..e96e14d 100644
--- a/linux-headers/linux/vfio.h
+++ b/linux-headers/linux/vfio.h
@@ -30,6 +30,7 @@
*/
#define VFIO_DMA_CC_IOMMU 4
+#define VFIO_IOMMU_PROT_EXEC 5
/*
* The IOCTL interface is designed for extensibility by embedding the
* structure length (argsz) and flags into structures passed between
@@ -399,6 +400,7 @@ struct vfio_iommu_type1_dma_map {
__u32 flags;
#define VFIO_DMA_MAP_FLAG_READ (1 << 0) /* readable from device
*/
#define VFIO_DMA_MAP_FLAG_WRITE (1 << 1) /* writable from device */
+#define VFIO_DMA_MAP_FLAG_EXEC (1 << 2) /* executable from device */
__u64 vaddr; /* Process virtual address */
__u64 iova; /* IO virtual address */
__u64 size; /* Size of mapping (bytes) */
--
1.8.3.2
[Qemu-devel] [RFC v3 06/10] virt: Assign a VFIO platform device with -device option, Eric Auger, 2014/06/02