[PATCH v6 00/17] vhost-user-gpu fixes

Marc-André Lureau posted 17 patches 4 days, 7 hours ago
Only 16 patches received!
contrib/vhost-user-gpu/vhost-user-gpu.c | 233 +++++++++++++++++++++++++-------
contrib/vhost-user-gpu/virgl.c          | 123 +++++++++++++++--
contrib/vhost-user-gpu/vugpu.h          |   7 +-
hw/display/vhost-user-gpu.c             | 108 +++++++++++++--
4 files changed, 399 insertions(+), 72 deletions(-)
[PATCH v6 00/17] vhost-user-gpu fixes
Posted by Marc-André Lureau 4 days, 7 hours ago
Dmitry reported a handful of vhost-user-gpu issues (#4847-4849): crash
when a command waits for a reply and a fence is signaled (#4848), guest
losing display when the device is restarted (#4849), or main loop
spinning on bad descriptor (#4847). The first patches address those.

The rest are problems found while working through the code: scanout
sizes are not checked, the 2D scanout path frees a surface it does not
own and leaks the dmabuf, the console is not resized on dmabuf scanout,
and the exported dmabuf is imported with the wrong stride in some
setups.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
Changes in v6:
- address Akihiko's v5 review:
  - keep the display socket when the control queue stops, close it only
    when the frontend sends a new one, and resume the control queue after
    accepting it
  - do not report a send failure for resource unref and scanout disable,
    since the operation has already been completed on the backend
  - validate scanout bounds and stride in the backend too, so invalid
    scanouts fail the guest command instead of being silently dropped
  - validate the scanout size before clearing the previous surface
- add "hw/display/vhost-user-gpu: honor the dmabuf scanout origin"
- check the dmabuf stride against the scanout bpp in the frontend
- reject multi-planar resources
- Link to v5: https://lore.kernel.org/qemu-devel/20261201-issue-4848-v5-0-b7e477b83881@redhat.com

Changes in v5:
- split "reset the frontend socket on stop and start" into smaller patches
- loop on short reads/writes instead of failing, use MSG_NOSIGNAL
- only complete the pending command while the control queue is started
- add scanout size and dmabuf bounds checks in the frontend
- free the pending 2D scanout surface on reset
- vg_wait_cancel() takes a "complete" argument, so that completing the
  pending command on queue stop is explicit
- resume the control queue when a cursor update fails to send
- add "don't reply to a DMABUF update after a stop" and "keep the display
  socket while running" frontend patches, before the matching backend ones
- check the scanout size on both 2D and dmabuf paths
- split "fix scanout bookkeeping on the 2D path" in two
- log invalid dmabuf scanouts as guest errors
- move the #4847 fix earlier, add Fixes: tags
- Link to v4: https://lore.kernel.org/qemu-devel/20261124-issue-4848-v4-0-24993c4766fc@redhat.com

Changes in v4:
- replace vg_wait_drop() with vg_wait_cancel() when queue stopped
- drop patch 3 & 4 #4846, waiting for Akihiko series ("[PATCH v3 0/9] virtio-gpu: Do not wait for the main thread during reset")
- Link to v3: https://lore.kernel.org/qemu-devel/20261113-issue-4848-v3-0-98e4fa3e77eb@redhat.com

Changes in v3:
- fix crash on finalize
- replace Dmitry email address
- Link to v2: https://lore.kernel.org/qemu-devel/20261113-issue-4848-v2-0-631414664bca@redhat.com

Changes in v2:
- add "hw/display/vhost-user-gpu: reset scanouts on the main loop"
  patch, similar to virtio-gpu
- add Tested-by tags
- Link to v1: https://lore.kernel.org/qemu-devel/20261112-issue-4848-v1-0-aeba1cfe2c03@redhat.com

---
Marc-André Lureau (17):
      contrib/vhost-user-gpu: don't fence commands waiting for a reply
      hw/display/vhost-user-gpu: don't set an fd handler without a socket
      contrib/vhost-user-gpu: don't raise SIGPIPE when the frontend goes away
      contrib/vhost-user-gpu: handle short reads and writes on the frontend socket
      contrib/vhost-user-gpu: report frontend send failures to the guest
      contrib/vhost-user-gpu: stop waiting for a reply on socket failure
      contrib/vhost-user-gpu: cancel the frontend wait when the queue stops
      hw/display/vhost-user-gpu: don't reply to a DMABUF update after a stop
      hw/display/vhost-user-gpu: keep the display socket while running
      hw/display/vhost-user-gpu: check the scanout size
      contrib/vhost-user-gpu: validate scanout bounds and format
      hw/display/vhost-user-gpu: fix the 2D scanout surface ownership
      hw/display/vhost-user-gpu: release the dmabuf on a 2D scanout
      hw/display/vhost-user-gpu: free the pending scanout surface on reset
      hw/display/vhost-user-gpu: resize the console on dmabuf scanout
      hw/display/vhost-user-gpu: honor the dmabuf scanout origin
      contrib/vhost-user-gpu: use the stride of the exported dmabuf

 contrib/vhost-user-gpu/vhost-user-gpu.c | 233 +++++++++++++++++++++++++-------
 contrib/vhost-user-gpu/virgl.c          | 123 +++++++++++++++--
 contrib/vhost-user-gpu/vugpu.h          |   7 +-
 hw/display/vhost-user-gpu.c             | 108 +++++++++++++--
 4 files changed, 399 insertions(+), 72 deletions(-)
---
base-commit: 3c061218fcf37a98c944ecb88cff56f94f5c0a43
change-id: 20261112-issue-4848-d49d6bd8e7b4

Best regards,
--  
Marc-André Lureau <marcandre.lureau@redhat.com>


Re: [PATCH v6 00/17] vhost-user-gpu fixes
Posted by Dmitry R 3 days, 12 hours ago
Hi Marc-André,

I tested v6 on its stated base, 3c061218fcf3, on x86_64/KVM. The
setup was the same as for v4: vhost-user-vga with the contrib backend
(--virgl), a D-Bus display with a listener, and a Debian 13 guest.

- #4848: I injected a fence while GET_EDID was waiting for its reply.
  The injection was observed, and the backend and QEMU stayed alive.
- #4847: QEMU stayed alive without any "failed to read msg header"
  lines in 90 seconds; it used 8 seconds of CPU time.
- #4849: after stop/cont, guest reset, and another stop/cont, the
  backend stayed alive without sock_fd or wait_in assertions. The
  guest driver came back after reset, without DRM errors in this test.
- I ran 60 cycles of SetUIInfo followed 0-4 ms later by QMP stop/cont.
  QEMU and the backend stayed alive, with no QMP or D-Bus errors,
  backend assertions, or hung guest tasks. The display continued to
  update afterwards. The guest reported ERR_UNSPEC for two
  RESOURCE_FLUSH commands and one SET_SCANOUT command. No
  GET_DISPLAY_INFO or GET_EDID command reported ERR_UNSPEC, so this
  run did not establish that a stop caught either command while it
  was waiting for a reply. That particular window remains untested.

The tests above cover the reported paths; they do not cover every
change in the 17-patch series.

Dmitry