On Tue, Nov 10, 2026 at 02:39:35PM +0200, Manos Pitsidianakis wrote: > Add a check for the VIRTIO spec statement: > > 5.14.6.6.3.2 Driver Requirements: Stream Parameters > > period_bytes MUST be a divider buffer_bytes, i.e. buffer_bytes % > period_bytes == 0. > > Signed-off-by: Manos Pitsidianakis <[email protected]> > --- > hw/audio/virtio-snd.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c > index a6036d5b75..1cbc4da752 100644 > --- a/hw/audio/virtio-snd.c > +++ b/hw/audio/virtio-snd.c > @@ -380,6 +380,17 @@ uint32_t virtio_snd_set_pcm_params(VirtIOSound *s, > return cpu_to_le32(VIRTIO_SND_S_BAD_MSG); > } > > + if (le32_to_cpu(params->buffer_bytes) > + % le32_to_cpu(params->period_bytes) != 0) { > + error_report("%s: 5.14.6.6.3.2 period_bytes MUST be a divider of " > + "buffer_bytes, i.e. buffer_bytes %% period_bytes == 0. " > + "Got buffer_bytes = %"PRIu32", period_bytes = %"PRIu32, > + VIRTIO_DEVICE(s)->name, > + le32_to_cpu(params->buffer_bytes), > + le32_to_cpu(params->period_bytes)); > + return cpu_to_le32(VIRTIO_SND_S_BAD_MSG); > + } > + > st_params = virtio_snd_pcm_get_params(s, stream_id); > > st_params->buffer_bytes = le32_to_cpu(params->buffer_bytes); > > -- > 2.56.0
Reviewed-by: Jim MacArthur <[email protected]>
