History

vfio: Define capability chains

We have a few cases where we need to extend the data returned from the INFO ioctls in VFIO. For instance we already have devices exposed through vfio-pci where VFIO_DEVICE_GET_REGION_INFO reports the region as mmap-capable, but really only supports sparse mmaps, avoiding the MSI-X table. If we wanted to provide in-kernel emulation or extended functionality for devices, we'd also want the ability to tell the user not to mmap various regions, rather than forcing them to figure it out on their own. Another example is VFIO_IOMMU_GET_INFO. We'd really like to expose the actual IOVA capabilities of the IOMMU rather than letting the user assume the address space they have available to them. We could add IOVA base and size fields to struct vfio_iommu_type1_info, but what if we have multiple IOVA ranges. For instance x86 uses a range of addresses at 0xfee00000 for MSI vectors. These typically are not available for standard DMA IOVA mappings and splits our available IOVA space into two ranges. POWER systems have both an IOVA window below 4G as well as dynamic data window which they can use to remap all of guest memory. Representing variable sized arrays within a fixed structure makes it very difficult to parse, we'd therefore like to put this data beyond fixed fields within the data structures. One way to do this is to emulate capabilities in PCI configuration space. A new flag indciates whether capabilties are supported and a new fixed field reports the offset of the first entry. Users can then walk the chain to find capabilities, adding capabilities does not require additional fields in the fixed structure, and parsing variable sized data becomes trivial. This patch outlines the theory and base header structure, which should be shared by all future users.

Alex Williamson committed 10 years ago

Commit c84982a1 parent 7c435b41 file · +27 −0Browse files

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

Unified · Split

include/uapi/linux/vfio.h+27−0
@@ -59,6 +59,33 @@ · 58 unmodified lines
5959 #define VFIO_TYPE (';')
6060 #define VFIO_BASE 100
6161
62+/*
63+ * For extension of INFO ioctls, VFIO makes use of a capability chain
64+ * designed after PCI/e capabilities. A flag bit indicates whether
65+ * this capability chain is supported and a field defined in the fixed
66+ * structure defines the offset of the first capability in the chain.
67+ * This field is only valid when the corresponding bit in the flags
68+ * bitmap is set. This offset field is relative to the start of the
69+ * INFO buffer, as is the next field within each capability header.
70+ * The id within the header is a shared address space per INFO ioctl,
71+ * while the version field is specific to the capability id. The
72+ * contents following the header are specific to the capability id.
73+ */
74+struct vfio_info_cap_header {
75+ __u16 id; /* Identifies capability */
76+ __u16 version; /* Version specific to the capability ID */
77+ __u32 next; /* Offset of next capability */
78+};
79+
80+/*
81+ * Callers of INFO ioctls passing insufficiently sized buffers will see
82+ * the capability chain flag bit set, a zero value for the first capability
83+ * offset (if available within the provided argsz), and argsz will be
84+ * updated to report the necessary buffer size. For compatibility, the
85+ * INFO ioctl will not report error in this case, but the capability chain
86+ * will not be available.
87+ */
88+
6289 /* -------- IOCTLs for VFIO file descriptor (/dev/vfio/vfio) -------- */
6390
6491 /**

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