qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Viktor Prutyanov <viktor@daynix.com>
Cc: jasowang@redhat.com, qemu-devel@nongnu.org, yan@daynix.com,
	yuri.benditovich@daynix.com
Subject: Re: [PATCH v4 0/2] vhost: register and change IOMMU flag depending on ATS state
Date: Thu, 22 Jun 2023 18:54:28 -0400	[thread overview]
Message-ID: <20230622185347-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20230525125742.4190-1-viktor@daynix.com>

On Thu, May 25, 2023 at 03:57:40PM +0300, Viktor Prutyanov wrote:
> 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

Fails build on windows hosts:

https://gitlab.com/mstredhat/qemu/-/pipelines/909063579/failures

C:\GitLab-Runner\builds\mstredhat\qemu\output/../hw/net/virtio-net.c:3954: undefined reference to `vhost_toggle_device_iotlb'




> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2001312
> 
> 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.c         | 38 ++++++++++++++++++++++++++------------
>  include/hw/virtio/vhost.h |  1 +
>  3 files changed, 28 insertions(+), 12 deletions(-)
> 
> -- 
> 2.21.0



      parent reply	other threads:[~2023-06-22 22:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25 12:57 [PATCH v4 0/2] vhost: register and change IOMMU flag depending on ATS state Viktor Prutyanov
2023-05-25 12:57 ` [PATCH v4 1/2] vhost: register and change IOMMU flag depending on Device-TLB state Viktor Prutyanov
2023-05-26  4:07   ` Jason Wang
2023-05-25 12:57 ` [PATCH v4 2/2] virtio-net: pass Device-TLB enable/disable events to vhost Viktor Prutyanov
2023-05-26  4:07   ` Jason Wang
2023-06-22 22:54 ` Michael S. Tsirkin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230622185347-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=viktor@daynix.com \
    --cc=yan@daynix.com \
    --cc=yuri.benditovich@daynix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).