Skip to content

VIRTIO-IOMMU/VFIO page size related fixes

Eric Auger requested to merge eauger1/centos-qemu-kvm:virtio-iommu-pgsize into c9s

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2211609 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2211634 Upstream Status: Merged Brew: http://brewweb.engineering.redhat.com/brew/taskinfo?taskID=53834057 Tested: VFIO assignment with 64kB host

When assigning a host device and protecting it with the virtio-iommu we may end up with qemu crashing with

qemu-kvm: virtio-iommu page mask 0xfffffffffffff000 is incompatible
with mask 0x20010000
qemu: hardware error: vfio: DMA mapping failed, unable to continue

This happens if the host features a 64kB page size and constraints the physical IOMMU to use a 64kB page size. By default 4kB granule is used by the qemu virtio-iommu device and this latter becomes aware of the 64kB requirement too late, after the machine init, when the vfio device domain is attached. virtio_iommu_set_page_size_mask() fails and this causes vfio_listener_region_add() to end up with hw_error(). Currently the granule is global to all domains.

To work around this issue, despite the IOMMU MR may be bypassed, we transiently enable it on machine init done to get vfio_listener_region_add and virtio_iommu_set_page_size_mask called ealier, before the domain attach. That way the page size requirement can be taken into account before the guest gets started.

Also get benefit of this series to do some cleanups in some traces which may confuse the end user.

Best Regards

Eric

Edited by Eric Auger

Merge request reports