From: Peter Xu <peterx@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: mst@redhat.com, Wei.Huang2@amd.com, qemu-devel@nongnu.org,
dgilbert@redhat.com, Sriyash.Caculo@amd.com, pbonzini@redhat.com,
chao.gao@intel.com
Subject: Re: [PATCH 0/3] Disable vhost device IOTLB is IOMMU is not enabled
Date: Wed, 4 Aug 2021 12:08:39 -0400 [thread overview]
Message-ID: <YQq7h0OWlmQ+mX8z@t490s> (raw)
In-Reply-To: <20210804034803.1644-1-jasowang@redhat.com>
On Wed, Aug 04, 2021 at 11:48:00AM +0800, Jason Wang wrote:
> Hi:
>
> We currently try to enable device IOTLB when iommu_platform is
> set. This may lead unnecessary trasnsactions between qemu and vhost
> when vIOMMU is not used (which is the typical case for the encrypted
> VM).
>
> So patch tries to use transport specific method to detect the enalbing
> of vIOMMU and enable the device IOTLB only if vIOMMU is enalbed.
Just to mention that there's also the ordering requirement for e.g. vfio-pci
and the iommu device so far because vfio_realize() depends on vIOMMU being
realized too, so specifying "-device vfio-pci" before "-device intel-iommu"
will stop working, I think (see the similar pci_device_iommu_address_space()
call in vfio_realize()).
Do you think vhost can do the same to assume vIOMMU must be specified before
vhost? Then vhost can call pci_device_iommu_address_space() freely. It'll be
more gentle for vhost even when it's used wrong: instead of not working at all
(vfio-pci), vhost runs slower.
Currently libvirt should be able to guarantee that ordering so libvirt users
shouldn't need to bother. I think libvirt should also guarantee the vIOMMU
device to be created before all the rest devices, including virtio/vhost. But
need to check. If that's the case libvirt will naturally work for vhost too.
For the long term we may need to think about making device creation to be not
ordered by user cmdline input but still has a priority specified in the code
itself. Migration has something like that (MigrationPriority). I think we
just need something similar for general device realizations. Since vhost
raised the same need, I think that priority should bump up too.
The other concern is right now vhost has vhost_dev.dma_as but now we're not
using it for vhost_dev_has_iommu(). It's just a bit confusing as when to use
which.
What do you think?
Thanks,
--
Peter Xu
next prev parent reply other threads:[~2021-08-04 18:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-04 3:48 [PATCH 0/3] Disable vhost device IOTLB is IOMMU is not enabled Jason Wang
2021-08-04 3:48 ` [PATCH 1/3] virtio-bus: introduce iommu_enabled() Jason Wang
2021-08-04 3:48 ` [PATCH 2/3] virtio-pci: implement iommu_enabled() Jason Wang
2021-08-04 3:48 ` [PATCH 3/3] vhost: correctly detect the enabling IOMMU Jason Wang
2021-08-04 5:57 ` [PATCH 0/3] Disable vhost device IOTLB is IOMMU is not enabled Chao Gao
2021-08-04 16:08 ` Peter Xu [this message]
2021-08-05 1:46 ` Jason Wang
2021-08-05 3:08 ` Peter Xu
2021-08-05 7:26 ` Caculo, Sriyash
2021-09-02 5:46 ` Jason Wang
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=YQq7h0OWlmQ+mX8z@t490s \
--to=peterx@redhat.com \
--cc=Sriyash.Caculo@amd.com \
--cc=Wei.Huang2@amd.com \
--cc=chao.gao@intel.com \
--cc=dgilbert@redhat.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).