Skip to content

Commit abe71eb

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 all over the place, most notably fixes for latent bugs in drivers that got exposed by suppressing interrupts before DRIVER_OK, which in turn has been done by 8b4ec69 ("virtio: harden vring IRQ")" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: um: virt-pci: set device ready in probe() vdpa: make get_vq_group and set_group_asid optional virtio: Fix all occurences of the "the the" typo vduse: Fix NULL pointer dereference on sysfs access vringh: Fix loop descriptors check in the indirect cases vdpa/mlx5: clean up indenting in handle_ctrl_vlan() vdpa/mlx5: fix error code for deleting vlan virtio-mmio: fix missing put_device() when vm_cmdline_parent registration failed vdpa/mlx5: Fix syntax errors in comments virtio-rng: make device ready before making request
2 parents 0678afa + eacea84 commit abe71eb

File tree

9 files changed

+32
-15
lines changed

9 files changed

+32
-15
lines changed

arch/um/drivers/virt-pci.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,8 @@ static int um_pci_init_vqs(struct um_pci_device *dev)
544544
dev->cmd_vq = vqs[0];
545545
dev->irq_vq = vqs[1];
546546

547+
virtio_device_ready(dev->vdev);
548+
547549
for (i = 0; i < NUM_IRQ_MSGS; i++) {
548550
void *msg = kzalloc(MAX_IRQ_MSG_SIZE, GFP_KERNEL);
549551

@@ -587,7 +589,7 @@ static int um_pci_virtio_probe(struct virtio_device *vdev)
587589
dev->irq = irq_alloc_desc(numa_node_id());
588590
if (dev->irq < 0) {
589591
err = dev->irq;
590-
goto error;
592+
goto err_reset;
591593
}
592594
um_pci_devices[free].dev = dev;
593595
vdev->priv = dev;
@@ -604,6 +606,9 @@ static int um_pci_virtio_probe(struct virtio_device *vdev)
604606

605607
um_pci_rescan();
606608
return 0;
609+
err_reset:
610+
virtio_reset_device(vdev);
611+
vdev->config->del_vqs(vdev);
607612
error:
608613
mutex_unlock(&um_pci_mtx);
609614
kfree(dev);

drivers/char/hw_random/virtio-rng.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ static int probe_common(struct virtio_device *vdev)
159159
goto err_find;
160160
}
161161

162+
virtio_device_ready(vdev);
163+
162164
/* we always have a pending entropy request */
163165
request_entropy(vi);
164166

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ struct mlx5_vdpa_virtqueue {
107107

108108
/* Resources for implementing the notification channel from the device
109109
* to the driver. fwqp is the firmware end of an RC connection; the
110-
* other end is vqqp used by the driver. cq is is where completions are
110+
* other end is vqqp used by the driver. cq is where completions are
111111
* reported.
112112
*/
113113
struct mlx5_vdpa_cq cq;
@@ -1814,12 +1814,13 @@ static virtio_net_ctrl_ack handle_ctrl_vlan(struct mlx5_vdpa_dev *mvdev, u8 cmd)
18141814

18151815
id = mlx5vdpa16_to_cpu(mvdev, vlan);
18161816
mac_vlan_del(ndev, ndev->config.mac, id, true);
1817+
status = VIRTIO_NET_OK;
18171818
break;
18181819
default:
1819-
break;
1820-
}
1820+
break;
1821+
}
18211822

1822-
return status;
1823+
return status;
18231824
}
18241825

18251826
static void mlx5_cvq_kick_handler(struct work_struct *work)

