Skip to content

Commit ef688e1

Browse files
committed
virtio: meet virtio spec by finalizing features before using device
Virtio devices are supposed to negotiate features before they start using the device, but the current code doesn't do this. This is because the driver's probe() function invariably has to add buffers to a virtqueue, or probe the disk (virtio_blk). This currently doesn't matter since no existing backend is strict about the feature negotiation. But it's possible to imagine a future feature which completely changes how a device operates: in this case, we'd need to acknowledge it before using the device. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 20f77f5 commit ef688e1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎drivers/virtio/virtio.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,14 @@ static int virtio_dev_probe(struct device *_d)
118118
if (device_features & (1 << i))
119119
set_bit(i, dev->features);
120120

121+
dev->config->finalize_features(dev);
122+
121123
err = drv->probe(dev);
122124
if (err)
123125
add_status(dev, VIRTIO_CONFIG_S_FAILED);
124-
else {
125-
dev->config->finalize_features(dev);
126+
else
126127
add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
127-
}
128+
128129
return err;
129130
}
130131

0 commit comments

Comments
 (0)