All of lore.kernel.org
 help / color / mirror / Atom feed
From: gchen chen <gchen.guomin@gmail.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, guomin_chen@sina.com
Subject: Re: [PATCH] vfio/pci: Clear token on bypass registration failure
Date: Wed, 11 Nov 2020 10:15:04 +0800	[thread overview]
Message-ID: <CAEEwsfR_4pm9mZ81rAYPZ6dY_avfW=xuBx3mOKFD5uoUTOd_uQ@mail.gmail.com> (raw)
In-Reply-To: <160311419702.25406.2436004222669241097.stgit@gimli.home>

Thanks a lot.

Alex Williamson <alex.williamson@redhat.com> 于2020年10月19日周一 下午9:30写道:
>
> The eventfd context is used as our irqbypass token, therefore if an
> eventfd is re-used, our token is the same.  The irqbypass code will
> return an -EBUSY in this case, but we'll still attempt to unregister
> the producer, where if that duplicate token still exists, results in
> removing the wrong object.  Clear the token of failed producers so
> that they harmlessly fall out when unregistered.
>
> Fixes: 6d7425f109d2 ("vfio: Register/unregister irq_bypass_producer")
> Reported-by: guomin chen <guomin_chen@sina.com>
> Tested-by: guomin chen <guomin_chen@sina.com>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>  drivers/vfio/pci/vfio_pci_intrs.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
> index 1d9fb2592945..869dce5f134d 100644
> --- a/drivers/vfio/pci/vfio_pci_intrs.c
> +++ b/drivers/vfio/pci/vfio_pci_intrs.c
> @@ -352,11 +352,13 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
>         vdev->ctx[vector].producer.token = trigger;
>         vdev->ctx[vector].producer.irq = irq;
>         ret = irq_bypass_register_producer(&vdev->ctx[vector].producer);
> -       if (unlikely(ret))
> +       if (unlikely(ret)) {
>                 dev_info(&pdev->dev,
>                 "irq bypass producer (token %p) registration fails: %d\n",
>                 vdev->ctx[vector].producer.token, ret);
>
> +               vdev->ctx[vector].producer.token = NULL;
> +       }
>         vdev->ctx[vector].trigger = trigger;
>
>         return 0;
>

      reply	other threads:[~2020-11-11  2:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 13:30 [PATCH] vfio/pci: Clear token on bypass registration failure Alex Williamson
2020-11-11  2:15 ` gchen chen [this message]

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='CAEEwsfR_4pm9mZ81rAYPZ6dY_avfW=xuBx3mOKFD5uoUTOd_uQ@mail.gmail.com' \
    --to=gchen.guomin@gmail.com \
    --cc=alex.williamson@redhat.com \
    --cc=guomin_chen@sina.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.