History

vfio: Define device specific region type capability

To this point vfio has only provided an interface to the user that allows them to determine the number of regions and specifics about each region. What the region represents is left to the vfio bus driver. vfio-pci chooses to use fixed indexes for fixed resources, index 0 is BAR0, 1 is BAR1,... 7 is config space, etc. This works pretty well since all PCI devices have these regions, even if they don't necessarily populate all of them. Then we start to add things like VGA, which only certain device even support. We added this the same way, but now we've wasted a region index, and due to our offset implementation the corresponding address space, for all devices. Rather than continuing that process, let's try to make regions self describing by including a capability that defines their type. For vfio-pci we'll make the current VFIO_PCI_NUM_REGIONS fixed, defining the end of the static indexes and the beginning of self describing regions.

Alex Williamson committed 10 years ago

Commit c7bb4cb1 parent 188ad9d1 file · +30 −1Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/linux/vfio.h+30−1
@@ -252,6 +252,34 @@ struct vfio_region_info_cap_sparse_mmap { · 251 unmodified lines
252 struct vfio_region_sparse_mmap_area areas[];252 struct vfio_region_sparse_mmap_area areas[];
253};253};
254 254
255/*
256 * The device specific type capability allows regions unique to a specific
257 * device or class of devices to be exposed. This helps solve the problem for
258 * vfio bus drivers of defining which region indexes correspond to which region
259 * on the device, without needing to resort to static indexes, as done by
260 * vfio-pci. For instance, if we were to go back in time, we might remove
261 * VFIO_PCI_VGA_REGION_INDEX and let vfio-pci simply define that all indexes
262 * greater than or equal to VFIO_PCI_NUM_REGIONS are device specific and we'd
263 * make a "VGA" device specific type to describe the VGA access space. This
264 * means that non-VGA devices wouldn't need to waste this index, and thus the
265 * address space associated with it due to implementation of device file
266 * descriptor offsets in vfio-pci.
267 *
268 * The current implementation is now part of the user ABI, so we can't use this
269 * for VGA, but there are other upcoming use cases, such as opregions for Intel
270 * IGD devices and framebuffers for vGPU devices. We missed VGA, but we'll
271 * use this for future additions.
272 *
273 * The structure below defines version 1 of this capability.
274 */
275#define VFIO_REGION_INFO_CAP_TYPE 2
276
277struct vfio_region_info_cap_type {
278 struct vfio_info_cap_header header;
279 __u32 type; /* global per bus driver */
280 __u32 subtype; /* type specific */
281};
282
255/**283/**
256 * VFIO_DEVICE_GET_IRQ_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 9,284 * VFIO_DEVICE_GET_IRQ_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 9,
257 * struct vfio_irq_info)285 * struct vfio_irq_info)
@@ -387,7 +415,8 @@ enum { · 129 unmodified lines
387 * between described ranges are unimplemented.415 * between described ranges are unimplemented.
388 */416 */
389 VFIO_PCI_VGA_REGION_INDEX,417 VFIO_PCI_VGA_REGION_INDEX,
390 VFIO_PCI_NUM_REGIONS418 VFIO_PCI_NUM_REGIONS = 9 /* Fixed user ABI, region indexes >=9 use */
419 /* device specific cap to define content. */
391};420};
392 421
393enum {422enum {

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