]> git.proxmox.com Git - mirror_qemu.git/commit
virtio-iommu: Fix 64kB host page size VFIO device assignment
authorEric Auger <eric.auger@redhat.com>
Wed, 5 Jul 2023 16:51:17 +0000 (18:51 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 10 Jul 2023 22:59:32 +0000 (18:59 -0400)
commit94df5b2180d61fb2ee2b04cc007981e58b6479a9
treed40aa02e276996b7840807bc52f597f5e39306d4
parentca92eb5defcf9d1c2106341744a73a03cf26e824
virtio-iommu: Fix 64kB host page size VFIO device assignment

When running on a 64kB page size host and protecting a VFIO device
with the virtio-iommu, qemu crashes with this kind of message:

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

This is due to the fact the IOMMU MR corresponding to the VFIO device
is enabled very late on domain attach, after the machine init.
The device reports a minimal 64kB page size but it is too late to be
applied. virtio_iommu_set_page_size_mask() fails and this causes
vfio_listener_region_add() to end up with hw_error();

To work around this issue, we transiently enable the IOMMU MR on
machine init to collect the page size requirements and then restore
the bypass state.

Fixes: 90519b9053 ("virtio-iommu: Add bypass mode support to assigned device")
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Message-Id: <20230705165118.28194-2-eric.auger@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
hw/virtio/trace-events
hw/virtio/virtio-iommu.c
include/hw/virtio/virtio-iommu.h