Skip to contentSkip to conversation

hw/virtio: Add a protection against duplicate vu_scmi_stop calls

PATCH In review Milan Zamazal 4 participants 7 messages Jul 20, 2023 – Aug 3, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/virtio: Add a protection against duplicate vu_scmi_stop calls

The QEMU CI fails in virtio-scmi test occasionally. As reported by Thomas Huth, this happens most likely when the system is loaded and it fails with the following error:

qemu-system-aarch64: ../../devel/qemu/hw/pci/msix.c:659:
msix_unset_vector_notifiers: Assertion `dev->msix_vector_use_notifier && dev->msix_vector_release_notifier' failed. ../../devel/qemu/tests/qtest/libqtest.c:200: kill_qemu() detected QEMU death from signal 6 (Aborted) (core dumped)

As discovered by Fabiano Rosas, the cause is a duplicate invocation of msix_unset_vector_notifiers via duplicate vu_scmi_stop calls:

msix_unset_vector_notifiers
virtio_pci_set_guest_notifiers
vu_scmi_stop
vu_scmi_disconnect
...
qemu_chr_write_buffer

msix_unset_vector_notifiers
virtio_pci_set_guest_notifiers
vu_scmi_stop
vu_scmi_set_status
...
qemu_cleanup

While vu_scmi_stop calls are protected by vhost_dev_is_started() check, it's apparently not enough. vhost-user-blk and vhost-user-gpio use an extra protection, see f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine) for the motivation. Let's use the same in vhost-user-scmi, which fixes the failure above.

Fixes a5dab090e142 ("hw/virtio: Add boilerplate for vhost-user-scmi device")
---
 hw/virtio/vhost-user-scmi.c         | 7 +++++++
 include/hw/virtio/vhost-user-scmi.h | 1 +
 2 files changed, 8 insertions(+)
hw/virtio/vhost-user-scmi.c +7 -0
index d386fb2df9..918bb7dcf7 100644
@@ -63,6 +63,7 @@ static int vu_scmi_start(VirtIODevice *vdev)
         error_report("Error starting vhost-user-scmi: %d", ret);
         goto err_guest_notifiers;
     }
+    scmi->started_vu = true;
 
     /*
      * guest_notifier_mask/pending not used yet, so just unmask
@@ -90,6 +91,12 @@ static void vu_scmi_stop(VirtIODevice *vdev)
     struct vhost_dev *vhost_dev = &scmi->vhost_dev;
     int ret;
 
+    /* vhost_dev_is_started() check in the callers is not fully reliable. */
+    if (!scmi->started_vu) {
+        return;
+    }
+    scmi->started_vu = false;
+
     if (!k->set_guest_notifiers) {
         return;
     }
include/hw/virtio/vhost-user-scmi.h +1 -0
index 6175a74ebd..c90db77dd5 100644
@@ -25,6 +25,7 @@ struct VHostUserSCMI {
     VirtQueue *cmd_vq;
     VirtQueue *event_vq;
     bool connected;
+    bool started_vu;
 };
 
 #endif /* _QEMU_VHOST_USER_SCMI_H */
Signature · 1 line
2.40.1
Tested-by on v1 1/1
#1 lore raw
Quoted 31 lines · Milan Zamazal

The QEMU CI fails in virtio-scmi test occasionally. As reported by Thomas Huth, this happens most likely when the system is loaded and it fails with the following error:

   qemu-system-aarch64: ../../devel/qemu/hw/pci/msix.c:659:
   msix_unset_vector_notifiers: Assertion `dev->msix_vector_use_notifier && dev->msix_vector_release_notifier' failed.
   ../../devel/qemu/tests/qtest/libqtest.c:200: kill_qemu() detected QEMU death from signal 6 (Aborted) (core dumped)

As discovered by Fabiano Rosas, the cause is a duplicate invocation of msix_unset_vector_notifiers via duplicate vu_scmi_stop calls:

   msix_unset_vector_notifiers
   virtio_pci_set_guest_notifiers
   vu_scmi_stop
   vu_scmi_disconnect
   ...
   qemu_chr_write_buffer

   msix_unset_vector_notifiers
   virtio_pci_set_guest_notifiers
   vu_scmi_stop
   vu_scmi_set_status
   ...
   qemu_cleanup

While vu_scmi_stop calls are protected by vhost_dev_is_started() check, it's apparently not enough. vhost-user-blk and vhost-user-gpio use an extra protection, see f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine) for the motivation. Let's use the same in vhost-user-scmi, which fixes the failure above.

Quoted 6 lines
Fixes a5dab090e142 ("hw/virtio: Add boilerplate for vhost-user-scmi device")
---
  hw/virtio/vhost-user-scmi.c         | 7 +++++++
  include/hw/virtio/vhost-user-scmi.h | 1 +
  2 files changed, 8 insertions(+)

