* [PATCH v3 0/2] virtio-rng: fix hotunplug
@ 2014-09-10 6:11 Amos Kong
2014-09-10 6:11 ` [PATCH v3 1/2] virtio-rng: fix stuck of hot-unplugging busy device Amos Kong
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Amos Kong @ 2014-09-10 6:11 UTC (permalink / raw)
To: virtualization; +Cc: amit.shah, stable, kvm
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1121540
When we try to hot-unplugging a busy virtio-rng device, the device
can't be removed. And the reading process in guest gets stuck.
Those two patches fixed this issue by completing have_data completion
and preventing invalid reading.
Thanks for the help of Amit.
Cc: stable@vger.kernel.org
V2: reset data_avail (Amit)
adjust unregister order
V3: split patch, update commitlog
Amos Kong (2):
virtio-rng: fix stuck of hot-unplugging busy device
virtio-rng: skip reading when we start to remove the device
drivers/char/hw_random/virtio-rng.c | 7 +++++++
1 file changed, 7 insertions(+)
--
1.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/2] virtio-rng: fix stuck of hot-unplugging busy device
2014-09-10 6:11 [PATCH v3 0/2] virtio-rng: fix hotunplug Amos Kong
@ 2014-09-10 6:11 ` Amos Kong
2014-09-10 7:03 ` Amit Shah
2014-09-10 6:11 ` [PATCH v3 2/2] virtio-rng: skip reading when we start to remove the device Amos Kong
[not found] ` <1410329497-14349-3-git-send-email-akong@redhat.com>
2 siblings, 1 reply; 7+ messages in thread
From: Amos Kong @ 2014-09-10 6:11 UTC (permalink / raw)
To: virtualization; +Cc: amit.shah, stable, kvm
When we try to hot-remove a busy virtio-rng device from QEMU monitor,
the device can't be hot-removed. Because virtio-rng driver hangs at
wait_for_completion_killable().
This patch exits the waiting by completing have_data completion before
unregistering, resets data_avail to avoid the hwrng core use wrong
buffer bytes.
Signed-off-by: Amos Kong <akong@redhat.com>
Cc: stable@vger.kernel.org
---
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 2e3139e..849b228 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -137,6 +137,8 @@ static void remove_common(struct virtio_device *vdev)
{
struct virtrng_info *vi = vdev->priv;
+ vi->data_avail = 0;
+ complete(&vi->have_data);
vdev->config->reset(vdev);
vi->busy = false;
if (vi->hwrng_register_done)
--
1.9.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/2] virtio-rng: skip reading when we start to remove the device
2014-09-10 6:11 [PATCH v3 0/2] virtio-rng: fix hotunplug Amos Kong
2014-09-10 6:11 ` [PATCH v3 1/2] virtio-rng: fix stuck of hot-unplugging busy device Amos Kong
@ 2014-09-10 6:11 ` Amos Kong
[not found] ` <1410329497-14349-3-git-send-email-akong@redhat.com>
2 siblings, 0 replies; 7+ messages in thread
From: Amos Kong @ 2014-09-10 6:11 UTC (permalink / raw)
To: virtualization; +Cc: amit.shah, stable, kvm
Before we really unregister the hwrng device, reading will get stuck if
the virtio device is reset. We should return error for reading when we
start to remove the device.
Signed-off-by: Amos Kong <akong@redhat.com>
Cc: stable@vger.kernel.org
---
drivers/char/hw_random/virtio-rng.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index 849b228..132c9cc 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -36,6 +36,7 @@ struct virtrng_info {
int index;
bool busy;
bool hwrng_register_done;
+ bool hwrng_removed;
};
@@ -68,6 +69,9 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
int ret;
struct virtrng_info *vi = (struct virtrng_info *)rng->priv;
+ if (vi->hwrng_removed)
+ return -ENODEV;
+
if (!vi->busy) {
vi->busy = true;
init_completion(&vi->have_data);
@@ -137,6 +141,7 @@ static void remove_common(struct virtio_device *vdev)
{
struct virtrng_info *vi = vdev->priv;
+ vi->hwrng_removed = true;
vi->data_avail = 0;
complete(&vi->have_data);
vdev->config->reset(vdev);
--
1.9.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/2] virtio-rng: fix stuck of hot-unplugging busy device
2014-09-10 6:11 ` [PATCH v3 1/2] virtio-rng: fix stuck of hot-unplugging busy device Amos Kong
@ 2014-09-10 7:03 ` Amit Shah
2014-09-11 12:50 ` Rusty Russell
0 siblings, 1 reply; 7+ messages in thread
From: Amit Shah @ 2014-09-10 7:03 UTC (permalink / raw)
To: Amos Kong; +Cc: stable, kvm, virtualization
On (Wed) 10 Sep 2014 [14:11:36], Amos Kong wrote:
> When we try to hot-remove a busy virtio-rng device from QEMU monitor,
> the device can't be hot-removed. Because virtio-rng driver hangs at
> wait_for_completion_killable().
>
> This patch exits the waiting by completing have_data completion before
> unregistering, resets data_avail to avoid the hwrng core use wrong
> buffer bytes.
>
> Signed-off-by: Amos Kong <akong@redhat.com>
> Cc: stable@vger.kernel.org
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Amit
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 2/2] virtio-rng: skip reading when we start to remove the device
[not found] ` <1410329497-14349-3-git-send-email-akong@redhat.com>
@ 2014-09-10 7:04 ` Amit Shah
2014-09-12 1:37 ` Rusty Russell
0 siblings, 1 reply; 7+ messages in thread
From: Amit Shah @ 2014-09-10 7:04 UTC (permalink / raw)
To: Amos Kong; +Cc: stable, kvm, virtualization
On (Wed) 10 Sep 2014 [14:11:37], Amos Kong wrote:
> Before we really unregister the hwrng device, reading will get stuck if
> the virtio device is reset. We should return error for reading when we
> start to remove the device.
>
> Signed-off-by: Amos Kong <akong@redhat.com>
> Cc: stable@vger.kernel.org
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Amit
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/2] virtio-rng: fix stuck of hot-unplugging busy device
2014-09-10 7:03 ` Amit Shah
@ 2014-09-11 12:50 ` Rusty Russell
0 siblings, 0 replies; 7+ messages in thread
From: Rusty Russell @ 2014-09-11 12:50 UTC (permalink / raw)
To: Amit Shah, Amos Kong; +Cc: stable, kvm, virtualization
Amit Shah <amit.shah@redhat.com> writes:
> On (Wed) 10 Sep 2014 [14:11:36], Amos Kong wrote:
>> When we try to hot-remove a busy virtio-rng device from QEMU monitor,
>> the device can't be hot-removed. Because virtio-rng driver hangs at
>> wait_for_completion_killable().
>>
>> This patch exits the waiting by completing have_data completion before
>> unregistering, resets data_avail to avoid the hwrng core use wrong
>> buffer bytes.
>>
>> Signed-off-by: Amos Kong <akong@redhat.com>
>> Cc: stable@vger.kernel.org
>
> Reviewed-by: Amit Shah <amit.shah@redhat.com>
Thanks, applied.
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 2/2] virtio-rng: skip reading when we start to remove the device
2014-09-10 7:04 ` Amit Shah
@ 2014-09-12 1:37 ` Rusty Russell
0 siblings, 0 replies; 7+ messages in thread
From: Rusty Russell @ 2014-09-12 1:37 UTC (permalink / raw)
To: Amit Shah, Amos Kong; +Cc: stable, kvm, virtualization
Amit Shah <amit.shah@redhat.com> writes:
> On (Wed) 10 Sep 2014 [14:11:37], Amos Kong wrote:
>> Before we really unregister the hwrng device, reading will get stuck if
>> the virtio device is reset. We should return error for reading when we
>> start to remove the device.
>>
>> Signed-off-by: Amos Kong <akong@redhat.com>
>> Cc: stable@vger.kernel.org
>
> Reviewed-by: Amit Shah <amit.shah@redhat.com>
Thanks, applied.
They're sitting in my fixes branch. If there are no screams from
linux-next, I'll push to Linus Monday.
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-09-12 1:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-10 6:11 [PATCH v3 0/2] virtio-rng: fix hotunplug Amos Kong
2014-09-10 6:11 ` [PATCH v3 1/2] virtio-rng: fix stuck of hot-unplugging busy device Amos Kong
2014-09-10 7:03 ` Amit Shah
2014-09-11 12:50 ` Rusty Russell
2014-09-10 6:11 ` [PATCH v3 2/2] virtio-rng: skip reading when we start to remove the device Amos Kong
[not found] ` <1410329497-14349-3-git-send-email-akong@redhat.com>
2014-09-10 7:04 ` Amit Shah
2014-09-12 1:37 ` Rusty Russell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).