OSDN Git Service

hwrng: virtio - add an internal buffer
authorLaurent Vivier <lvivier@redhat.com>
Thu, 28 Oct 2021 10:11:08 +0000 (12:11 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 1 Nov 2021 09:26:47 +0000 (05:26 -0400)
commitbf3175bc50a3754dc427e2f5046e17a9fafc8be7
treef9e87bffbd3de715dd8758f42d0c6af4ecc6c8d6
parentedf747affc41a18ccc3a616813d4c2b6d38b46ce
hwrng: virtio - add an internal buffer

hwrng core uses two buffers that can be mixed in the
virtio-rng queue.

If the buffer is provided with wait=0 it is enqueued in the
virtio-rng queue but unused by the caller.
On the next call, core provides another buffer but the
first one is filled instead and the new one queued.
And the caller reads the data from the new one that is not
updated, and the data in the first one are lost.

To avoid this mix, virtio-rng needs to use its own unique
internal buffer at a cost of a data copy to the caller buffer.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Link: https://lore.kernel.org/r/20211028101111.128049-2-lvivier@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/char/hw_random/virtio-rng.c