]> Git Repo - linux.git/commitdiff
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
authorLinus Torvalds <[email protected]>
Fri, 15 Jun 2018 21:35:02 +0000 (06:35 +0900)
committerLinus Torvalds <[email protected]>
Fri, 15 Jun 2018 21:35:02 +0000 (06:35 +0900)
Pull virtio updates from Michael Tsirkin:
 "virtio, vhost: features, fixes

   - PCI virtual function support for virtio

   - DMA barriers for virtio strong barriers

   - bugfixes"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  virtio: update the comments for transport features
  virtio_pci: support enabling VFs
  vhost: fix info leak due to uninitialized memory
  virtio_ring: switch to dma_XX barriers for rpmsg

1  2 
drivers/vhost/vhost.c
drivers/virtio/virtio_pci_common.c

diff --combined drivers/vhost/vhost.c
index ce8c95b6365bbe020ed12078c1a7ae0c65c3cd96,9beefa6ed1ce014bb35fa005e67dc1828cd7cb7a..a502f1af4a213607adec4aa28fa6ae8eb9ce0389
@@@ -208,7 -208,7 +208,7 @@@ int vhost_poll_start(struct vhost_poll 
        if (poll->wqh)
                return 0;
  
 -      mask = file->f_op->poll(file, &poll->table);
 +      mask = vfs_poll(file, &poll->table);
        if (mask)
                vhost_poll_wakeup(&poll->wait, 0, 0, poll_to_key(mask));
        if (mask & EPOLLERR) {
@@@ -385,13 -385,10 +385,13 @@@ static long vhost_dev_alloc_iovecs(stru
  
        for (i = 0; i < dev->nvqs; ++i) {
                vq = dev->vqs[i];
 -              vq->indirect = kmalloc(sizeof *vq->indirect * UIO_MAXIOV,
 -                                     GFP_KERNEL);
 -              vq->log = kmalloc(sizeof *vq->log * UIO_MAXIOV, GFP_KERNEL);
 -              vq->heads = kmalloc(sizeof *vq->heads * UIO_MAXIOV, GFP_KERNEL);
 +              vq->indirect = kmalloc_array(UIO_MAXIOV,
 +                                           sizeof(*vq->indirect),
 +                                           GFP_KERNEL);
 +              vq->log = kmalloc_array(UIO_MAXIOV, sizeof(*vq->log),
 +                                      GFP_KERNEL);
 +              vq->heads = kmalloc_array(UIO_MAXIOV, sizeof(*vq->heads),
 +                                        GFP_KERNEL);
                if (!vq->indirect || !vq->log || !vq->heads)
                        goto err_nomem;
        }
@@@ -1289,8 -1286,7 +1289,8 @@@ static long vhost_set_memory(struct vho
                return -EOPNOTSUPP;
        if (mem.nregions > max_mem_regions)
                return -E2BIG;
 -      newmem = kvzalloc(size + mem.nregions * sizeof(*m->regions), GFP_KERNEL);
 +      newmem = kvzalloc(struct_size(newmem, regions, mem.nregions),
 +                      GFP_KERNEL);
        if (!newmem)
                return -ENOMEM;
  
@@@ -2349,6 -2345,9 +2349,9 @@@ struct vhost_msg_node *vhost_new_msg(st
        struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL);
        if (!node)
                return NULL;
+       /* Make sure all padding within the structure is initialized. */
+       memset(&node->msg, 0, sizeof node->msg);
        node->vq = vq;
        node->msg.type = type;
        return node;
index b563a4499cc86346572e23e1257e57cf034c5dc6,1d4467b2dc317d6ed9b85a4dc04b3bbe06366be2..705aebd74e560cd8d125cee28537e9734dabe518
@@@ -113,13 -113,12 +113,13 @@@ static int vp_request_msix_vectors(stru
  
        vp_dev->msix_vectors = nvectors;
  
 -      vp_dev->msix_names = kmalloc(nvectors * sizeof *vp_dev->msix_names,
 -                                   GFP_KERNEL);
 +      vp_dev->msix_names = kmalloc_array(nvectors,
 +                                         sizeof(*vp_dev->msix_names),
 +                                         GFP_KERNEL);
        if (!vp_dev->msix_names)
                goto error;
        vp_dev->msix_affinity_masks
 -              = kzalloc(nvectors * sizeof *vp_dev->msix_affinity_masks,
 +              = kcalloc(nvectors, sizeof(*vp_dev->msix_affinity_masks),
                          GFP_KERNEL);
        if (!vp_dev->msix_affinity_masks)
                goto error;
@@@ -578,6 -577,8 +578,8 @@@ static void virtio_pci_remove(struct pc
        struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
        struct device *dev = get_device(&vp_dev->vdev.dev);
  
+       pci_disable_sriov(pci_dev);
        unregister_virtio_device(&vp_dev->vdev);
  
        if (vp_dev->ioaddr)
        put_device(dev);
  }
  
+ static int virtio_pci_sriov_configure(struct pci_dev *pci_dev, int num_vfs)
+ {
+       struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
+       struct virtio_device *vdev = &vp_dev->vdev;
+       int ret;
+       if (!(vdev->config->get_status(vdev) & VIRTIO_CONFIG_S_DRIVER_OK))
+               return -EBUSY;
+       if (!__virtio_test_bit(vdev, VIRTIO_F_SR_IOV))
+               return -EINVAL;
+       if (pci_vfs_assigned(pci_dev))
+               return -EPERM;
+       if (num_vfs == 0) {
+               pci_disable_sriov(pci_dev);
+               return 0;
+       }
+       ret = pci_enable_sriov(pci_dev, num_vfs);
+       if (ret < 0)
+               return ret;
+       return num_vfs;
+ }
  static struct pci_driver virtio_pci_driver = {
        .name           = "virtio-pci",
        .id_table       = virtio_pci_id_table,
  #ifdef CONFIG_PM_SLEEP
        .driver.pm      = &virtio_pci_pm_ops,
  #endif
+       .sriov_configure = virtio_pci_sriov_configure,
  };
  
  module_pci_driver(virtio_pci_driver);
This page took 0.07416 seconds and 4 git commands to generate.