]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
virtio: new feature to detect IOMMU device quirk
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 18 Apr 2016 09:58:14 +0000 (12:58 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 1 Aug 2016 18:44:52 +0000 (21:44 +0300)
commit1a937693993ff10d7e80cca6ddd55f3000aa6376
tree77df81f5acf23d1c21240a625b5a8066b350e27a
parent37cf99e08c6fb4dcea0f9ad2b13b6daa8c76a711
virtio: new feature to detect IOMMU device quirk

The interaction between virtio and IOMMUs is messy.

On most systems with virtio, physical addresses match bus addresses,
and it doesn't particularly matter which one we use to program
the device.

On some systems, including Xen and any system with a physical device
that speaks virtio behind a physical IOMMU, we must program the IOMMU
for virtio DMA to work at all.

On other systems, including SPARC and PPC64, virtio-pci devices are
enumerated as though they are behind an IOMMU, but the virtio host
ignores the IOMMU, so we must either pretend that the IOMMU isn't
there or somehow map everything as the identity.

Add a feature bit to detect that quirk: VIRTIO_F_IOMMU_PLATFORM.

Any device with this feature bit set to 0 needs a quirk and has to be
passed physical addresses (as opposed to bus addresses) even though
the device is behind an IOMMU.

Note: it has to be a per-device quirk because for example, there could
be a mix of passed-through and virtual virtio devices. As another
example, some devices could be implemented by an out of process
hypervisor backend (in case of qemu vhost, or vhost-user) and so support
for an IOMMU needs to be coded up separately.

It would be cleanest to handle this in IOMMU core code, but that needs
per-device DMA ops. While we are waiting for that to be implemented, use
a work-around in virtio core.

Note: a "noiommu" feature is a quirk - add a wrapper to make
that clear.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/virtio/virtio_ring.c
include/linux/virtio_config.h
include/uapi/linux/virtio_config.h