2022-06-08 08:32:16

by Jason Wang

[permalink] [raw]
Subject: [PATCH] virtio-rng: make device ready before making request

Current virtio-rng does a entropy request before DRIVER_OK, this
violates the spec and kernel will ignore the interrupt after commit
8b4ec69d7e09 ("virtio: harden vring IRQ").

Fixing this by making device ready before the request.

Fixes: 8b4ec69d7e09 ("virtio: harden vring IRQ")
Reported-and-tested-by: [email protected]
Signed-off-by: Jason Wang <[email protected]>
---
drivers/char/hw_random/virtio-rng.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index e856df7e285c..a6f3a8a2aca6 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -159,6 +159,8 @@ static int probe_common(struct virtio_device *vdev)
goto err_find;
}

+ virtio_device_ready(vdev);
+
/* we always have a pending entropy request */
request_entropy(vi);

--
2.25.1


2022-06-08 12:43:44

by Laurent Vivier

[permalink] [raw]
Subject: Re: [PATCH] virtio-rng: make device ready before making request

On 08/06/2022 08:14, Jason Wang wrote:
> Current virtio-rng does a entropy request before DRIVER_OK, this
> violates the spec and kernel will ignore the interrupt after commit
> 8b4ec69d7e09 ("virtio: harden vring IRQ").
>
> Fixing this by making device ready before the request.
>
> Fixes: 8b4ec69d7e09 ("virtio: harden vring IRQ")
> Reported-and-tested-by: [email protected]
> Signed-off-by: Jason Wang <[email protected]>
> ---
> drivers/char/hw_random/virtio-rng.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
> index e856df7e285c..a6f3a8a2aca6 100644
> --- a/drivers/char/hw_random/virtio-rng.c
> +++ b/drivers/char/hw_random/virtio-rng.c
> @@ -159,6 +159,8 @@ static int probe_common(struct virtio_device *vdev)
> goto err_find;
> }
>
> + virtio_device_ready(vdev);
> +
> /* we always have a pending entropy request */
> request_entropy(vi);
>

Reviewed-by: Laurent Vivier <[email protected]>