On Fri, Apr 24, 2026 at 03:31:53PM -0300, Jason Gunthorpe wrote:
On Thu, Apr 16, 2026 at 06:17:52AM -0700, Matt Evans wrote:
A new field is reserved in vfio_device_feature_dma_buf.flags to request CPU-facing memory type attributes for mmap()s of the buffer. Add a flag VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_WC, which results in WC PTEs for the DMABUF's BAR region.
Signed-off-by: Matt Evans mattev@meta.com
drivers/vfio/pci/vfio_pci_dmabuf.c | 15 +++++++++++++-- drivers/vfio/pci/vfio_pci_priv.h | 1 + include/uapi/linux/vfio.h | 12 +++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-)
Nice and simple
Reviewed-by: Jason Gunthorpe jgg@nvidia.com
@@ -1549,8 +1551,12 @@ struct vfio_region_dma_range { struct vfio_device_feature_dma_buf { __u32 region_index; __u32 open_flags;
- __u32 flags;
- __u32 nr_ranges;
- __u32 flags;
- /* Flags sub-field reserved for attribute enum */
+#define VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_MASK (0xfU << 28) +#define VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_UC (0 << 28) +#define VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_WC (1 << 28)
- __u32 nr_ranges;
Alex,
The TPH proposal extends the flags field in a similar way, but I suggested a different approach to conserve bits. At the moment, we spend three bits on a single feature, which feels wasteful.
What do you think? https://lore.kernel.org/all/20260409120415.GF86584@unreal/
Thanks