aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Nipun Gupta <nipun.gupta@amd.com> 2023-09-15 10:24:22 +0530
committerGravatar Alex Williamson <alex.williamson@redhat.com> 2023-09-28 12:12:07 -0600
commitf59a7b6af012619199c55f587a6c4ed681639b32 (patch)
treef2c3e4e32661fdf856a6a4517007a4229a8414ac
parentcdx: add support for bus mastering (diff)
downloadlinux-f59a7b6af012619199c55f587a6c4ed681639b32.tar.gz
linux-f59a7b6af012619199c55f587a6c4ed681639b32.tar.bz2
linux-f59a7b6af012619199c55f587a6c4ed681639b32.zip
vfio: add bus master feature to device feature ioctl
add bus mastering control to VFIO_DEVICE_FEATURE IOCTL. The VFIO user can use this feature to enable or disable the Bus Mastering of a device bound to VFIO. Co-developed-by: Shubham Rohila <shubham.rohila@amd.com> Signed-off-by: Shubham Rohila <shubham.rohila@amd.com> Signed-off-by: Nipun Gupta <nipun.gupta@amd.com> Link: https://lore.kernel.org/r/20230915045423.31630-2-nipun.gupta@amd.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
-rw-r--r--include/uapi/linux/vfio.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index afc1369216d9..b177424149f4 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -1434,6 +1434,27 @@ struct vfio_device_feature_mig_data_size {
#define VFIO_DEVICE_FEATURE_MIG_DATA_SIZE 9
+/**
+ * Upon VFIO_DEVICE_FEATURE_SET, set or clear the BUS mastering for the device
+ * based on the operation specified in op flag.
+ *
+ * The functionality is incorporated for devices that needs bus master control,
+ * but the in-band device interface lacks the support. Consequently, it is not
+ * applicable to PCI devices, as bus master control for PCI devices is managed
+ * in-band through the configuration space. At present, this feature is supported
+ * only for CDX devices.
+ * When the device's BUS MASTER setting is configured as CLEAR, it will result in
+ * blocking all incoming DMA requests from the device. On the other hand, configuring
+ * the device's BUS MASTER setting as SET (enable) will grant the device the
+ * capability to perform DMA to the host memory.
+ */
+struct vfio_device_feature_bus_master {
+ __u32 op;
+#define VFIO_DEVICE_FEATURE_CLEAR_MASTER 0 /* Clear Bus Master */
+#define VFIO_DEVICE_FEATURE_SET_MASTER 1 /* Set Bus Master */
+};
+#define VFIO_DEVICE_FEATURE_BUS_MASTER 10
+
/* -------- API for Type1 VFIO IOMMU -------- */
/**