• Michael S. Tsirkin's avatar
    virtio: new feature to detect IOMMU device quirk · 1a937693
    Michael S. Tsirkin authored
    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: default avatarMichael S. Tsirkin <mst@redhat.com>
    1a937693
virtio_config.h 11.9 KB