Skip to content

Commit 3bb50f8

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael Tsirkin: "Fixes up some issues in rc5" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: vhost-vdpa: Fix the wrong input in config_cb VDUSE: fix documentation underline warning Revert "virtio-blk: Add validation for block size in config space" vhost_vdpa: unset vq irq before freeing irq virtio: write back F_VERSION_1 before validate
2 parents be9eb2f + bcef935 commit 3bb50f8

File tree

4 files changed

+23
-37
lines changed

4 files changed

+23
-37
lines changed

Documentation/userspace-api/vduse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ types can be added after the security issue of corresponding device driver
1818
is clarified or fixed in the future.
1919

2020
Create/Destroy VDUSE devices
21-
------------------------
21+
----------------------------
2222

2323
VDUSE devices are created as follows:
2424

drivers/block/virtio_blk.c

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -689,28 +689,6 @@ static const struct blk_mq_ops virtio_mq_ops = {
689689
static unsigned int virtblk_queue_depth;
690690
module_param_named(queue_depth, virtblk_queue_depth, uint, 0444);
691691

692-
static int virtblk_validate(struct virtio_device *vdev)
693-
{
694-
u32 blk_size;
695-
696-
if (!vdev->config->get) {
697-
dev_err(&vdev->dev, "%s failure: config access disabled\n",
698-
__func__);
699-
return -EINVAL;
700-
}
701-
702-
if (!virtio_has_feature(vdev, VIRTIO_BLK_F_BLK_SIZE))
703-
return 0;
704-
705-
blk_size = virtio_cread32(vdev,
706-
offsetof(struct virtio_blk_config, blk_size));
707-
708-
if (blk_size < SECTOR_SIZE || blk_size > PAGE_SIZE)
709-
__virtio_clear_bit(vdev, VIRTIO_BLK_F_BLK_SIZE);
710-
711-
return 0;
712-
}
713-
714692
static int virtblk_probe(struct virtio_device *vdev)
715693
{
716694
struct virtio_blk *vblk;
@@ -722,6 +700,12 @@ static int virtblk_probe(struct virtio_device *vdev)
722700
u8 physical_block_exp, alignment_offset;
723701
unsigned int queue_depth;
724702

703+
if (!vdev->config->get) {
704+
dev_err(&vdev->dev, "%s failure: config access disabled\n",
705+
__func__);
706+
return -EINVAL;
707+
}
708+
725709
err = ida_simple_get(&vd_index_ida, 0, minor_to_index(1 << MINORBITS),
726710
GFP_KERNEL);
727711
if (err < 0)
@@ -836,14 +820,6 @@ static int virtblk_probe(struct virtio_device *vdev)
836820
else
837821
blk_size = queue_logical_block_size(q);
838822

839-
if (blk_size < SECTOR_SIZE || blk_size > PAGE_SIZE) {
840-
dev_err(&vdev->dev,
841-
"block size is changed unexpectedly, now is %u\n",
842-
blk_size);
843-
err = -EINVAL;
844-
goto out_cleanup_disk;
845-
}
846-
847823
/* Use topology information if available */
848824
err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY,
849825
struct virtio_blk_config, physical_block_exp,
@@ -1009,7 +985,6 @@ static struct virtio_driver virtio_blk = {
1009985
.driver.name = KBUILD_MODNAME,
1010986
.driver.owner = THIS_MODULE,
1011987
.id_table = id_table,
1012-
.validate = virtblk_validate,
1013988
.probe = virtblk_probe,
1014989
.remove = virtblk_remove,
1015990
.config_changed = virtblk_config_changed,

drivers/vhost/vdpa.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
173173
if (status != 0 && (ops->get_status(vdpa) & ~status) != 0)
174174
return -EINVAL;
175175

176+
if ((status_old & VIRTIO_CONFIG_S_DRIVER_OK) && !(status & VIRTIO_CONFIG_S_DRIVER_OK))
177+
for (i = 0; i < nvqs; i++)
178+
vhost_vdpa_unsetup_vq_irq(v, i);
179+
176180
if (status == 0) {
177181
ret = ops->reset(vdpa);
178182
if (ret)
@@ -184,10 +188,6 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
184188
for (i = 0; i < nvqs; i++)
185189
vhost_vdpa_setup_vq_irq(v, i);
186190

187-
if ((status_old & VIRTIO_CONFIG_S_DRIVER_OK) && !(status & VIRTIO_CONFIG_S_DRIVER_OK))
188-
for (i = 0; i < nvqs; i++)
189-
vhost_vdpa_unsetup_vq_irq(v, i);
190-
191191
return 0;
192192
}
193193

@@ -322,7 +322,7 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
322322
struct eventfd_ctx *ctx;
323323

324324
cb.callback = vhost_vdpa_config_cb;
325-
cb.private = v->vdpa;
325+
cb.private = v;
326326
if (copy_from_user(&fd, argp, sizeof(fd)))
327327
return -EFAULT;
328328

drivers/virtio/virtio.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,17 @@ static int virtio_dev_probe(struct device *_d)
239239
driver_features_legacy = driver_features;
240240
}
241241

242+
/*
243+
* Some devices detect legacy solely via F_VERSION_1. Write
244+
* F_VERSION_1 to force LE config space accesses before FEATURES_OK for
245+
* these when needed.
246+
*/
247+
if (drv->validate && !virtio_legacy_is_little_endian()
248+
&& device_features & BIT_ULL(VIRTIO_F_VERSION_1)) {
249+
dev->features = BIT_ULL(VIRTIO_F_VERSION_1);
250+
dev->config->finalize_features(dev);
251+
}
252+
242253
if (device_features & (1ULL << VIRTIO_F_VERSION_1))
243254
dev->features = driver_features & device_features;
244255
else

0 commit comments

Comments
 (0)