[RFC PATCH 8/9] vfio: UAPI for setting mmap attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This uapi allows setting mmap attributes using a specified region
offset, region offset is expected to be used from returned value of
VFIO_DEVICE_GET_REGION_INFO or similar, where vmmap mt entry was
created, start with write_combine attribute, which the user can use to
request mmap to use wc. vfio devices expected to load the vmmap entry
from mt and do the needed region specific checks, and sets the
attributes accordingly.

Signed-off-by: Mahmoud Adam <mngyadam@xxxxxxxxx>
---
 drivers/vfio/vfio_main.c  |  1 +
 include/linux/vfio.h      |  1 +
 include/uapi/linux/vfio.h | 19 +++++++++++++++++++
 3 files changed, 21 insertions(+)

diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
index 3275ff56eef47..58c3cf12a5317 100644
--- a/drivers/vfio/vfio_main.c
+++ b/drivers/vfio/vfio_main.c
@@ -633,6 +633,7 @@ void vfio_mmap_init(struct vfio_device *vdev, struct vfio_mmap *vmmap,
 	vmmap->ops = ops;
 	vmmap->size = size;
 	vmmap->region_flags = region_flags;
+	vmmap->attrs = 0;
 }
 EXPORT_SYMBOL_GPL(vfio_mmap_init);
 
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index 836ef72a38104..5885df1729183 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -85,6 +85,7 @@ struct vfio_mmap {
 	u64 offset;
 	u64 size;
 	u32 region_flags;
+	u32 attrs;
 	struct vfio_mmap_ops *ops;
 };
 
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 5764f315137f9..2e3fa90eef5a3 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -1831,6 +1831,25 @@ struct vfio_iommu_spapr_tce_remove {
 };
 #define VFIO_IOMMU_SPAPR_TCE_REMOVE	_IO(VFIO_TYPE, VFIO_BASE + 20)
 
+/**
+ * VFIO_DEVICE_SET_MMAP_ATTRS  - _IOW(VFIO_TYPE, VFIO_BASE + 21, struct vfio_mmap_attrs)
+ *
+ * Set memory mapping attributes for a specified region offset before
+ * calling mmap, it expects that the offset used was fetched by
+ * calling VFIO_DEVICE_GET_REGION_INFO.
+ *
+ * Attributes supported:
+ * - VFIO_MMAP_ATTR_WRITE_COMBINE: use write-combine when requested to mmap this offset.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_mmap_attrs {
+	__u64	offset;	/* Region offset */
+	__u32	attrs;
+#define VFIO_MMAP_ATTR_WRITE_COMBINE	(1 << 0)
+};
+#define VFIO_DEVICE_SET_MMAP_ATTRS	_IO(VFIO_TYPE, VFIO_BASE + 21)
+
 /* ***************************************************************** */
 
 #endif /* _UAPIVFIO_H */
-- 
2.47.3




Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux