qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Fam Zheng <fam@euphon.net>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org,
	Max Reitz <mreitz@redhat.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [RFC PATCH v5 2/4] util/vfio-helpers: Report error when IOMMU page size is not supported
Date: Wed, 9 Sep 2020 16:10:31 +0200	[thread overview]
Message-ID: <574d99fb-aaac-50e7-f2a3-37e31de2f341@redhat.com> (raw)
In-Reply-To: <20200909083815.wp2f3kmc2xxgjukm@dev>

On 9/9/20 10:38 AM, Fam Zheng wrote:
> On 2020-09-08 20:03, Philippe Mathieu-Daudé wrote:
>> This driver uses the host page size to align its memory regions,
>> but this size is not always compatible with the IOMMU. Add a
>> check if the size matches, and bails out with listing the sizes
>> the IOMMU supports.
>>
>> Example on Aarch64:
>>
>>  $ qemu-system-aarch64 -M virt -drive if=none,id=nvme0,file=nvme://0006:90:00.0/1,format=raw
>>  qemu-system-aarch64: -drive if=none,id=nvme0,file=nvme://0006:90:00.0/1,format=raw: Unsupported IOMMU page size: 4 KiB
>>  Available page size:
>>   64 KiB
>>   512 MiB
>>
>> Suggested-by: Alex Williamson <alex.williamson@redhat.com>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  util/vfio-helpers.c | 20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>>
>> diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
>> index 55b4107ce69..6d9ec7d365c 100644
>> --- a/util/vfio-helpers.c
>> +++ b/util/vfio-helpers.c
>> @@ -11,6 +11,7 @@
>>   */
>>  
>>  #include "qemu/osdep.h"
>> +#include "qemu/cutils.h"
>>  #include <sys/ioctl.h>
>>  #include <linux/vfio.h>
>>  #include "qapi/error.h"
>> @@ -316,6 +317,25 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device,
>>          ret = -errno;
>>          goto fail;
>>      }
>> +    if (!(iommu_info.flags & VFIO_IOMMU_INFO_PGSIZES)) {
>> +        error_setg(errp, "Failed to get IOMMU page size info");
>> +        ret = -errno;
> 
> We don't have errno here, do we?

Oops thanks, I'll replace by "ret = -EINVAL;".

> 
>> +        goto fail;
>> +    }
>> +    if (!extract64(iommu_info.iova_pgsizes,
>> +                   ctz64(qemu_real_host_page_size), 1)) {
>> +        g_autofree char *host_page_size = size_to_str(qemu_real_host_page_size);
>> +        error_setg(errp, "Unsupported IOMMU page size: %s", host_page_size);
>> +        error_append_hint(errp, "Available page size:\n");
>> +        for (int i = 0; i < 64; i++) {
>> +            if (extract64(iommu_info.iova_pgsizes, i, 1)) {
>> +                g_autofree char *iova_pgsizes = size_to_str(1UL << i);
>> +                error_append_hint(errp, " %s\n", iova_pgsizes);
> 
> Interesting... Since it's printing page size which is fairly low level,
> why not just plain (hex) numbers?

Because this error is reported to the user (not the developer)
and depends of the host/iommu.

If you don't mind I'll keep it as it (as the code is written).

Thank you for reviewing the series!

Phil.

> 
> Fam
> 
>> +            }
>> +        }
>> +        ret = -EINVAL;
>> +        goto fail;
>> +    }
>>  
>>      s->device = ioctl(s->group, VFIO_GROUP_GET_DEVICE_FD, device);
>>  
>> -- 
>> 2.26.2
>>
>>
> 



  reply	other threads:[~2020-09-09 14:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08 18:03 [RFC PATCH v5 0/4] util/vfio-helpers: Add support for multiple IRQs Philippe Mathieu-Daudé
2020-09-08 18:03 ` [RFC PATCH v5 1/4] util/vfio-helpers: Improve reporting unsupported IOMMU type Philippe Mathieu-Daudé
2020-09-08 18:03 ` [RFC PATCH v5 2/4] util/vfio-helpers: Report error when IOMMU page size is not supported Philippe Mathieu-Daudé
2020-09-09  8:38   ` Fam Zheng
2020-09-09 14:10     ` Philippe Mathieu-Daudé [this message]
2020-09-08 18:03 ` [RFC PATCH v5 3/4] util/vfio-helpers: Introduce qemu_vfio_pci_init_msix_irqs() Philippe Mathieu-Daudé
2020-09-08 18:03 ` [RFC PATCH v5 4/4] block/nvme: Use qemu_vfio_pci_init_msix_irqs() to initialize our IRQ Philippe Mathieu-Daudé
2020-09-09  8:42   ` Fam Zheng
2020-09-09  8:43 ` [RFC PATCH v5 0/4] util/vfio-helpers: Add support for multiple IRQs Fam Zheng

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=574d99fb-aaac-50e7-f2a3-37e31de2f341@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=fam@euphon.net \
    --cc=kwolf@redhat.com \
    --cc=mreitz@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).