Thanks, that fixes the problem for me!

Reviewed-by on v1 1/1
#2 lore raw
In reply to Milan Zamazal
Quoted 25 lines · Milan Zamazal

The QEMU CI fails in virtio-scmi test occasionally. As reported by Thomas Huth, this happens most likely when the system is loaded and it fails with the following error:

qemu-system-aarch64: ../../devel/qemu/hw/pci/msix.c:659:
msix_unset_vector_notifiers: Assertion `dev->msix_vector_use_notifier && dev->msix_vector_release_notifier' failed. ../../devel/qemu/tests/qtest/libqtest.c:200: kill_qemu() detected QEMU death from signal 6 (Aborted) (core dumped)

As discovered by Fabiano Rosas, the cause is a duplicate invocation of msix_unset_vector_notifiers via duplicate vu_scmi_stop calls:

msix_unset_vector_notifiers
virtio_pci_set_guest_notifiers
vu_scmi_stop
vu_scmi_disconnect
...
qemu_chr_write_buffer

msix_unset_vector_notifiers
virtio_pci_set_guest_notifiers
vu_scmi_stop
vu_scmi_set_status
...
qemu_cleanup

Quoted 8 lines

While vu_scmi_stop calls are protected by vhost_dev_is_started() check, it's apparently not enough. vhost-user-blk and vhost-user-gpio use an extra protection, see f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine) for the motivation. Let's use the same in vhost-user-scmi, which fixes the failure above.

Fixes a5dab090e142 ("hw/virtio: Add boilerplate for vhost-user-scmi device")
#3 lore raw
Quoted 36 lines · Fabiano Rosas
Quoted 34 lines · Milan Zamazal

The QEMU CI fails in virtio-scmi test occasionally. As reported by Thomas Huth, this happens most likely when the system is loaded and it fails with the following error:

qemu-system-aarch64: ../../devel/qemu/hw/pci/msix.c:659:
msix_unset_vector_notifiers: Assertion
`dev->msix_vector_use_notifier && dev->msix_vector_release_notifier' failed.
../../devel/qemu/tests/qtest/libqtest.c:200: kill_qemu() detected
QEMU death from signal 6 (Aborted) (core dumped)

As discovered by Fabiano Rosas, the cause is a duplicate invocation of msix_unset_vector_notifiers via duplicate vu_scmi_stop calls:

msix_unset_vector_notifiers
virtio_pci_set_guest_notifiers
vu_scmi_stop
vu_scmi_disconnect
...
qemu_chr_write_buffer

msix_unset_vector_notifiers
virtio_pci_set_guest_notifiers
vu_scmi_stop
vu_scmi_set_status
...
qemu_cleanup

While vu_scmi_stop calls are protected by vhost_dev_is_started() check, it's apparently not enough. vhost-user-blk and vhost-user-gpio use an extra protection, see f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine) for the motivation. Let's use the same in vhost-user-scmi, which fixes the failure above.

Quoted 4 lines
Quoted 2 lines
Fixes a5dab090e142 ("hw/virtio: Add boilerplate for vhost-user-scmi device")

Please note that this bug fix should IMO definitely go to 8.1, to not have a bug in vhost-user-scmi and to not have broken tests. Any chance to get it merged?

Thanks,
Milan

#4 lore raw
Quoted 38 lines · Milan Zamazal
Quoted 36 lines · Fabiano Rosas
Quoted 34 lines · Milan Zamazal

The QEMU CI fails in virtio-scmi test occasionally. As reported by Thomas Huth, this happens most likely when the system is loaded and it fails with the following error:

   qemu-system-aarch64: ../../devel/qemu/hw/pci/msix.c:659:
   msix_unset_vector_notifiers: Assertion

