From: Alex Williamson <alex.williamson@redhat.com>
To: Auger Eric <eric.auger@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PULL 3/3] vfio/common: Introduce vfio_set_irq_signaling helper
Date: Tue, 2 Jul 2019 09:55:46 -0600 [thread overview]
Message-ID: <20190702095546.11842fec@x1.home> (raw)
In-Reply-To: <63a37329-f892-ed5f-4929-e40dac25b64d@redhat.com>
On Tue, 2 Jul 2019 14:32:26 +0200
Auger Eric <eric.auger@redhat.com> wrote:
> Hi Peter,
>
> On 7/2/19 12:37 PM, Peter Maydell wrote:
> > On Thu, 13 Jun 2019 at 22:51, Alex Williamson
> > <alex.williamson@redhat.com> wrote:
> >>
> >> From: Eric Auger <eric.auger@redhat.com>
> >>
> >> The code used to assign an interrupt index/subindex to an
> >> eventfd is duplicated many times. Let's introduce an helper that
> >> allows to set/unset the signaling for an ACTION_TRIGGER,
> >> ACTION_MASK or ACTION_UNMASK action.
> >>
> >> In the error message, we now use errno in case of any
> >> VFIO_DEVICE_SET_IRQS ioctl failure.
> >>
> >> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> >> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> >> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> >> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> >
> > Hi; coverity reports (CID 1402196) a possible unchecked return value
> > in this code:
> >
> >
> >> @@ -592,26 +550,10 @@ static void vfio_msix_vector_release(PCIDevice *pdev, unsigned int nr)
> >> * be re-asserted on unmask. Nothing to do if already using QEMU mode.
> >> */
> >> if (vector->virq >= 0) {
> >> - int argsz;
> >> - struct vfio_irq_set *irq_set;
> >> - int32_t *pfd;
> >> -
> >> - argsz = sizeof(*irq_set) + sizeof(*pfd);
> >> -
> >> - irq_set = g_malloc0(argsz);
> >> - irq_set->argsz = argsz;
> >> - irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD |
> >> - VFIO_IRQ_SET_ACTION_TRIGGER;
> >> - irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
> >> - irq_set->start = nr;
> >> - irq_set->count = 1;
> >> - pfd = (int32_t *)&irq_set->data;
> >> + int32_t fd = event_notifier_get_fd(&vector->interrupt);
> >>
> >> - *pfd = event_notifier_get_fd(&vector->interrupt);
> >> -
> >> - ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set);
> >> -
> >> - g_free(irq_set);
> >> + vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX, nr,
> >> + VFIO_IRQ_SET_ACTION_TRIGGER, fd, NULL);
> >
> > In vfp_msix_vector_release() we call vfio_set_irq_signaling(),
> > but we don't check the returned error value, whereas in the other
> > 7 places we call the function we do check. Is there some missing
> > error handling here ?
>
> the difference with the other calls is that we pass a NULL errp here so
> we don't need to consume a potential error. Before the introduction of
> vfio_set_irq_signaling we had an ioctl call whose returned value was not
> tested either. So I think it properly translates what was done before.
> It seems we are willingly not producing any error message in that case.
> Alex, can you confirm?
When we're emulating writes to the MSI-X vector table we have no
failure path up to the guest. Real hardware cannot fail to enable a
vector that's available in hardware, thus we can either log the issue,
ignore the issue, or fault. I guess Coverity is simply noting that
other cases are tested while this is not, therefore we should either
explicitly ignore the return value with a cast to void or take this as
an opportunity to log the fault, which might be useful in debugging a
device that isn't working properly. Thanks,
Alex
next prev parent reply other threads:[~2019-07-02 17:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 21:33 [Qemu-devel] [PULL 0/3] vfio updates 2019-06-13 Alex Williamson
2019-06-13 21:33 ` [Qemu-devel] [PULL 1/3] vfio/pci: Hide Resizable BAR capability Alex Williamson
2019-06-13 21:33 ` [Qemu-devel] [PULL 2/3] vfio/pci: Allow MSI-X relocation to fixup bogus PBA Alex Williamson
2019-06-13 21:34 ` [Qemu-devel] [PULL 3/3] vfio/common: Introduce vfio_set_irq_signaling helper Alex Williamson
2019-07-02 10:37 ` Peter Maydell
2019-07-02 12:32 ` Auger Eric
2019-07-02 15:55 ` Alex Williamson [this message]
2019-07-02 15:58 ` Peter Maydell
2019-07-02 16:30 ` Alex Williamson
2019-07-02 16:33 ` Auger Eric
2019-06-14 9:04 ` [Qemu-devel] [PULL 0/3] vfio updates 2019-06-13 Peter Maydell
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=20190702095546.11842fec@x1.home \
--to=alex.williamson@redhat.com \
--cc=eric.auger@redhat.com \
--cc=peter.maydell@linaro.org \
--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).