Re: [RFC PATCH v4 16/20] vhost: Check for device VRING_USED_F_NO_NOTIFY at shadow virtqueue kick
From: Jason Wang <hidden>
Date: 2021-10-13 04:37:25
Also in:
qemu-devel
在 2021/10/1 下午3:05, Eugenio Pérez 写道:
quoted hunk
Signed-off-by: Eugenio Pérez <eperezma@redhat.com> --- hw/virtio/vhost-shadow-virtqueue.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index df7e6fa3ec..775f8d36a0 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c@@ -173,6 +173,15 @@ static void vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem) svq->ring_id_maps[qemu_head] = elem; } +static void vhost_svq_kick(VhostShadowVirtqueue *svq) +{ + /* Make sure we are reading updated device flag */
I guess this would be better: /* We need to expose available array entries before checking used * flags. */ (Borrowed from kernel codes). Thanks
quoted hunk
+ smp_mb(); + if (!(svq->vring.used->flags & VRING_USED_F_NO_NOTIFY)) { + event_notifier_set(&svq->kick_notifier); + } +} + /* Handle guest->device notifications */ static void vhost_handle_guest_kick(EventNotifier *n) {@@ -197,7 +206,7 @@ static void vhost_handle_guest_kick(EventNotifier *n) } vhost_svq_add(svq, elem); - event_notifier_set(&svq->kick_notifier); + vhost_svq_kick(svq); } virtio_queue_set_notification(svq->vq, true);
_______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization