Skip to content

vhost: register and change IOMMU flag depending on ATS state

Viktor Prutyanov qemu-devel 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest2 patches 3 repliesIn review
  2. v42 patches 3 repliesSuperseded
  3. v33 patches 7 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 RFC4 patches7 repliesSuperseded
v1 RFC4 patches6 repliesSuperseded

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2vhost: register and change IOMMU flag depending on Device-TLB statehw/virtio/vhost-stub.c hw/virtio/vhost.c include/hw/virtio/vhost.h+31 -120 replies
2/2virtio-net: pass Device-TLB enable/disable events to vhosthw/net/virtio-net.c+1 -00 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchJason Wang
1/2A-b
2/2A-b

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

Read the v5 thread

Cover letter [PATCH v5 0/2] vhost: register and change IOMMU flag depending on ATS state

When IOMMU and vhost are enabled together, QEMU tracks IOTLB or Device-TLB unmap events depending on whether Device-TLB is enabled. But even if Device-TLB and PCI ATS is enabled, the guest can reject to use it. For example, this situation appears when Windows Server 2022 is running with intel-iommu with device-iotlb=on and virtio-net-pci with vhost=on. The guest implies that no address translation info cached in device IOTLB and doesn't send device IOTLB invalidation commands. So, it leads to irrelevant address translations in vhost-net in the host kernel. Therefore network frames from the guest in host tap interface contains wrong payload data.

This series adds checking of ATS state for proper unmap flag register (IOMMU_NOTIFIER_UNMAP or IOMMU_NOTIFIER_DEVIOTLB_UNMAP).

Tested on Windows Server 2022, Windows 11 and Fedora guests with
-device virtio-net-pci,bus=pci.3,netdev=nd0,iommu_platform=on,ats=on -netdev tap,id=nd0,ifname=tap1,script=no,downscript=no,vhost=on -device intel-iommu,intremap=on,eim=on,device-iotlb=on/off
Tested on Fedora guest with
-device virtio-iommu

v5: add vhost_toggle_device_iotlb to vhost-stub
v4: call vhost_toggle_device_iotlb regardless of vhost backend,
move vhost_started check to generic part
v3: call virtio_pci_ats_ctrl_trigger directly, remove
IOMMU_NOTIFIER_UNMAP fallbacks
v2: remove memory_region_iommu_notify_flags_changed, move trigger to
VirtioDeviceClass, use vhost_ops, use device_iotlb name

Viktor Prutyanov (2):
vhost: register and change IOMMU flag depending on Device-TLB state
virtio-net: pass Device-TLB enable/disable events to vhost

 hw/net/virtio-net.c       |  1 +
 hw/virtio/vhost-stub.c    |  4 ++++
 hw/virtio/vhost.c         | 38 ++++++++++++++++++++++++++------------
 include/hw/virtio/vhost.h |  1 +
 4 files changed, 32 insertions(+), 12 deletions(-)
Signature · 1 line
2.21.0