From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com,
jean-philippe@linaro.org, zhenzhong.duan@intel.com
Cc: alex.williamson@redhat.com, clg@redhat.com,
bharat.bhushan@nxp.com, peter.maydell@linaro.org
Subject: [PATCH v2 0/2] VIRTIO-IOMMU/VFIO page size related fixes
Date: Wed, 5 Jul 2023 18:51:16 +0200 [thread overview]
Message-ID: <20230705165118.28194-1-eric.auger@redhat.com> (raw)
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(-)
--
2.38.1
next reply other threads:[~2023-07-05 16:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-05 16:51 Eric Auger [this message]
2023-07-05 16:51 ` [PATCH v2 1/2] virtio-iommu: Fix 64kB host page size VFIO device assignment Eric Auger
2023-07-06 9:25 ` Duan, Zhenzhong
2023-07-05 16:51 ` [PATCH v2 2/2] virtio-iommu: Rework the traces in virtio_iommu_set_page_size_mask() Eric Auger
2023-07-07 15:25 ` [PATCH v2 0/2] VIRTIO-IOMMU/VFIO page size related fixes Jean-Philippe Brucker
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=20230705165118.28194-1-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=bharat.bhushan@nxp.com \
--cc=clg@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=jean-philippe@linaro.org \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=zhenzhong.duan@intel.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).