From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Eric Auger <eric.auger@redhat.com>,
eric.auger.pro@gmail.com, qemu-devel@nongnu.org,
qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org,
peter.maydell@linaro.org, clg@redhat.com, yanghliu@redhat.com,
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
Richard Henderson <richard.henderson@linaro.org>
Cc: alex.williamson@redhat.com, zhenzhong.duan@intel.com,
jasowang@redhat.com, pbonzini@redhat.com, berrange@redhat.com
Subject: Re: [PATCH v4 3/3] virtio-iommu: Change the default granule to the host page size
Date: Fri, 23 Feb 2024 09:08:44 +0100 [thread overview]
Message-ID: <bdab51cf-fca8-4fe7-9e47-31bd10259dfa@linaro.org> (raw)
In-Reply-To: <20240223074459.63422-4-eric.auger@redhat.com>
Hi Eric,
On 23/2/24 08:27, Eric Auger wrote:
> We used to set the default granule to 4KB but with VFIO assignment
> it makes more sense to use the actual host page size.
>
> Indeed when hotplugging a VFIO device protected by a virtio-iommu
> on a 64kB/64kB host/guest config, we current get a qemu crash:
>
> "vfio: DMA mapping failed, unable to continue"
>
> This is due to the hot-attached VFIO device calling
> memory_region_iommu_set_page_size_mask() with 64kB granule
> whereas the virtio-iommu granule was already frozen to 4KB on
> machine init done.
>
> Set the granule property to "host" and introduce a new compat.
>
> Note that the new default will prevent 4kB guest on 64kB host
> because the granule will be set to 64kB which would be larger
> than the guest page size. In that situation, the virtio-iommu
> driver fails on viommu_domain_finalise() with
> "granule 0x10000 larger than system page size 0x1000".
>
> In that case the workaround is to request 4K granule.
>
> The current limitation of global granule in the virtio-iommu
> should be removed and turned into per domain granule. But
> until we get this upgraded, this new default is probably
> better because I don't think anyone is currently interested in
> running a 4KB page size guest with virtio-iommu on a 64KB host.
> However supporting 64kB guest on 64kB host with virtio-iommu and
> VFIO looks a more important feature.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> hw/core/machine.c | 1 +
> hw/virtio/virtio-iommu.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 70ac96954c..38851df4b8 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -35,6 +35,7 @@
>
> GlobalProperty hw_compat_8_2[] = {
> { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "64" },
> + { TYPE_VIRTIO_IOMMU_PCI, "granule", "4K" },
IIUC the current value is qemu_target_page_mask(), not 4KiB.
Could this be an issue for arm / mips / mips / sparc64 guests?
> };
> const size_t hw_compat_8_2_len = G_N_ELEMENTS(hw_compat_8_2);
>
> diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
> index 0461b87ef2..e9e44a8ad8 100644
> --- a/hw/virtio/virtio-iommu.c
> +++ b/hw/virtio/virtio-iommu.c
> @@ -1558,7 +1558,7 @@ static Property virtio_iommu_properties[] = {
> DEFINE_PROP_BOOL("boot-bypass", VirtIOIOMMU, boot_bypass, true),
> DEFINE_PROP_UINT8("aw-bits", VirtIOIOMMU, aw_bits, 0),
> DEFINE_PROP_GRANULE_MODE("granule", VirtIOIOMMU, granule_mode,
> - GRANULE_MODE_4K),
> + GRANULE_MODE_HOST),
> DEFINE_PROP_END_OF_LIST(),
> };
>
next prev parent reply other threads:[~2024-02-23 8:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-23 7:27 [PATCH v4 0/3] VIRTIO-IOMMU: Set default granule to host page size Eric Auger
2024-02-23 7:27 ` [PATCH v4 1/3] qdev: Add a granule_mode property Eric Auger
2024-02-23 7:52 ` Philippe Mathieu-Daudé
2024-02-23 8:30 ` Eric Auger
2024-02-23 11:39 ` Philippe Mathieu-Daudé
2024-02-23 7:27 ` [PATCH v4 2/3] virtio-iommu: Add a granule property Eric Auger
2024-02-23 7:57 ` Philippe Mathieu-Daudé
2024-02-23 8:36 ` Eric Auger
2024-02-23 7:27 ` [PATCH v4 3/3] virtio-iommu: Change the default granule to the host page size Eric Auger
2024-02-23 8:08 ` Philippe Mathieu-Daudé [this message]
2024-02-23 8:38 ` Eric Auger
2024-02-23 11:33 ` Philippe Mathieu-Daudé
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=bdab51cf-fca8-4fe7-9e47-31bd10259dfa@linaro.org \
--to=philmd@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=eric.auger@redhat.com \
--cc=jasowang@redhat.com \
--cc=jean-philippe@linaro.org \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=yanghliu@redhat.com \
--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).