vhost: fix notification for packed ring
PATCH 1/1 vhost: fix notification for packed ring
The notification can't be disabled in packed ring when application tries to disable notification, because the device event flags field is overwritten by an unexpected value. This patch fixes this issue.
--- lib/librte_vhost/vhost.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
lib/librte_vhost/vhost.c +5 -2
@@ -667,8 +667,10 @@ vhost_enable_notify_packed(struct virtio_net *dev, {uint16_t flags; -if (!enable) - vq->device_event->flags =VRING_EVENT_F_DISABLE ; +if (!enable) { + flags =VRING_EVENT_F_DISABLE ; + goto out; + } flags =VRING_EVENT_F_ENABLE ;if (dev->features & (1ULL <<VIRTIO_RING_F_EVENT_IDX )) {
@@ -677,6 +679,7 @@ vhost_enable_notify_packed(struct virtio_net *dev, vq->avail_wrap_counter <<15 ; } +out:rte_smp_wmb (); vq->device_event->flags = flags;
Signature · 1 line
2.19.1
Quoted 32 lines · Tiwei Bie
The notification can't be disabled in packed ring when application tries to disable notification, because the device event flags field is overwritten by an unexpected value. This patch fixes this issue.
Fixes b1cce26af1dc ("vhost: add notification for packed ring")Signed-off-by Tiwei Bie <[email protected]>--- lib/librte_vhost/vhost.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)lib/librte_vhost/vhost.c +4
-2@@ -667,8 +667,10 @@ vhost_enable_notify_packed(struct virtio_net *dev, {uint16_t flags; -if (!enable) - vq->device_event->flags =VRING_EVENT_F_DISABLE ; +if (!enable) { + flags =VRING_EVENT_F_DISABLE ; + goto out; + } flags =VRING_EVENT_F_ENABLE ;if (dev->features & (1ULL <<VIRTIO_RING_F_EVENT_IDX )) {
lib/librte_vhost/vhost.c vhost_enable_notify_packed(struct virtio_net *dev, · line 685
Quoted 7 lines
lib/librte_vhost/vhost.c +1
-0@@ -677,6 +679,7 @@ vhost_enable_notify_packed(struct virtio_net *dev, vq->avail_wrap_counter <<15 ; } +out:rte_smp_wmb (); vq->device_event->flags = flags;
Thanks for spotting this:
Maxime
Quoted 31 lines · Tiwei Bie
The notification can't be disabled in packed ring when application tries to disable notification, because the device event flags field is overwritten by an unexpected value. This patch fixes this issue.
Fixes b1cce26af1dc ("vhost: add notification for packed ring")Signed-off-by Tiwei Bie <[email protected]>--- lib/librte_vhost/vhost.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)lib/librte_vhost/vhost.c +4
-2@@ -667,8 +667,10 @@ vhost_enable_notify_packed(struct virtio_net *dev, {uint16_t flags; -if (!enable) - vq->device_event->flags =VRING_EVENT_F_DISABLE ; +if (!enable) { + flags =VRING_EVENT_F_DISABLE ; + goto out; + } flags =VRING_EVENT_F_ENABLE ;if (dev->features & (1ULL <<VIRTIO_RING_F_EVENT_IDX )) {
lib/librte_vhost/vhost.c vhost_enable_notify_packed(struct virtio_net *dev, · line 684
Quoted 6 lines
lib/librte_vhost/vhost.c +1
-0@@ -677,6 +679,7 @@ vhost_enable_notify_packed(struct virtio_net *dev, vq->avail_wrap_counter <<15 ; } +out:rte_smp_wmb ();
It looks to me the barrier is even not needed for !enable.
Thanks
Quoted 1 line
lib/librte_vhost/vhost.c +0
-0vq->device_event->flags = flags;
Michael S. Tsirkin
Reviewed-byQuoted 39 lines · Jason Wang
Quoted 29 lines · Tiwei Bie
The notification can't be disabled in packed ring when application tries to disable notification, because the device event flags field is overwritten by an unexpected value. This patch fixes this issue.
Fixes b1cce26af1dc ("vhost: add notification for packed ring")Signed-off-by Tiwei Bie <[email protected]>--- lib/librte_vhost/vhost.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)lib/librte_vhost/vhost.c +4
-2@@ -667,8 +667,10 @@ vhost_enable_notify_packed(struct virtio_net *dev, {uint16_t flags; -if (!enable) - vq->device_event->flags =VRING_EVENT_F_DISABLE ; +if (!enable) { + flags =VRING_EVENT_F_DISABLE ; + goto out; + } flags =VRING_EVENT_F_ENABLE ;if (dev->features & (1ULL <<VIRTIO_RING_F_EVENT_IDX )) {lib/librte_vhost/vhost.c vhost_enable_notify_packed(struct virtio_net *dev, · line 682
Quoted 4 lines
lib/librte_vhost/vhost.c +1
-0@@ -677,6 +679,7 @@ vhost_enable_notify_packed(struct virtio_net *dev, vq->avail_wrap_counter <<15 ; } +out:rte_smp_wmb ();It looks to me the barrier is even not needed for !enable.
Quoted 1 line
Thanks
Good point, I agree.
Besides that
Quoted 1 line
Quoted 1 line
lib/librte_vhost/vhost.c +0
-0vq->device_event->flags = flags;
Quoted 40 lines · Michael S. Tsirkin
Quoted 39 lines · Jason Wang
Quoted 29 lines · Tiwei Bie
The notification can't be disabled in packed ring when application tries to disable notification, because the device event flags field is overwritten by an unexpected value. This patch fixes this issue.
Fixes b1cce26af1dc ("vhost: add notification for packed ring")Signed-off-by Tiwei Bie <[email protected]>--- lib/librte_vhost/vhost.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)lib/librte_vhost/vhost.c +4
-2@@ -667,8 +667,10 @@ vhost_enable_notify_packed(struct virtio_net *dev, {uint16_t flags; -if (!enable) - vq->device_event->flags =VRING_EVENT_F_DISABLE ; +if (!enable) { + flags =VRING_EVENT_F_DISABLE ; + goto out; + } flags =VRING_EVENT_F_ENABLE ;if (dev->features & (1ULL <<VIRTIO_RING_F_EVENT_IDX )) {lib/librte_vhost/vhost.c vhost_enable_notify_packed(struct virtio_net *dev, · line 682
Quoted 4 lines
lib/librte_vhost/vhost.c +1
-0@@ -677,6 +679,7 @@ vhost_enable_notify_packed(struct virtio_net *dev, vq->avail_wrap_counter <<15 ; } +out:rte_smp_wmb ();It looks to me the barrier is even not needed for !enable.
Quoted 7 lines
Quoted 1 line
Thanks
Good point, I agree.
Besides thatReviewed-by Michael S. Tsirkin <[email protected]>
Yeah, it's better to return directly after disabling the interrupt. I will send a new version to do this change.
Thanks!
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
lib/librte_vhost/vhost.c +0
-0vq->device_event->flags = flags;
PATCH v2 1/1 vhost: fix notification for packed ring
In reply to Tiwei BieThe notification can't be disabled in packed ring when application tries to disable notification, because the device event flags field is overwritten by an unexpected value. This patch fixes this issue.
---
v2: return directly after disabling the interrupt (Jason/MST)
lib/librte_vhost/vhost.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/librte_vhost/vhost.c +3 -1
@@ -667,8 +667,10 @@ vhost_enable_notify_packed(struct virtio_net *dev, {uint16_t flags; -if (!enable) +if (!enable) { vq->device_event->flags =VRING_EVENT_F_DISABLE ; +return ; + } flags =VRING_EVENT_F_ENABLE ;if (dev->features & (1ULL <<VIRTIO_RING_F_EVENT_IDX )) {
Signature · 1 line
2.19.1
Quoted 10 lines · Tiwei Bie
The notification can't be disabled in packed ring when application tries to disable notification, because the device event flags field is overwritten by an unexpected value. This patch fixes this issue.
Fixes b1cce26af1dc ("vhost: add notification for packed ring")Signed-off-by Tiwei Bie <[email protected]>Reviewed-by Michael S. Tsirkin <[email protected]>
Quoted 23 lines
---
v2: return directly after disabling the interrupt (Jason/MST)lib/librte_vhost/vhost.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/librte_vhost/vhost.c +3
-1@@ -667,8 +667,10 @@ vhost_enable_notify_packed(struct virtio_net *dev, {uint16_t flags; -if (!enable) +if (!enable) { vq->device_event->flags =VRING_EVENT_F_DISABLE ; +return ; + } flags =VRING_EVENT_F_ENABLE ;if (dev->features & (1ULL <<VIRTIO_RING_F_EVENT_IDX )) {
Quoted 22 lines · Tiwei Bie
The notification can't be disabled in packed ring when application tries to disable notification, because the device event flags field is overwritten by an unexpected value. This patch fixes this issue.
Fixes b1cce26af1dc ("vhost: add notification for packed ring")Signed-off-by Tiwei Bie <[email protected]>Reviewed-by Michael S. Tsirkin <[email protected]>---
v2: return directly after disabling the interrupt (Jason/MST)lib/librte_vhost/vhost.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/librte_vhost/vhost.c +0
-0@@ -667,8 +667,10 @@ vhost_enable_notify_packed(struct virtio_net *dev, {
lib/librte_vhost/vhost.c vhost_enable_notify_packed(struct virtio_net *dev, · line 676
Quoted 10 lines
lib/librte_vhost/vhost.c +3
-1uint16_t flags; -if (!enable) +if (!enable) { vq->device_event->flags =VRING_EVENT_F_DISABLE ; +return ; + } flags =VRING_EVENT_F_ENABLE ;if (dev->features & (1ULL <<VIRTIO_RING_F_EVENT_IDX )) {
Maxime Coquelin
AppliedQuoted 8 lines · Tiwei Bie
The notification can't be disabled in packed ring when application tries to disable notification, because the device event flags field is overwritten by an unexpected value. This patch fixes this issue.
Fixes b1cce26af1dc ("vhost: add notification for packed ring")
Quoted 7 lines
Signed-off-by Tiwei Bie <[email protected]>Reviewed-by Michael S. Tsirkin <[email protected]>---
v2: return directly after disabling the interrupt (Jason/MST)lib/librte_vhost/vhost.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Applied to dpdk-next-virtio/master.
Thanks,
Maxime