What is vfio driver?

What is vfio driver?

The VFIO driver is an IOMMU/device agnostic framework for exposing direct device access to userspace, in a secure, IOMMU protected environment. In other words, this allows safe 2, non-privileged, userspace drivers.

What is vfio?

VFIO stands for Virtual Function I/O and is a new user-level driver framework for Linux. It replaces the traditional KVM PCI Pass-Through device assignment. The VFIO driver exposes direct device access to user space in a secure memory (IOMMU) protected environment.

Why vfio?

VFIO allows you to (near) literally slice your machine up to run additional OSes. For most users that want to run VFIO, their day to day OS is likely linux, but the need to run Windows (or OSX) at near native speeds (3-5% performance hit) is still very important.

What is IOMMU support?

In computing, an input–output memory management unit (IOMMU) is a memory management unit (MMU) that connects a direct-memory-access–capable (DMA-capable) I/O bus to the main memory. Some units also provide memory protection from faulty or malicious devices.

What is Uio driver?

The Userspace I/O framework (UIO) was introduced in Linux 2.6. 23 and allows device drivers to be writ- ten almost entirely in userspace. UIO is suitable for hardware that does not fit into other kernel sub- systems, like fieldbus cards, industrial I/O cards, or A/D converters.

Why is IOMMU needed?

The Input-Output Memory Management Unit (IOMMU) is a hardware component that performs address translation from I/O device virtual addresses to physical addresses. This hardware-assisted I/O address translation dramatically improves the system performance within a virtual environment.

What is user space driver?

User space driver can directly mmap() /dev/mem memory to their virtual address space and need no context switching. Userspace driver cannot have interrupt handlers implemented (They have to poll for interrupt). Userspace driver cannot perform DMA (As DMA capable memory can be allocated from kernel space).

Why do I need a vfio driver for IOMMU?

If the IOMMU group contains multiple devices, each will need to be bound to a VFIO driver before operations on the VFIO group are allowed (it’s also sufficient to only unbind the device from host drivers if a VFIO driver is unavailable; this will make the group available, but not that particular device).

What does the vfio device API do in Linux?

The VFIO device API includes ioctls for describing the device, the I/O regions and their read/write/mmap offsets on the device descriptor, as well as mechanisms for describing and registering interrupt notifications. Assume user wants to access PCI device 0000:06:0d.0: This device is therefore in IOMMU group 26.

Why do I get an error message when I try to use vfio?

If when attempting to use VFIO you see an error message indicating the group is not viable, it relates to this rule that all of the devices in the group need to be bound to an appropriate host driver.

Can a vfio group be attached to a container?

With a group (or groups) attached to a container, the remaining ioctls become available, enabling access to the VFIO IOMMU interfaces. Additionally, it now becomes possible to get file descriptors for each device within a group using an ioctl on the VFIO group file descriptor.