From: "Michael S. Tsirkin" <mst@redhat.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org,
Su Hui <suhui@nfschina.com>
Subject: Re: [PATCH] virtio_ring: add an error code check in virtqueue_resize
Date: Mon, 23 Oct 2023 07:18:38 -0400 [thread overview]
Message-ID: <20231023071752-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1698058354.8316164-2-xuanzhuo@linux.alibaba.com>
On Mon, Oct 23, 2023 at 06:52:34PM +0800, Xuan Zhuo wrote:
> On Mon, 23 Oct 2023 17:52:02 +0800, Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
> > On Mon, 23 Oct 2023 17:50:46 +0800, Su Hui <suhui@nfschina.com> wrote:
> > > On 2023/10/23 13:46, Xuan Zhuo wrote:
> > > >>>>>>>> Well, what are the cases where it can happen practically?
> > > >>>>>>> Device error. Such as vp_active_vq()
> > > >>>>>>>
> > > >>>>>>> Thanks.
> > > >>>>>> Hmm interesting. OK. But do callers know to recover?
> > > >>>>> No.
> > > >>>>>
> > > >>>>> So I think WARN + broken is suitable.
> > > >>>>>
> > > >>>>> Thanks.
> > > >>>> Sorry for the late, is the following code okay?
> > > >>>>
> > > >>>> @@ -2739,7 +2739,7 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
> > > >>>> void (*recycle)(struct virtqueue *vq, void *buf))
> > > >>>> {
> > > >>>> struct vring_virtqueue *vq = to_vvq(_vq);
> > > >>>> - int err;
> > > >>>> + int err, err_reset;
> > > >>>>
> > > >>>> if (num > vq->vq.num_max)
> > > >>>> return -E2BIG;
> > > >>>> @@ -2759,7 +2759,15 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
> > > >>>> else
> > > >>>> err = virtqueue_resize_split(_vq, num);
> > > >>>>
> > > >>>> - return virtqueue_enable_after_reset(_vq);
> > > >>>> + err_reset = virtqueue_enable_after_reset(_vq);
> > > >>>> +
> > > >>>> + if (err) {
> > > >>> No err.
> > > >>>
> > > >>> err is not important.
> > > >>> You can remove that.
> > > >> Emm, I'm a little confused that which code should I remove ?
> > > >>
> > > >>
> > > >> like this:
> > > >> if (vq->packed_ring)
> > > >> virtqueue_resize_packed(_vq, num);
> > > >> else
> > > >> virtqueue_resize_split(_vq, num);
> > > >>
> > > >> And we should set broken and warn inside virtqueue_enable_after_reset()?
> > >
> > > In my opinion, we should return the error code of virtqueue_resize_packed() / virtqueue_resize_split().
> > > But if this err is not important, this patch makes no sense.
> > > Maybe I misunderstand somewhere...
> > > If you think it's worth sending a patch, you can send it :).(I'm not familiar with this code).
> >
> > OK.
>
> Hi Michael,
>
> The queue reset code is wrote with the CONFIG_VIRTIO_HARDEN_NOTIFICATION.
>
> When we disable the vq, the broken is true until we re-enable it.
>
> So when we re-enable it fail, the vq is broken status.
>
> Normally, this just happens on the buggy device.
> So I think that is enough.
>
> Thanks.
I don't know what to do about CONFIG_VIRTIO_HARDEN_NOTIFICATION.
It's known to be broken and it does not look like there's
active effort to revive it - should we just drop it for now?
>
> static int vp_modern_disable_vq_and_reset(struct virtqueue *vq)
> {
> [...]
>
> vp_modern_set_queue_reset(mdev, vq->index);
>
> [...]
>
> #ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION
> ->> __virtqueue_break(vq);
> #endif
>
> [...]
> }
>
> static int vp_modern_enable_vq_after_reset(struct virtqueue *vq)
> {
> [...]
>
> if (vp_modern_get_queue_reset(mdev, index))
> return -EBUSY;
>
> if (vp_modern_get_queue_enable(mdev, index))
> return -EBUSY;
>
> err = vp_active_vq(vq, info->msix_vector);
> if (err)
> return err;
>
> }
>
> [...]
>
> #ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION
> ->> __virtqueue_unbreak(vq);
> #endif
>
> [...]
> }
>
>
>
>
> >
> > Thanks.
> >
> >
> > >
> > > Thanks,
> > > Su Hui
> > >
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: Su Hui <suhui@nfschina.com>,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] virtio_ring: add an error code check in virtqueue_resize
Date: Mon, 23 Oct 2023 07:18:38 -0400 [thread overview]
Message-ID: <20231023071752-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1698058354.8316164-2-xuanzhuo@linux.alibaba.com>
On Mon, Oct 23, 2023 at 06:52:34PM +0800, Xuan Zhuo wrote:
> On Mon, 23 Oct 2023 17:52:02 +0800, Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
> > On Mon, 23 Oct 2023 17:50:46 +0800, Su Hui <suhui@nfschina.com> wrote:
> > > On 2023/10/23 13:46, Xuan Zhuo wrote:
> > > >>>>>>>> Well, what are the cases where it can happen practically?
> > > >>>>>>> Device error. Such as vp_active_vq()
> > > >>>>>>>
> > > >>>>>>> Thanks.
> > > >>>>>> Hmm interesting. OK. But do callers know to recover?
> > > >>>>> No.
> > > >>>>>
> > > >>>>> So I think WARN + broken is suitable.
> > > >>>>>
> > > >>>>> Thanks.
> > > >>>> Sorry for the late, is the following code okay?
> > > >>>>
> > > >>>> @@ -2739,7 +2739,7 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
> > > >>>> void (*recycle)(struct virtqueue *vq, void *buf))
> > > >>>> {
> > > >>>> struct vring_virtqueue *vq = to_vvq(_vq);
> > > >>>> - int err;
> > > >>>> + int err, err_reset;
> > > >>>>
> > > >>>> if (num > vq->vq.num_max)
> > > >>>> return -E2BIG;
> > > >>>> @@ -2759,7 +2759,15 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
> > > >>>> else
> > > >>>> err = virtqueue_resize_split(_vq, num);
> > > >>>>
> > > >>>> - return virtqueue_enable_after_reset(_vq);
> > > >>>> + err_reset = virtqueue_enable_after_reset(_vq);
> > > >>>> +
> > > >>>> + if (err) {
> > > >>> No err.
> > > >>>
> > > >>> err is not important.
> > > >>> You can remove that.
> > > >> Emm, I'm a little confused that which code should I remove ?
> > > >>
> > > >>
> > > >> like this:
> > > >> if (vq->packed_ring)
> > > >> virtqueue_resize_packed(_vq, num);
> > > >> else
> > > >> virtqueue_resize_split(_vq, num);
> > > >>
> > > >> And we should set broken and warn inside virtqueue_enable_after_reset()?
> > >
> > > In my opinion, we should return the error code of virtqueue_resize_packed() / virtqueue_resize_split().
> > > But if this err is not important, this patch makes no sense.
> > > Maybe I misunderstand somewhere...
> > > If you think it's worth sending a patch, you can send it :).(I'm not familiar with this code).
> >
> > OK.
>
> Hi Michael,
>
> The queue reset code is wrote with the CONFIG_VIRTIO_HARDEN_NOTIFICATION.
>
> When we disable the vq, the broken is true until we re-enable it.
>
> So when we re-enable it fail, the vq is broken status.
>
> Normally, this just happens on the buggy device.
> So I think that is enough.
>
> Thanks.
I don't know what to do about CONFIG_VIRTIO_HARDEN_NOTIFICATION.
It's known to be broken and it does not look like there's
active effort to revive it - should we just drop it for now?
>
> static int vp_modern_disable_vq_and_reset(struct virtqueue *vq)
> {
> [...]
>
> vp_modern_set_queue_reset(mdev, vq->index);
>
> [...]
>
> #ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION
> ->> __virtqueue_break(vq);
> #endif
>
> [...]
> }
>
> static int vp_modern_enable_vq_after_reset(struct virtqueue *vq)
> {
> [...]
>
> if (vp_modern_get_queue_reset(mdev, index))
> return -EBUSY;
>
> if (vp_modern_get_queue_enable(mdev, index))
> return -EBUSY;
>
> err = vp_active_vq(vq, info->msix_vector);
> if (err)
> return err;
>
> }
>
> [...]
>
> #ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION
> ->> __virtqueue_unbreak(vq);
> #endif
>
> [...]
> }
>
>
>
>
> >
> > Thanks.
> >
> >
> > >
> > > Thanks,
> > > Su Hui
> > >
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2023-10-23 11:19 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-20 9:23 [PATCH] virtio_ring: add an error code check in virtqueue_resize Su Hui
2023-10-20 9:28 ` Xuan Zhuo
2023-10-20 9:28 ` Xuan Zhuo
2023-10-20 9:34 ` Michael S. Tsirkin
2023-10-20 9:34 ` Michael S. Tsirkin
2023-10-20 9:36 ` Xuan Zhuo
2023-10-20 9:36 ` Xuan Zhuo
2023-10-20 9:42 ` Michael S. Tsirkin
2023-10-20 9:42 ` Michael S. Tsirkin
2023-10-20 9:50 ` Xuan Zhuo
2023-10-20 9:50 ` Xuan Zhuo
2023-10-20 10:08 ` Michael S. Tsirkin
2023-10-20 10:08 ` Michael S. Tsirkin
2023-10-23 2:26 ` Xuan Zhuo
2023-10-23 2:26 ` Xuan Zhuo
2023-10-23 2:51 ` Su Hui
2023-10-23 2:53 ` Xuan Zhuo
2023-10-23 2:53 ` Xuan Zhuo
2023-10-23 3:06 ` Su Hui
2023-10-23 5:46 ` Xuan Zhuo
2023-10-23 5:46 ` Xuan Zhuo
2023-10-23 9:50 ` Su Hui
2023-10-23 9:52 ` Xuan Zhuo
2023-10-23 9:52 ` Xuan Zhuo
2023-10-23 10:52 ` Xuan Zhuo
2023-10-23 10:52 ` Xuan Zhuo
2023-10-23 11:18 ` Michael S. Tsirkin [this message]
2023-10-23 11:18 ` Michael S. Tsirkin
2023-10-23 11:17 ` Michael S. Tsirkin
2023-10-23 11:17 ` Michael S. Tsirkin
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=20231023071752-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=suhui@nfschina.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xuanzhuo@linux.alibaba.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 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.