History

vfio: Define sparse mmap capability for regions

We can't always support mmap across an entire device region, for example we deny mmaps covering the MSI-X table of PCI devices, but we don't really have a way to report it. We expect the user to implicitly know this restriction. We also can't split the region because vfio-pci defines an API with fixed region index to BAR number mapping. We therefore define a new capability which lists areas within the region that may be mmap'd. In addition to the MSI-X case, this potentially enables in-kernel emulation and extensions to devices.

Alex Williamson committed 10 years ago

Commit ff63eb61 parent d7a8d5e1 file · +25 −1Browse files

Unified · Split

include/uapi/linux/vfio.h+25−1
@@ -221,13 +221,37 @@ struct vfio_region_info { · 220 unmodified lines
221221 #define VFIO_REGION_INFO_FLAG_READ (1 << 0) /* Region supports read */
222222 #define VFIO_REGION_INFO_FLAG_WRITE (1 << 1) /* Region supports write */
223223 #define VFIO_REGION_INFO_FLAG_MMAP (1 << 2) /* Region supports mmap */
224+#define VFIO_REGION_INFO_FLAG_CAPS (1 << 3) /* Info supports caps */
224225 __u32 index; /* Region index */
225− __u32 resv; /* Reserved for alignment */
226+ __u32 cap_offset; /* Offset within info struct of first cap */
226227 __u64 size; /* Region size (bytes) */
227228 __u64 offset; /* Region offset from start of device fd */
228229 };
229230 #define VFIO_DEVICE_GET_REGION_INFO _IO(VFIO_TYPE, VFIO_BASE + 8)
230231
232+/*
233+ * The sparse mmap capability allows finer granularity of specifying areas
234+ * within a region with mmap support. When specified, the user should only
235+ * mmap the offset ranges specified by the areas array. mmaps outside of the
236+ * areas specified may fail (such as the range covering a PCI MSI-X table) or
237+ * may result in improper device behavior.
238+ *
239+ * The structures below define version 1 of this capability.
240+ */
241+#define VFIO_REGION_INFO_CAP_SPARSE_MMAP 1
242+
243+struct vfio_region_sparse_mmap_area {
244+ __u64 offset; /* Offset of mmap'able area within region */
245+ __u64 size; /* Size of mmap'able area */
246+};
247+
248+struct vfio_region_info_cap_sparse_mmap {
249+ struct vfio_info_cap_header header;
250+ __u32 nr_areas;
251+ __u32 reserved;
252+ struct vfio_region_sparse_mmap_area areas[];
253+};
254+
231255 /**
232256 * VFIO_DEVICE_GET_IRQ_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 9,
233257 * struct vfio_irq_info)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t