qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] VIRTIO-IOMMU/VFIO: Don't assume 64b IOVA space
@ 2023-09-04  8:03 Eric Auger
  2023-09-04  8:03 ` [PATCH 01/13] memory: Let ReservedRegion use Range Eric Auger
                   ` (14 more replies)
  0 siblings, 15 replies; 29+ messages in thread
From: Eric Auger @ 2023-09-04  8:03 UTC (permalink / raw)
  To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, alex.williamson,
	clg, jean-philippe, mst, pbonzini
  Cc: peter.maydell, peterx, david, philmd

On x86, when assigning VFIO-PCI devices protected with virtio-iommu
we encounter the case where the guest tries to map IOVAs beyond 48b
whereas the physical VTD IOMMU only supports 48b. This ends up with
VFIO_MAP_DMA failures at qemu level because at kernel level,
vfio_iommu_iova_dma_valid() check returns false on vfio_map_do_map().

This is due to the fact the virtio-iommu currently unconditionally
exposes an IOVA range of 64b through its config input range fields.

This series removes this assumption by retrieving the usable IOVA
regions through the VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE UAPI when
a VFIO device is attached. This info is communicated to the
virtio-iommu memory region, transformed into the inversed info, ie.
the host reserved IOVA regions. Then those latter are combined with the
reserved IOVA regions set though the virtio-iommu reserved-regions
property. That way, the guest virtio-iommu driver, unchanged, is
able to probe the whole set of reserved regions and prevent any IOVA
belonging to those ranges from beeing used, achieving the original goal.

Best Regards

Eric

This series can be found at:
https://github.com/eauger/qemu/tree/virtio-iommu_geometry_v1

Eric Auger (13):
  memory: Let ReservedRegion use Range
  memory: Introduce memory_region_iommu_set_iova_ranges
  vfio: Collect container iova range info
  virtio-iommu: Rename reserved_regions into prop_resv_regions
  virtio-iommu: Introduce per IOMMUDevice reserved regions
  range: Introduce range_inverse_array()
  virtio-iommu: Implement set_iova_ranges() callback
  range: Make range_compare() public
  util/reserved-region: Add new ReservedRegion helpers
  virtio-iommu: Consolidate host reserved regions and property set ones
  test: Add some tests for range and resv-mem helpers
  virtio-iommu: Resize memory region according to the max iova info
  vfio: Remove 64-bit IOVA address space assumption

 include/exec/memory.h            |  30 ++++-
 include/hw/vfio/vfio-common.h    |   2 +
 include/hw/virtio/virtio-iommu.h |   7 +-
 include/qemu/range.h             |   9 ++
 include/qemu/reserved-region.h   |  32 +++++
 hw/core/qdev-properties-system.c |   9 +-
 hw/vfio/common.c                 |  70 ++++++++---
 hw/virtio/virtio-iommu-pci.c     |   8 +-
 hw/virtio/virtio-iommu.c         |  85 +++++++++++--
 softmmu/memory.c                 |  15 +++
 tests/unit/test-resv-mem.c       | 198 +++++++++++++++++++++++++++++++
 util/range.c                     |  41 ++++++-
 util/reserved-region.c           |  94 +++++++++++++++
 hw/virtio/trace-events           |   1 +
 tests/unit/meson.build           |   1 +
 util/meson.build                 |   1 +
 16 files changed, 562 insertions(+), 41 deletions(-)
 create mode 100644 include/qemu/reserved-region.h
 create mode 100644 tests/unit/test-resv-mem.c
 create mode 100644 util/reserved-region.c

-- 
2.41.0



^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2023-09-14 13:39 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-04  8:03 [PATCH 00/13] VIRTIO-IOMMU/VFIO: Don't assume 64b IOVA space Eric Auger
2023-09-04  8:03 ` [PATCH 01/13] memory: Let ReservedRegion use Range Eric Auger
2023-09-04  8:12   ` Philippe Mathieu-Daudé
2023-09-04 14:22     ` Eric Auger
2023-09-06  7:17   ` David Hildenbrand
2023-09-11 18:40   ` Peter Xu
2023-09-04  8:03 ` [PATCH 02/13] memory: Introduce memory_region_iommu_set_iova_ranges Eric Auger
2023-09-11 18:41   ` Peter Xu
2023-09-14 13:38   ` David Hildenbrand
2023-09-04  8:03 ` [PATCH 03/13] vfio: Collect container iova range info Eric Auger
2023-09-04  8:03 ` [PATCH 04/13] virtio-iommu: Rename reserved_regions into prop_resv_regions Eric Auger
2023-09-04  8:03 ` [PATCH 05/13] virtio-iommu: Introduce per IOMMUDevice reserved regions Eric Auger
2023-09-04  8:03 ` [PATCH 06/13] range: Introduce range_inverse_array() Eric Auger
2023-09-04  8:18   ` Philippe Mathieu-Daudé
2023-09-04 14:21     ` Eric Auger
2023-09-04  8:03 ` [PATCH 07/13] virtio-iommu: Implement set_iova_ranges() callback Eric Auger
2023-09-04  8:03 ` [PATCH 08/13] range: Make range_compare() public Eric Auger
2023-09-04  8:19   ` Philippe Mathieu-Daudé
2023-09-04  8:03 ` [PATCH 09/13] util/reserved-region: Add new ReservedRegion helpers Eric Auger
2023-09-04  8:03 ` [PATCH 10/13] virtio-iommu: Consolidate host reserved regions and property set ones Eric Auger
2023-09-04  8:03 ` [PATCH 11/13] test: Add some tests for range and resv-mem helpers Eric Auger
2023-09-04  8:03 ` [PATCH 12/13] virtio-iommu: Resize memory region according to the max iova info Eric Auger
2023-09-04  8:21   ` Philippe Mathieu-Daudé
2023-09-04  8:03 ` [PATCH 13/13] vfio: Remove 64-bit IOVA address space assumption Eric Auger
2023-09-05  8:22 ` [PATCH 00/13] VIRTIO-IOMMU/VFIO: Don't assume 64b IOVA space YangHang Liu
2023-09-05  9:15   ` Eric Auger
2023-09-05  9:50   ` Eric Auger
2023-09-05 17:55 ` Alex Williamson
2023-09-06  6:40   ` Eric Auger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).