On Wed, Sep 13, 2023 at 05:04:24PM +0200, Matias Ezequiel Vara Larsen wrote:> Hello, > > This email is to report a behavior of the Linux virtio-sound driver that > looks like it is not conforming to the VirtIO specification. The kernel > driver is moving buffers from the used ring to the available ring > without knowing if the content has been updated from the user. If the > device picks up buffers from the available ring just after it is > notified, it happens that the content is old.Then, what happens, exactly? Do things still work?> This problem can be fixed > by waiting a period of time after the device dequeues a buffer from the > available ring. The driver should not be allowed to change the content > of a buffer in the available ring. When buffers are enqueued in the > available ring, the device can consume them immediately. > > 1. Is the actual driver implementation following the spec? > 2. Shall the spec be extended to support such a use-case? > > Thanks, Matias
Matias Ezequiel Vara Larsen
2023-Sep-19 14:18 UTC
virtio-sound linux driver conformance to spec
On Tue, Sep 19, 2023 at 05:43:56AM -0400, Michael S. Tsirkin wrote:> On Wed, Sep 13, 2023 at 05:04:24PM +0200, Matias Ezequiel Vara Larsen wrote: > > Hello, > > > > This email is to report a behavior of the Linux virtio-sound driver that > > looks like it is not conforming to the VirtIO specification. The kernel > > driver is moving buffers from the used ring to the available ring > > without knowing if the content has been updated from the user. If the > > device picks up buffers from the available ring just after it is > > notified, it happens that the content is old. > > Then, what happens, exactly? Do things still work?We are currently developing a vhost-user backend for virtio-sound and what happens is that if the backend implementation decides to copy the content of a buffer from a request that just arrived to the available ring, it gets the old content thus reproducing some sections two times. For example, we observe that when issuing `aplay FrontLeft.wav`, we hear `Front, front left...`. To fix this issue, our current implementation delays reading from guest memory just until the audio engine requires. However, the first implementation shall also work since it is conforming to the specification. Matias