Skip to content

VIRTIO-IOMMU/VFIO page size related fixes

Eric Auger qemu-arm qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 2 repliesIn review
  2. v12 patches 15 repliesSuperseded

Changes in v2 from the cover letter

- test bypass is set before transiently enabling the IOMMU MRs
- add Zhenzhong's R-b

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2virtio-iommu: Fix 64kB host page size VFIO device assignmenthw/virtio/trace-events hw/virtio/virtio-iommu.c include/hw/virtio/virtio-iommu.h+32 -21 reply
2/2virtio-iommu: Rework the traces in virtio_iommu_set_page_size_mask()hw/virtio/virtio-iommu.c+7 -120 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchZhenzhong DuanJean-Philippe Brucker
SeriesR-b T-b
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] VIRTIO-IOMMU/VFIO page size related fixes

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

This series can be found at:
https://github.com/eauger/qemu/tree/virtio-iommu-page-size-v2

History:
v1 -> v2:
- test bypass is set before transiently enabling the IOMMU MRs
- add Zhenzhong's R-b

Eric Auger (2):
virtio-iommu: Fix 64kB host page size VFIO device assignment
virtio-iommu: Rework the traces in virtio_iommu_set_page_size_mask()

 include/hw/virtio/virtio-iommu.h |  2 ++
 hw/virtio/virtio-iommu.c         | 50 +++++++++++++++++++++++---------
 hw/virtio/trace-events           |  1 +
 3 files changed, 39 insertions(+), 14 deletions(-)
Signature · 1 line
2.38.1