Skip to contentSkip to conversation

virtio_balloon: set DRIVER_OK before using device

PATCH In review Michael S. Tsirkin 2 participants 6 messages Mar 4, 2015 – Mar 9, 2015

Subsystems (2)
lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH 1/1 virtio_balloon: set DRIVER_OK before using device

virtio spec requires that all drivers set DRIVER_OK before using devices. While balloon isn't yet included in the virtio 1 spec, previous spec versions also required this.

virtio balloon might violate this rule: probe calls kthread_run before setting DRIVER_OK, which might run immediately and cause balloon to inflate/deflate.

To fix, call virtio_device_ready before running the kthread.

---
 drivers/virtio/virtio_balloon.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
index 5a6ad6d..6a356e3 100644
@@ -508,6 +508,8 @@ static int virtballoon_probe(struct virtio_device *vdev)
 	if (err < 0)
 		goto out_oom_notify;
 
+	virtio_device_ready(vdev);
+
 	vb->thread = kthread_run(balloon, vb, "vballoon");
 	if (IS_ERR(vb->thread)) {
 		err = PTR_ERR(vb->thread);
Signature · 1 line
MST
#1 lore raw
Quoted 5 lines · Michael S. Tsirkin

virtio spec requires that all drivers set DRIVER_OK before using devices. While balloon isn't yet included in the virtio 1 spec, previous spec versions also required this.

Quoted 7 lines

virtio balloon might violate this rule: probe calls kthread_run before setting DRIVER_OK, which might run immediately and cause balloon to inflate/deflate.

To fix, call virtio_device_ready before running the kthread.

Replied, CC'd stable.

Thanks,
Rusty.

Quoted 19 lines
---
 drivers/virtio/virtio_balloon.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
index 5a6ad6d..6a356e3 100644
@@ -508,6 +508,8 @@ static int virtballoon_probe(struct virtio_device *vdev)
 	if (err < 0)
 		goto out_oom_notify;
 
+	virtio_device_ready(vdev);
+
 	vb->thread = kthread_run(balloon, vb, "vballoon");
 	if (IS_ERR(vb->thread)) {
 		err = PTR_ERR(vb->thread);
Signature · 1 line
MST
author maintainer
#2 lore raw
Quoted 10 lines · Rusty Russell
Quoted 9 lines · Michael S. Tsirkin

virtio spec requires that all drivers set DRIVER_OK before using devices. While balloon isn't yet included in the virtio 1 spec, previous spec versions also required this.

virtio balloon might violate this rule: probe calls kthread_run before setting DRIVER_OK, which might run immediately and cause balloon to inflate/deflate.

Quoted 5 lines
Quoted 3 lines

To fix, call virtio_device_ready before running the kthread.

Replied, CC'd stable.

Did you mean applied?

Quoted 23 lines

Thanks,
Rusty.

Quoted 19 lines
---
 drivers/virtio/virtio_balloon.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
index 5a6ad6d..6a356e3 100644
@@ -508,6 +508,8 @@ static int virtballoon_probe(struct virtio_device *vdev)
 	if (err < 0)
 		goto out_oom_notify;
 
+	virtio_device_ready(vdev);
+
 	vb->thread = kthread_run(balloon, vb, "vballoon");
 	if (IS_ERR(vb->thread)) {
 		err = PTR_ERR(vb->thread);
Signature · 1 line
MST
author maintainer
#3 lore raw
In reply to Rusty Russell
Quoted 10 lines · Rusty Russell
Quoted 9 lines · Michael S. Tsirkin

virtio spec requires that all drivers set DRIVER_OK before using devices. While balloon isn't yet included in the virtio 1 spec, previous spec versions also required this.

virtio balloon might violate this rule: probe calls kthread_run before setting DRIVER_OK, which might run immediately and cause balloon to inflate/deflate.

Quoted 5 lines
Quoted 3 lines

To fix, call virtio_device_ready before running the kthread.

Replied, CC'd stable.

Did you mean applied?

Quoted 23 lines

Thanks,
Rusty.

Quoted 19 lines
---
 drivers/virtio/virtio_balloon.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
index 5a6ad6d..6a356e3 100644
@@ -508,6 +508,8 @@ static int virtballoon_probe(struct virtio_device *vdev)
 	if (err < 0)
 		goto out_oom_notify;
 
+	virtio_device_ready(vdev);
+
 	vb->thread = kthread_run(balloon, vb, "vballoon");
 	if (IS_ERR(vb->thread)) {
 		err = PTR_ERR(vb->thread);
Signature · 1 line
MST
#4 lore raw
Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines · Rusty Russell
Quoted 9 lines · Michael S. Tsirkin

virtio spec requires that all drivers set DRIVER_OK before using devices. While balloon isn't yet included in the virtio 1 spec, previous spec versions also required this.

virtio balloon might violate this rule: probe calls kthread_run before setting DRIVER_OK, which might run immediately and cause balloon to inflate/deflate.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

To fix, call virtio_device_ready before running the kthread.

Replied, CC'd stable.

Did you mean applied?

I stand erected.

Franks,
Rusty.

#5 lore raw
In reply to Michael S. Tsirkin
Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines · Rusty Russell
Quoted 9 lines · Michael S. Tsirkin

virtio spec requires that all drivers set DRIVER_OK before using devices. While balloon isn't yet included in the virtio 1 spec, previous spec versions also required this.

virtio balloon might violate this rule: probe calls kthread_run before setting DRIVER_OK, which might run immediately and cause balloon to inflate/deflate.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

To fix, call virtio_device_ready before running the kthread.

Replied, CC'd stable.

Did you mean applied?

I stand erected.

Franks,
Rusty.