[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 05/31] vhost: Add Shadow VirtQueue kick forwarding capabiliti
|
From: |
Eugenio Perez Martin |
|
Subject: |
Re: [PATCH 05/31] vhost: Add Shadow VirtQueue kick forwarding capabilities |
|
Date: |
Mon, 31 Jan 2022 11:48:49 +0100 |
On Fri, Jan 28, 2022 at 7:33 AM Jason Wang <jasowang@redhat.com> wrote:
>
>
> 在 2022/1/22 上午4:27, Eugenio Pérez 写道:
> > At this mode no buffer forwarding will be performed in SVQ mode: Qemu
> > will just forward the guest's kicks to the device.
> >
> > Also, host notifiers must be disabled at SVQ start, and they will not
> > start if SVQ has been enabled when the device is stopped. This will be
> > addressed in next patches.
>
>
> We need to disable host_notifier_mr as well, otherwise guest may touch
> the hardware doorbell directly without going through eventfd.
>
Yes. SVQ cannot be enabled at this point anyway, but I think it's a
good idea to reorder so we disable hn_mr first.
>
> >
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > ---
> > hw/virtio/vhost-shadow-virtqueue.h | 2 ++
> > hw/virtio/vhost-shadow-virtqueue.c | 27 ++++++++++++++++++++++++++-
> > 2 files changed, 28 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/virtio/vhost-shadow-virtqueue.h
> > b/hw/virtio/vhost-shadow-virtqueue.h
> > index a56ecfc09d..4c583a9171 100644
> > --- a/hw/virtio/vhost-shadow-virtqueue.h
> > +++ b/hw/virtio/vhost-shadow-virtqueue.h
> > @@ -19,6 +19,8 @@ void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq,
> > int svq_kick_fd);
> > const EventNotifier *vhost_svq_get_dev_kick_notifier(
> > const VhostShadowVirtqueue
> > *svq);
> >
> > +void vhost_svq_stop(VhostShadowVirtqueue *svq);
> > +
> > VhostShadowVirtqueue *vhost_svq_new(void);
> >
> > void vhost_svq_free(VhostShadowVirtqueue *vq);
> > diff --git a/hw/virtio/vhost-shadow-virtqueue.c
> > b/hw/virtio/vhost-shadow-virtqueue.c
> > index 21534bc94d..8991f0b3c3 100644
> > --- a/hw/virtio/vhost-shadow-virtqueue.c
> > +++ b/hw/virtio/vhost-shadow-virtqueue.c
> > @@ -42,11 +42,26 @@ const EventNotifier *vhost_svq_get_dev_kick_notifier(
> > return &svq->hdev_kick;
> > }
> >
> > +/* Forward guest notifications */
> > +static void vhost_handle_guest_kick(EventNotifier *n)
> > +{
> > + VhostShadowVirtqueue *svq = container_of(n, VhostShadowVirtqueue,
> > + svq_kick);
> > +
> > + if (unlikely(!event_notifier_test_and_clear(n))) {
> > + return;
> > + }
> > +
> > + event_notifier_set(&svq->hdev_kick);
> > +}
> > +
> > /**
> > * Set a new file descriptor for the guest to kick SVQ and notify for
> > avail
> > *
> > * @svq The svq
> > - * @svq_kick_fd The new svq kick fd
> > + * @svq_kick_fd The svq kick fd
> > + *
> > + * Note that SVQ will never close the old file descriptor.
> > */
> > void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd)
> > {
> > @@ -65,12 +80,22 @@ void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue
> > *svq, int svq_kick_fd)
> > * need to explicitely check for them.
> > */
> > event_notifier_init_fd(&svq->svq_kick, svq_kick_fd);
> > + event_notifier_set_handler(&svq->svq_kick, vhost_handle_guest_kick);
> >
> > if (!check_old || event_notifier_test_and_clear(&tmp)) {
> > event_notifier_set(&svq->hdev_kick);
> > }
> > }
> >
> > +/**
> > + * Stop shadow virtqueue operation.
> > + * @svq Shadow Virtqueue
> > + */
> > +void vhost_svq_stop(VhostShadowVirtqueue *svq)
> > +{
> > + event_notifier_set_handler(&svq->svq_kick, NULL);
> > +}
>
>
> This function is not used in the patch.
>
Right, I will add the use of it here.
Thanks!
> Thanks
>
>
> > +
> > /**
> > * Creates vhost shadow virtqueue, and instruct vhost device to use the
> > shadow
> > * methods and file descriptors.
>
- Re: [PATCH 01/31] vdpa: Reorder virtio/vhost-vdpa.c functions, (continued)
- [PATCH 03/31] vdpa: Add vhost_svq_get_dev_kick_notifier, Eugenio Pérez, 2022/01/21
- [PATCH 04/31] vdpa: Add vhost_svq_set_svq_kick_fd, Eugenio Pérez, 2022/01/21
- [PATCH 05/31] vhost: Add Shadow VirtQueue kick forwarding capabilities, Eugenio Pérez, 2022/01/21
- [PATCH 06/31] vhost: Route guest->host notification through shadow virtqueue, Eugenio Pérez, 2022/01/21
- [PATCH 07/31] vhost: dd vhost_svq_get_svq_call_notifier, Eugenio Pérez, 2022/01/21
- [PATCH 08/31] vhost: Add vhost_svq_set_guest_call_notifier, Eugenio Pérez, 2022/01/21
- [PATCH 09/31] vhost-vdpa: Take into account SVQ in vhost_vdpa_set_vring_call, Eugenio Pérez, 2022/01/21