Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

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

+61 -6
+3
drivers/vhost/vhost.c
··· 2349 2349 struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL); 2350 2350 if (!node) 2351 2351 return NULL; 2352 + 2353 + /* Make sure all padding within the structure is initialized. */ 2354 + memset(&node->msg, 0, sizeof node->msg); 2352 2355 node->vq = vq; 2353 2356 node->msg.type = type; 2354 2357 return node;
+30
drivers/virtio/virtio_pci_common.c
··· 578 578 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); 579 579 struct device *dev = get_device(&vp_dev->vdev.dev); 580 580 581 + pci_disable_sriov(pci_dev); 582 + 581 583 unregister_virtio_device(&vp_dev->vdev); 582 584 583 585 if (vp_dev->ioaddr) ··· 591 589 put_device(dev); 592 590 } 593 591 592 + static int virtio_pci_sriov_configure(struct pci_dev *pci_dev, int num_vfs) 593 + { 594 + struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); 595 + struct virtio_device *vdev = &vp_dev->vdev; 596 + int ret; 597 + 598 + if (!(vdev->config->get_status(vdev) & VIRTIO_CONFIG_S_DRIVER_OK)) 599 + return -EBUSY; 600 + 601 + if (!__virtio_test_bit(vdev, VIRTIO_F_SR_IOV)) 602 + return -EINVAL; 603 + 604 + if (pci_vfs_assigned(pci_dev)) 605 + return -EPERM; 606 + 607 + if (num_vfs == 0) { 608 + pci_disable_sriov(pci_dev); 609 + return 0; 610 + } 611 + 612 + ret = pci_enable_sriov(pci_dev, num_vfs); 613 + if (ret < 0) 614 + return ret; 615 + 616 + return num_vfs; 617 + } 618 + 594 619 static struct pci_driver virtio_pci_driver = { 595 620 .name = "virtio-pci", 596 621 .id_table = virtio_pci_id_table, ··· 626 597 #ifdef CONFIG_PM_SLEEP 627 598 .driver.pm = &virtio_pci_pm_ops, 628 599 #endif 600 + .sriov_configure = virtio_pci_sriov_configure, 629 601 }; 630 602 631 603 module_pci_driver(virtio_pci_driver);
+14
drivers/virtio/virtio_pci_modern.c
··· 153 153 return features; 154 154 } 155 155 156 + static void vp_transport_features(struct virtio_device *vdev, u64 features) 157 + { 158 + struct virtio_pci_device *vp_dev = to_vp_device(vdev); 159 + struct pci_dev *pci_dev = vp_dev->pci_dev; 160 + 161 + if ((features & BIT_ULL(VIRTIO_F_SR_IOV)) && 162 + pci_find_ext_capability(pci_dev, PCI_EXT_CAP_ID_SRIOV)) 163 + __virtio_set_bit(vdev, VIRTIO_F_SR_IOV); 164 + } 165 + 156 166 /* virtio config->finalize_features() implementation */ 157 167 static int vp_finalize_features(struct virtio_device *vdev) 158 168 { 159 169 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 170 + u64 features = vdev->features; 160 171 161 172 /* Give virtio_ring a chance to accept features. */ 162 173 vring_transport_features(vdev); 174 + 175 + /* Give virtio_pci a chance to accept features. */ 176 + vp_transport_features(vdev, features); 163 177 164 178 if (!__virtio_test_bit(vdev, VIRTIO_F_VERSION_1)) { 165 179 dev_err(&vdev->dev, "virtio: device uses modern interface "
+2 -2
include/linux/virtio_ring.h
··· 35 35 if (weak_barriers) 36 36 virt_rmb(); 37 37 else 38 - rmb(); 38 + dma_rmb(); 39 39 } 40 40 41 41 static inline void virtio_wmb(bool weak_barriers) ··· 43 43 if (weak_barriers) 44 44 virt_wmb(); 45 45 else 46 - wmb(); 46 + dma_wmb(); 47 47 } 48 48 49 49 static inline void virtio_store_mb(bool weak_barriers,
+12 -4
include/uapi/linux/virtio_config.h
··· 45 45 /* We've given up on this device. */ 46 46 #define VIRTIO_CONFIG_S_FAILED 0x80 47 47 48 - /* Some virtio feature bits (currently bits 28 through 32) are reserved for the 49 - * transport being used (eg. virtio_ring), the rest are per-device feature 50 - * bits. */ 48 + /* 49 + * Virtio feature bits VIRTIO_TRANSPORT_F_START through 50 + * VIRTIO_TRANSPORT_F_END are reserved for the transport 51 + * being used (e.g. virtio_ring, virtio_pci etc.), the 52 + * rest are per-device feature bits. 53 + */ 51 54 #define VIRTIO_TRANSPORT_F_START 28 52 - #define VIRTIO_TRANSPORT_F_END 34 55 + #define VIRTIO_TRANSPORT_F_END 38 53 56 54 57 #ifndef VIRTIO_CONFIG_NO_LEGACY 55 58 /* Do we get callbacks when the ring is completely used, even if we've ··· 74 71 * this is for compatibility with legacy systems. 75 72 */ 76 73 #define VIRTIO_F_IOMMU_PLATFORM 33 74 + 75 + /* 76 + * Does the device support Single Root I/O Virtualization? 77 + */ 78 + #define VIRTIO_F_SR_IOV 37 77 79 #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */