diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-11-02 02:55:40 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-11-02 02:55:40 +0300 |
commit | deefd5024f0772cf56052ace9a8c347dc70bcaf3 (patch) | |
tree | 3e0ff80b073c18c45103c5acbd318e62567cb989 /include | |
parent | 009fbfc97b6367762efa257f1478ec86d37949f9 (diff) | |
parent | 2b88119e35b00d8cb418d86abbace3b90a993bd7 (diff) | |
download | linux-deefd5024f0772cf56052ace9a8c347dc70bcaf3.tar.xz |
Merge tag 'vfio-v6.7-rc1' of https://github.com/awilliam/linux-vfio
Pull VFIO updates from Alex Williamson:
- Add support for "chunk mode" in the mlx5-vfio-pci variant driver,
which allows both larger device image sizes for migration, beyond the
previous 4GB limit, and also read-ahead support for improved
migration performance (Yishai Hadas)
- A new bus master control interface for the CDX bus driver where there
is no in-band mechanism to toggle device DMA as there is through
config space on PCI devices (Nipun Gupta)
- Add explicit alignment directives to vfio data structures to reduce
the chance of breaking 32-bit userspace. In most cases this is
transparent and the remaining cases where data structures are padded
work within the existing rules for extending data structures within
vfio (Stefan Hajnoczi)
- Resolve a bug in the cdx bus driver noted when compiled with clang
where missing parenthesis result in the wrong operation (Nathan
Chancellor)
- Resolve errors reported by smatch for a function when dealing with
invalid inputs (Alex Williamson)
- Add migration support to the mtty vfio/mdev sample driver for testing
and integration purposes, allowing CI of migration without specific
hardware requirements. Also resolve many of the short- comings of
this driver relative to implementation of the vfio interrupt ioctl
along the way (Alex Williamson)
* tag 'vfio-v6.7-rc1' of https://github.com/awilliam/linux-vfio:
vfio/mtty: Enable migration support
vfio/mtty: Overhaul mtty interrupt handling
vfio: Fix smatch errors in vfio_combine_iova_ranges()
vfio/cdx: Add parentheses between bitwise AND expression and logical NOT
vfio/mlx5: Activate the chunk mode functionality
vfio/mlx5: Add support for READING in chunk mode
vfio/mlx5: Add support for SAVING in chunk mode
vfio/mlx5: Pre-allocate chunks for the STOP_COPY phase
vfio/mlx5: Rename some stuff to match chunk mode
vfio/mlx5: Enable querying state size which is > 4GB
vfio/mlx5: Refactor the SAVE callback to activate a work only upon an error
vfio/mlx5: Wake up the reader post of disabling the SAVING migration file
vfio: use __aligned_u64 in struct vfio_device_ioeventfd
vfio: use __aligned_u64 in struct vfio_device_gfx_plane_info
vfio: trivially use __aligned_u64 for ioctl structs
vfio-cdx: add bus mastering device feature support
vfio: add bus master feature to device feature ioctl
cdx: add support for bus mastering
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/cdx/cdx_bus.h | 18 | ||||
-rw-r--r-- | include/uapi/linux/vfio.h | 47 |
2 files changed, 53 insertions, 12 deletions
diff --git a/include/linux/cdx/cdx_bus.h b/include/linux/cdx/cdx_bus.h index bead71b7bc73..8320ec3b9e37 100644 --- a/include/linux/cdx/cdx_bus.h +++ b/include/linux/cdx/cdx_bus.h @@ -21,11 +21,13 @@ struct cdx_controller; enum { + CDX_DEV_BUS_MASTER_CONF, CDX_DEV_RESET_CONF, }; struct cdx_device_config { u8 type; + bool bus_master_enable; }; typedef int (*cdx_scan_cb)(struct cdx_controller *cdx); @@ -170,4 +172,20 @@ extern struct bus_type cdx_bus_type; */ int cdx_dev_reset(struct device *dev); +/** + * cdx_set_master - enables bus-mastering for CDX device + * @cdx_dev: the CDX device to enable + * + * Return: 0 for success, -errno on failure + */ +int cdx_set_master(struct cdx_device *cdx_dev); + +/** + * cdx_clear_master - disables bus-mastering for CDX device + * @cdx_dev: the CDX device to disable + * + * Return: 0 for success, -errno on failure + */ +int cdx_clear_master(struct cdx_device *cdx_dev); + #endif /* _CDX_BUS_H_ */ diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index afc1369216d9..7f5fb010226d 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -277,8 +277,8 @@ struct vfio_region_info { #define VFIO_REGION_INFO_FLAG_CAPS (1 << 3) /* Info supports caps */ __u32 index; /* Region index */ __u32 cap_offset; /* Offset within info struct of first cap */ - __u64 size; /* Region size (bytes) */ - __u64 offset; /* Region offset from start of device fd */ + __aligned_u64 size; /* Region size (bytes) */ + __aligned_u64 offset; /* Region offset from start of device fd */ }; #define VFIO_DEVICE_GET_REGION_INFO _IO(VFIO_TYPE, VFIO_BASE + 8) @@ -294,8 +294,8 @@ struct vfio_region_info { #define VFIO_REGION_INFO_CAP_SPARSE_MMAP 1 struct vfio_region_sparse_mmap_area { - __u64 offset; /* Offset of mmap'able area within region */ - __u64 size; /* Size of mmap'able area */ + __aligned_u64 offset; /* Offset of mmap'able area within region */ + __aligned_u64 size; /* Size of mmap'able area */ }; struct vfio_region_info_cap_sparse_mmap { @@ -450,9 +450,9 @@ struct vfio_device_migration_info { VFIO_DEVICE_STATE_V1_RESUMING) __u32 reserved; - __u64 pending_bytes; - __u64 data_offset; - __u64 data_size; + __aligned_u64 pending_bytes; + __aligned_u64 data_offset; + __aligned_u64 data_size; }; /* @@ -476,7 +476,7 @@ struct vfio_device_migration_info { struct vfio_region_info_cap_nvlink2_ssatgt { struct vfio_info_cap_header header; - __u64 tgt; + __aligned_u64 tgt; }; /* @@ -816,7 +816,7 @@ struct vfio_device_gfx_plane_info { __u32 drm_plane_type; /* type of plane: DRM_PLANE_TYPE_* */ /* out */ __u32 drm_format; /* drm format of plane */ - __u64 drm_format_mod; /* tiled mode */ + __aligned_u64 drm_format_mod; /* tiled mode */ __u32 width; /* width of plane */ __u32 height; /* height of plane */ __u32 stride; /* stride of plane */ @@ -829,6 +829,7 @@ struct vfio_device_gfx_plane_info { __u32 region_index; /* region index */ __u32 dmabuf_id; /* dma-buf id */ }; + __u32 reserved; }; #define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14) @@ -863,9 +864,10 @@ struct vfio_device_ioeventfd { #define VFIO_DEVICE_IOEVENTFD_32 (1 << 2) /* 4-byte write */ #define VFIO_DEVICE_IOEVENTFD_64 (1 << 3) /* 8-byte write */ #define VFIO_DEVICE_IOEVENTFD_SIZE_MASK (0xf) - __u64 offset; /* device fd offset of write */ - __u64 data; /* data to be written */ + __aligned_u64 offset; /* device fd offset of write */ + __aligned_u64 data; /* data to be written */ __s32 fd; /* -1 for de-assignment */ + __u32 reserved; }; #define VFIO_DEVICE_IOEVENTFD _IO(VFIO_TYPE, VFIO_BASE + 16) @@ -1434,6 +1436,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 -------- */ /** @@ -1449,7 +1472,7 @@ struct vfio_iommu_type1_info { __u32 flags; #define VFIO_IOMMU_INFO_PGSIZES (1 << 0) /* supported page sizes info */ #define VFIO_IOMMU_INFO_CAPS (1 << 1) /* Info supports caps */ - __u64 iova_pgsizes; /* Bitmap of supported page sizes */ + __aligned_u64 iova_pgsizes; /* Bitmap of supported page sizes */ __u32 cap_offset; /* Offset within info struct of first cap */ __u32 pad; }; |