From: Alex Williamson <alex.williamson@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,
Drew Jones <drjones@redhat.com>,
qemu-block@nongnu.org, Laurent Vivier <lvivier@redhat.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
Eric Auger <eric.auger@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [RFC PATCH v3 2/5] util/vfio-helpers: Report error on unsupported host architectures
Date: Tue, 18 Aug 2020 11:12:39 -0600 [thread overview]
Message-ID: <20200818111239.2f9b510c@x1.home> (raw)
In-Reply-To: <20200818164509.736367-3-philmd@redhat.com>
On Tue, 18 Aug 2020 18:45:06 +0200
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> The vfio-helpers implementation expects a TYPEv1 IOMMU, see
> qemu_vfio_init_pci:
>
> 263 if (!ioctl(s->container, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) {
> 264 error_setg_errno(errp, errno, "VFIO IOMMU check failed");
>
> Thus POWER SPAPR IOMMU is obviously not supported.
>
> The implementation only cares about host page size alignment
> (usually 4KB on X86), not the IOMMU one, which is be problematic
> on Aarch64, when 64MB page size is used. So Aarch64 is not
> supported neither.
>
> Report an error when the host architecture is different than X86:
>
> $ qemu-system-aarch64 \
> -drive file=nvme://0001:01:00.0/1,if=none,id=drive0 \
> -device virtio-blk-pci,drive=drive0
> qemu-system-aarch64: -drive file=nvme://0001:01:00.0/1,if=none,id=drive0: QEMU VFIO utility is not supported on this architecture
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> Cc: Eric Auger <eric.auger@redhat.com>
> Cc: Drew Jones <drjones@redhat.com>
> Cc: Laurent Vivier <lvivier@redhat.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> ---
> util/vfio-helpers.c | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
> index e399e330e26..60017936e3e 100644
> --- a/util/vfio-helpers.c
> +++ b/util/vfio-helpers.c
> @@ -420,14 +420,38 @@ static void qemu_vfio_open_common(QEMUVFIOState *s)
> qemu_ram_foreach_block(qemu_vfio_init_ramblock, s);
> }
>
> +/**
> + * Return if the host architecture is supported.
> + *
> + * aarch64: IOMMU page alignment not respected
> + * ppc64: SPAPR IOMMU window not configured
> + * x86-64: Only architecture validated
> + * other: Untested
> + */
> +static bool qemu_vfio_arch_supported(void)
> +{
> + bool supported = false;
> +
> +#if defined(HOST_X86_64)
> + supported = true;
> +#endif
> +
> + return supported;
> +}
Why does this need to be hard coded to specific architectures rather
than probing for type1 IOMMU support and looking at the iova_pgsizes
from VFIO_IOMMU_GET_INFO to see if there's a compatible size? It
requires us to get a bit deeper into the device initialization, but we
should still be able to unwind out of the device realize. Otherwise
we're throwing out aarch64 running of 4KB for no reason, right? Thanks,
Alex
> /**
> * Open a PCI device, e.g. "0000:00:01.0".
> */
> QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp)
> {
> int r;
> - QEMUVFIOState *s = g_new0(QEMUVFIOState, 1);
> + QEMUVFIOState *s;
>
> + if (!qemu_vfio_arch_supported()) {
> + error_setg(errp,
> + "QEMU VFIO utility is not supported on this architecture");
> + return NULL;
> + }
> + s = g_new0(QEMUVFIOState, 1);
> r = qemu_vfio_init_pci(s, device, errp);
> if (r) {
> g_free(s);
next prev parent reply other threads:[~2020-08-18 17:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-18 16:45 [RFC PATCH v3 0/5] util/vfio-helpers: Add support for multiple IRQs Philippe Mathieu-Daudé
2020-08-18 16:45 ` [RFC PATCH v3 1/5] block/nvme: Use an array of EventNotifier Philippe Mathieu-Daudé
2020-08-19 8:08 ` Stefan Hajnoczi
2020-08-19 15:55 ` Philippe Mathieu-Daudé
2020-08-18 16:45 ` [RFC PATCH v3 2/5] util/vfio-helpers: Report error on unsupported host architectures Philippe Mathieu-Daudé
2020-08-18 17:12 ` Alex Williamson [this message]
2020-08-18 17:26 ` Philippe Mathieu-Daudé
2020-08-18 16:45 ` [RFC PATCH v3 3/5] util/vfio-helpers: Store eventfd using int32_t type Philippe Mathieu-Daudé
2020-08-18 16:45 ` [RFC PATCH v3 4/5] util/vfio-helpers: Introduce qemu_vfio_pci_init_msix_irqs() Philippe Mathieu-Daudé
2020-08-18 17:25 ` Alex Williamson
2020-08-18 16:45 ` [RFC PATCH v3 5/5] block/nvme: Use qemu_vfio_pci_init_msix_irqs() to initialize our IRQ 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=20200818111239.2f9b510c@x1.home \
--to=alex.williamson@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=drjones@redhat.com \
--cc=eric.auger@redhat.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=lvivier@redhat.com \
--cc=mreitz@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).