drivers/vdpa/vdpa_user/vduse_dev.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,9 +1345,9 @@ static int vduse_create_dev(struct vduse_dev_config *config,
13451345

13461346
dev->minor = ret;
13471347
dev->msg_timeout = VDUSE_MSG_DEFAULT_TIMEOUT;
1348-
dev->dev = device_create(vduse_class, NULL,
1349-
MKDEV(MAJOR(vduse_major), dev->minor),
1350-
dev, "%s", config->name);
1348+
dev->dev = device_create_with_groups(vduse_class, NULL,
1349+
MKDEV(MAJOR(vduse_major), dev->minor),
1350+
dev, vduse_dev_groups, "%s", config->name);
13511351
if (IS_ERR(dev->dev)) {
13521352
ret = PTR_ERR(dev->dev);
13531353
goto err_dev;
@@ -1596,7 +1596,6 @@ static int vduse_init(void)
15961596
return PTR_ERR(vduse_class);
15971597

15981598
vduse_class->devnode = vduse_devnode;
1599-
vduse_class->dev_groups = vduse_dev_groups;
16001599

16011600
ret = alloc_chrdev_region(&vduse_major, 0, VDUSE_DEV_MAX, "vduse");
16021601
if (ret)

drivers/vhost/vdpa.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
499499
ops->set_vq_ready(vdpa, idx, s.num);
500500
return 0;
501501
case VHOST_VDPA_GET_VRING_GROUP:
502+
if (!ops->get_vq_group)
503+
return -EOPNOTSUPP;
502504
s.index = idx;
503505
s.num = ops->get_vq_group(vdpa, idx);
504506
if (s.num >= vdpa->ngroups)

drivers/vhost/vringh.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ __vringh_iov(struct vringh *vrh, u16 i,
292292
int (*copy)(const struct vringh *vrh,
293293
void *dst, const void *src, size_t len))
294294
{
295-
int err, count = 0, up_next, desc_max;
295+
int err, count = 0, indirect_count = 0, up_next, desc_max;
296296
struct vring_desc desc, *descs;
297297
struct vringh_range range = { -1ULL, 0 }, slowrange;
298298
bool slow = false;
@@ -349,7 +349,12 @@ __vringh_iov(struct vringh *vrh, u16 i,
349349
continue;
350350
}
351351

352-
if (count++ == vrh->vring.num) {
352+
if (up_next == -1)
353+
count++;
354+
else
355+
indirect_count++;
356+
357+
if (count > vrh->vring.num || indirect_count > desc_max) {
353358
vringh_bad("Descriptor loop in %p", descs);
354359
err = -ELOOP;
355360
goto fail;
@@ -411,6 +416,7 @@ __vringh_iov(struct vringh *vrh, u16 i,
411416
i = return_from_indirect(vrh, &up_next,
412417
&descs, &desc_max);
413418
slow = false;
419+
indirect_count = 0;
414420
} else
415421
break;
416422
}

drivers/virtio/virtio_mmio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static void vm_set_status(struct virtio_device *vdev, u8 status)
255255

256256
/*
257257
* Per memory-barriers.txt, wmb() is not needed to guarantee
258-
* that the the cache coherent memory writes have completed
258+
* that the cache coherent memory writes have completed
259259
* before writing to the MMIO region.
260260
*/
261261
writel(status, vm_dev->base + VIRTIO_MMIO_STATUS);
@@ -701,6 +701,7 @@ static int vm_cmdline_set(const char *device,
701701
if (!vm_cmdline_parent_registered) {
702702
err = device_register(&vm_cmdline_parent);
703703
if (err) {
704+
put_device(&vm_cmdline_parent);
704705
pr_err("Failed to register parent device!\n");
705706
return err;
706707
}

drivers/virtio/virtio_pci_modern_dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ void vp_modern_set_status(struct virtio_pci_modern_device *mdev,
469469

470470
/*
471471
* Per memory-barriers.txt, wmb() is not needed to guarantee
472-
* that the the cache coherent memory writes have completed
472+
* that the cache coherent memory writes have completed
473473
* before writing to the MMIO region.
474474
*/
475475
vp_iowrite8(status, &cfg->device_status);

include/linux/vdpa.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ struct vdpa_map_file {
178178
* for the device
179179
* @vdev: vdpa device
180180
* Returns virtqueue algin requirement
181-
* @get_vq_group: Get the group id for a specific virtqueue
181+
* @get_vq_group: Get the group id for a specific
182+
* virtqueue (optional)
182183
* @vdev: vdpa device
183184
* @idx: virtqueue index
184185
* Returns u32: group id for this virtqueue
@@ -243,7 +244,7 @@ struct vdpa_map_file {
243244
* Returns the iova range supported by
244245
* the device.
245246
* @set_group_asid: Set address space identifier for a
246-
* virtqueue group
247+
* virtqueue group (optional)
247248
* @vdev: vdpa device
248249
* @group: virtqueue group
249250
* @asid: address space id for this group

0 commit comments

Comments
 (0)