Re: [PATCH RFC] vhost: fix vhost_get_avail_idx for a non empty ring
From: Jason Wang <jasowang@redhat.com>
Date: 2026-03-03 06:39:11
Also in:
kvm, lkml, virtualization
From: Jason Wang <jasowang@redhat.com>
Date: 2026-03-03 06:39:11
Also in:
kvm, lkml, virtualization
On Mon, Mar 2, 2026 at 4:51 PM Michael S. Tsirkin [off-list ref] wrote:
vhost_get_avail_idx is supposed to report whether it has updated
vq->avail_idx. Instead, it returns whether all entries have been
consumed, which is usually the same. But not always - in
drivers/vhost/net.c and when mergeable buffers have been enabled, the
driver checks whether the combined entries are big enough to store an
incoming packet. If not, the driver re-enables notifications with
available entries still in the ring. The incorrect return value from
vhost_get_avail_idx propagates through vhost_enable_notify and causes
the host to livelock if the guest is not making progress, as vhost will
immediately disable notifications and retry using the available entries.
The obvious fix is to make vhost_get_avail_idx do what the comment
says it does and report whether new entries have been added.
Reported-by: ShuangYu <redacted>
Fixes: d3bb267bbdcb ("vhost: cache avail index in vhost_enable_notify()")
Cc: Stefano Garzarella <sgarzare@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---Acked-by: Jason Wang <jasowang@redhat.com> Thanks