From: Joonho Lee <mynameisjune111@gmail.com>
To: Anton Yakovlev <anton.yakovlev@opensynergy.com>,
Takashi Iwai <tiwai@suse.com>
Cc: Joonho Lee <mynameisjune111@gmail.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jaroslav Kysela <perex@perex.cz>,
virtualization@lists.linux.dev, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org,
Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
Subject: [PATCH v1 0/5] ALSA: virtio: Fix request lifetime and error recovery
Date: Tue, 13 Oct 2026 14:30:21 +0900 [thread overview]
Message-ID: <cover.1791867377.git.mynameisjune111@gmail.com> (raw)
A failed PCM start or a timed-out request can leave virtio-snd with
messages still owned by the device. Retrying a stream can then reuse
pending messages, and freeing the ALSA buffer or a control payload can
leave a descriptor pointing at released memory.
This series fixes the enqueue and start error paths, then keeps control
requests and PCM backing pages alive until completion or device reset.
It is based on Takashi Iwai's sound.git for-next branch at the base
commit below. Please apply the five patches in order.
Patches 1 and 2 fix partial enqueue notification and failed-start state.
Patch 3 serializes control notification with teardown and retains queue
references through reset. Patch 4 retains the vmalloc-backed PCM pages
when ALSA releases the buffer mapping after a failed drain. Patch 5 puts
control payloads under the message reference count; it needs patch 3's
reset lifetime handling as well as normal completion handling.
Keeping a message object alive is not sufficient by itself: its payload
must remain alive too. Patches 3 and 5 therefore need to stay together
when evaluating the control-request lifetime fix. An unresponsive device
can retain memory until reset. Patch 4 adds a page-pointer array and page
references per PCM buffer; patch 5 adds owned payload storage and copies.
Validation:
- ARM64 GCC 14.2.0 W=1 builds passed for the final series and the
intermediate tree through patch 4, with no build warnings in those
runs. The tree through patch 3 also passed a W=1 driver rebuild.
Patches 1 and 2 were not separately kernel-built or booted.
- Source-extracted ASan/UBSan tests passed 340 assertions covering partial
enqueue, failed start, allocation failure, timeout/interruption, late
access, cleanup and a subsequent operation. These use kernel shims;
they do not prove real kernel concurrency.
- An ARM64 KASAN guest with a fault-injecting QEMU virtio-sound backend
reproduced PCM-page and PCM_INFO-payload use-after-free on the tree
through patch 3. Two runs of each case with the complete series had no
KASAN or other kernel diagnostics and passed subsequent capture and
playback checks. A separate drain-timeout/reset/rebind run also passed.
The backend deliberately holds a capture descriptor past RELEASE, or a
PCM_INFO response past the caller's timeout, then accesses the original
scatterlist. A test-only guest observer reads the referenced storage so
KASAN can check it; external DMA alone is not instrumented by KASAN. The
reset test checks that the backend's delayed callback does not run after
reset. It does not independently inspect guest memory after reset.
These are local fault-injection results, using QEMU's none audio backend.
TLV and enum payloads have source-shim coverage only. No physical audio,
Apple VZ or Docker Desktop microphone validation is claimed for this
series. VZ-specific completion compatibility changes are excluded. The
playback ACK callback's inability to propagate enqueue errors is also
outside this series. No new userspace ABI or feature is introduced.
Reproducer source and instructions:
https://github.com/whatisyourname0/virtio-snd-reproducer/tree/8e6ef41bb9c102af4f9d9809bc9fa9bd6243fb02
The source-only package includes the host harnesses, QEMU fault-injection
patch, guest observer and build/run scripts. The 340 host assertions were
rerun on macOS arm64 and Debian Linux aarch64. The portable QEMU validators
passed PCM, PCM_INFO and reset checks using existing build artifacts.
A newly generated initramfs also passed the PCM and recovery checks.
The complete QEMU/kernel source rebuild recipe has not been run end to
end from this package; that boundary is recorded in its README.
AI assistance (Codex, including GPT-6 Luna Max) was used for code analysis,
implementation, test fixtures, validation and patch text. The work was
prompted to isolate generic virtio-snd lifetime and error fixes from
VZ-specific behavior, reproduce the failures, and check recovery. Each
patch carries Assisted-by: LLM.
Joonho Lee (5):
ALSA: virtio: Notify queued PCM messages after send errors
ALSA: virtio: Recover PCM state after a failed start
ALSA: virtio: Retain control requests through device reset
ALSA: virtio: Retain PCM DMA pages until messages are freed
ALSA: virtio: Keep control payloads in refcounted messages
sound/virtio/virtio_card.c | 6 +-
sound/virtio/virtio_card.h | 2 +
sound/virtio/virtio_ctl_msg.c | 170 ++++++++++++++++++++++++++++------
sound/virtio/virtio_ctl_msg.h | 20 +++-
sound/virtio/virtio_kctl.c | 101 ++++++++++----------
sound/virtio/virtio_pcm.h | 5 +
sound/virtio/virtio_pcm_msg.c | 124 +++++++++++++++++++++++--
sound/virtio/virtio_pcm_ops.c | 65 +++++++++++--
8 files changed, 398 insertions(+), 95 deletions(-)
base-commit: 8d70e364e866bdfca81eee24d0688fac9472cfb9
--
2.54.0 (Apple Git-157)
next reply other threads:[~2026-10-13 5:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 5:30 Joonho Lee [this message]
2026-10-13 5:30 ` [PATCH v1 1/5] ALSA: virtio: Notify queued PCM messages after send errors Joonho Lee
2026-10-13 5:40 ` sashiko-bot
2026-10-13 5:30 ` [PATCH v1 2/5] ALSA: virtio: Recover PCM state after a failed start Joonho Lee
2026-10-13 5:42 ` sashiko-bot
2026-10-13 5:30 ` [PATCH v1 3/5] ALSA: virtio: Retain control requests through device reset Joonho Lee
2026-10-13 5:43 ` sashiko-bot
2026-10-13 5:30 ` [PATCH v1 4/5] ALSA: virtio: Retain PCM DMA pages until messages are freed Joonho Lee
2026-10-13 5:39 ` sashiko-bot
2026-10-13 5:30 ` [PATCH v1 5/5] ALSA: virtio: Keep control payloads in refcounted messages Joonho Lee
2026-10-13 5:39 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1791867377.git.mynameisjune111@gmail.com \
--to=mynameisjune111@gmail.com \
--cc=anton.yakovlev@opensynergy.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mst@redhat.com \
--cc=mvaralar@redhat.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.