`dev->msix_vector_use_notifier && dev->msix_vector_release_notifier' failed.
../../devel/qemu/tests/qtest/libqtest.c:200: kill_qemu() detected
QEMU death from signal 6 (Aborted) (core dumped)

As discovered by Fabiano Rosas, the cause is a duplicate invocation of msix_unset_vector_notifiers via duplicate vu_scmi_stop calls:

   msix_unset_vector_notifiers
   virtio_pci_set_guest_notifiers
   vu_scmi_stop
   vu_scmi_disconnect
   ...
   qemu_chr_write_buffer

   msix_unset_vector_notifiers
   virtio_pci_set_guest_notifiers
   vu_scmi_stop
   vu_scmi_set_status
   ...
   qemu_cleanup

While vu_scmi_stop calls are protected by vhost_dev_is_started() check, it's apparently not enough. vhost-user-blk and vhost-user-gpio use an extra protection, see f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine) for the motivation. Let's use the same in vhost-user-scmi, which fixes the failure above.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes a5dab090e142 ("hw/virtio: Add boilerplate for vhost-user-scmi device")

Please note that this bug fix should IMO definitely go to 8.1, to not have a bug in vhost-user-scmi and to not have broken tests. Any chance to get it merged?

If nobody else is planning a pull request with this patch included, I can take it for my next PR (since it is fixing the CI, I just saw another failure here:
https://gitlab.com/qemu-project/qemu/-/jobs/4790457938#L4784 )

Thomas

#5 lore raw
Quoted 48 lines · Thomas Huth
Quoted 38 lines · Milan Zamazal
Quoted 36 lines · Fabiano Rosas
Quoted 34 lines · Milan Zamazal

The QEMU CI fails in virtio-scmi test occasionally. As reported by Thomas Huth, this happens most likely when the system is loaded and it fails with the following error:

   qemu-system-aarch64: ../../devel/qemu/hw/pci/msix.c:659:
   msix_unset_vector_notifiers: Assertion

`dev->msix_vector_use_notifier && dev->msix_vector_release_notifier' failed.
../../devel/qemu/tests/qtest/libqtest.c:200: kill_qemu() detected
QEMU death from signal 6 (Aborted) (core dumped)

As discovered by Fabiano Rosas, the cause is a duplicate invocation of msix_unset_vector_notifiers via duplicate vu_scmi_stop calls:

   msix_unset_vector_notifiers
   virtio_pci_set_guest_notifiers
   vu_scmi_stop
   vu_scmi_disconnect
   ...
   qemu_chr_write_buffer

   msix_unset_vector_notifiers
   virtio_pci_set_guest_notifiers
   vu_scmi_stop
   vu_scmi_set_status
   ...
   qemu_cleanup

While vu_scmi_stop calls are protected by vhost_dev_is_started() check, it's apparently not enough. vhost-user-blk and vhost-user-gpio use an extra protection, see f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine) for the motivation. Let's use the same in vhost-user-scmi, which fixes the failure above.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes a5dab090e142 ("hw/virtio: Add boilerplate for vhost-user-scmi device")

Please note that this bug fix should IMO definitely go to 8.1, to not have a bug in vhost-user-scmi and to not have broken tests. Any chance to get it merged?

Quoted 7 lines

If nobody else is planning a pull request with this patch included, I can take it for my next PR (since it is fixing the CI, I just saw another failure here:
https://gitlab.com/qemu-project/qemu/-/jobs/4790457938#L4784 )

Thomas

I picked it up but if you like I can drop it.

Signature · 1 line
MST
#6 lore raw
Quoted 54 lines · Michael S. Tsirkin
Quoted 53 lines · Thomas Huth
Quoted 38 lines · Milan Zamazal
Quoted 36 lines · Fabiano Rosas
Quoted 34 lines · Milan Zamazal

The QEMU CI fails in virtio-scmi test occasionally. As reported by Thomas Huth, this happens most likely when the system is loaded and it fails with the following error:

    qemu-system-aarch64: ../../devel/qemu/hw/pci/msix.c:659:
    msix_unset_vector_notifiers: Assertion
`dev->msix_vector_use_notifier && dev->msix_vector_release_notifier'
failed.
    ../../devel/qemu/tests/qtest/libqtest.c:200: kill_qemu() detected

QEMU death from signal 6 (Aborted) (core dumped)

As discovered by Fabiano Rosas, the cause is a duplicate invocation of msix_unset_vector_notifiers via duplicate vu_scmi_stop calls:

    msix_unset_vector_notifiers
    virtio_pci_set_guest_notifiers
    vu_scmi_stop
    vu_scmi_disconnect
    ...
    qemu_chr_write_buffer

    msix_unset_vector_notifiers
    virtio_pci_set_guest_notifiers
    vu_scmi_stop
    vu_scmi_set_status
    ...
    qemu_cleanup

While vu_scmi_stop calls are protected by vhost_dev_is_started() check, it's apparently not enough. vhost-user-blk and vhost-user-gpio use an extra protection, see f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine) for the motivation. Let's use the same in vhost-user-scmi, which fixes the failure above.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes a5dab090e142 ("hw/virtio: Add boilerplate for vhost-user-scmi device")

Please note that this bug fix should IMO definitely go to 8.1, to not have a bug in vhost-user-scmi and to not have broken tests. Any chance to get it merged?

If nobody else is planning a pull request with this patch included, I can take it for my next PR (since it is fixing the CI, I just saw another failure here:
https://gitlab.com/qemu-project/qemu/-/jobs/4790457938#L4784 )

Quoted 4 lines
Quoted 2 lines

Thomas

I picked it up but if you like I can drop it.

I think it better fits into your tree, so if you plan a PR before the next RC, then please go ahead. I'll drop it from my branch again.

Thomas