aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-08-05vhost-vdpa: support IOTLB batching hintsJason Wang3-9/+40
This patches extend the vhost IOTLB API to accept batch updating hints form userspace. When userspace wants update the device IOTLB in a batch, it may do: 1) Write vhost_iotlb_msg with VHOST_IOTLB_BATCH_BEGIN flag 2) Perform a batch of IOTLB updating via VHOST_IOTLB_UPDATE/INVALIDATE 3) Write vhost_iotlb_msg with VHOST_IOTLB_BATCH_END flag Vhost-vdpa may decide to batch the IOMMU/IOTLB updating in step 3 when vDPA device support set_map() ops. This is useful for the vDPA device that want to know all the mappings to tweak their own DMA translation logic. For vDPA device that doesn't require set_map(), no behavior changes. This capability is advertised via VHOST_BACKEND_F_IOTLB_BATCH capability. Signed-off-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vhost-vdpa: support get/set backend featuresJason Wang1-0/+18
This patch makes userspace can get and set backend features to vhost-vdpa. Signed-off-by: Cindy Lu <[email protected]> Signed-off-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vhost: generialize backend features setting/gettingJason Wang3-16/+19
Move the backend features setting/getting from net.c to vhost.c to be reused by vhost-vdpa. Signed-off-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vhost-vdpa: refine ioctl pre-processingJason Wang1-4/+5
Switch to use 'switch' to make the codes more easier to be extended. Signed-off-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05Merge branch 'mlx5-next' of ↵Michael S. Tsirkin18-77/+228
git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux into HEAD Merge shared code that's necessary for mlx5 vdpa bits to build. The branch itself includes a small number of patches and is also independently merged by a couple of other trees. That shouldn't cause any conflicts by itself. Saeed Mahameed <[email protected]> says: --- mlx5-next is a very small branch based on a very early rc that includes mlx5 shared stuff between rdma and net-next, and now virtio as well. --- Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vDPA: dont change vq irq after DRIVER_OKZhu Lingshan2-1/+1
IRQ of a vq is not expected to be changed in a DRIVER_OK ~ !DRIVER_OK period for irq offloading purposes. Place this comment at the side of bus ops get_vq_irq than in set_status in vhost_vdpa. Signed-off-by: Zhu Lingshan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_pci_modern: Fix the comment of virtio_pci_find_capability()Liao Pingfang1-0/+1
Fix the comment of virtio_pci_find_capability() by adding missing comment for the last parameter: bars. Fixes: 59a5b0f7bf74 ("virtio-pci: alloc only resources actually used.") Signed-off-by: Liao Pingfang <[email protected]> Signed-off-by: Yi Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
2020-08-05irqbypass: do not start cons/prod when failed connectZhu Lingshan1-6/+10
If failed to connect, there is no need to start consumer nor producer. Signed-off-by: Zhu Lingshan <[email protected]> Suggested-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05ifcvf: implement vdpa_config_ops.get_vq_irq()Zhu Lingshan1-2/+16
This commit implemented vdpa_config_ops.get_vq_irq() in ifcvf, and initialized vq irq to -EINVAL. So that ifcvf can report irq number of a vq, or -EINVAL if the vq is not assigned an irq number. Signed-off-by: Zhu Lingshan <[email protected]> Suggested-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vhost_vdpa: implement IRQ offloading in vhost_vdpaZhu Lingshan2-1/+63
This patch introduce a set of functions for setup/unsetup and update irq offloading respectively by register/unregister and re-register the irq_bypass_producer. With these functions, this commit can setup/unsetup irq offloading through setting DRIVER_OK/!DRIVER_OK, and update irq offloading through SET_VRING_CALL. Signed-off-by: Zhu Lingshan <[email protected]> Suggested-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vDPA: add get_vq_irq() in vdpa_config_opsZhu Lingshan1-0/+7
This commit adds a new function get_vq_irq() in struct vdpa_config_ops, which will return the irq number of a virtqueue. Signed-off-by: Zhu Lingshan <[email protected]> Suggested-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05kvm: detect assigned device via irqbypass managerZhu Lingshan1-2/+10
vDPA devices has dedicated backed hardware like passthrough-ed devices. Then it is possible to setup irq offloading to vCPU for vDPA devices. Thus this patch tries to manipulated assigned device counters by kvm_arch_start/end_assignment() in irqbypass manager, so that assigned devices could be detected in update_pi_irte() We will increase/decrease the assigned device counter in kvm/x86. Both vDPA and VFIO would go through this code path. Only X86 uses these counters and kvm_arch_start/end_assignment(), so this code path only affect x86 for now. Signed-off-by: Zhu Lingshan <[email protected]> Suggested-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vhost: introduce vhost_vring_callZhu Lingshan3-9/+26
This commit introduces struct vhost_vring_call which replaced raw struct eventfd_ctx *call_ctx in struct vhost_virtqueue. Besides eventfd_ctx, it contains a spin lock and an irq_bypass_producer in its structure. Signed-off-by: Zhu Lingshan <[email protected]> Suggested-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vhost: Use flex_array_size() helper in copy_from_user()Gustavo A. R. Silva1-1/+1
Make use of the flex_array_size() helper to calculate the size of a flexible array member within an enclosing structure. This helper offers defense-in-depth against potential integer overflows, while at the same time makes it explicitly clear that we are dealing with a flexible array member. Signed-off-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/20200731130956.GA30525@embeddedor Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vdpasim: protect concurrent access to iommu iotlbMax Gurtovoy1-4/+27
Iommu iotlb can be accessed by different cores for performing IO using multiple virt queues. Add a spinlock to synchronize iotlb accesses. This could be easily reproduced when using more than 1 pktgen threads to inject traffic to vdpa simulator. Fixes: 2c53d0f64c06f("vdpasim: vDPA device simulator") Cc: [email protected] Signed-off-by: Max Gurtovoy <[email protected]> Signed-off-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vhost: vdpa: remove per device feature whitelistJason Wang1-37/+0
We used to have a per device feature whitelist to filter out the unsupported virtio features. But this seems unnecessary since: - the main idea behind feature whitelist is to block control vq feature until we finalize the control virtqueue API. But the current vhost-vDPA uAPI is sufficient to support control virtqueue. For device that has hardware control virtqueue, the vDPA device driver can just setup the hardware virtqueue and let userspace to use hardware virtqueue directly. For device that doesn't have a control virtqueue, the vDPA device driver need to use e.g vringh to emulate a software control virtqueue. - we don't do it in virtio-vDPA driver So remove this limitation. Signed-off-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_ring: Avoid loop when vq is broken in virtqueue_pollMao Wenan1-0/+3
The loop may exist if vq->broken is true, virtqueue_get_buf_ctx_packed or virtqueue_get_buf_ctx_split will return NULL, so virtnet_poll will reschedule napi to receive packet, it will lead cpu usage(si) to 100%. call trace as below: virtnet_poll virtnet_receive virtqueue_get_buf_ctx virtqueue_get_buf_ctx_packed virtqueue_get_buf_ctx_split virtqueue_napi_complete virtqueue_poll //return true virtqueue_napi_schedule //it will reschedule napi to fix this, return false if vq is broken in virtqueue_poll. Signed-off-by: Mao Wenan <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
2020-08-05virtio_net: use LE accessors for speed/duplexMichael S. Tsirkin2-5/+6
Speed and duplex config fields depend on VIRTIO_NET_F_SPEED_DUPLEX which being 63>31 depends on VIRTIO_F_VERSION_1. Accordingly, use LE accessors for these fields. Reported-by: Cornelia Huck <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_config: drop LE option from config spaceMichael S. Tsirkin1-26/+2
All drivers now use virtio_cread/write_le for LE config space fields. Drop LE option from virtio_cread/write, only leaving the option to access transitional fields. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio-iommu: convert to LE accessorsMichael S. Tsirkin1-17/+17
Virtio iommu is modern-only. Use LE accessors for config space. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_mem: convert to LE accessorsMichael S. Tsirkin1-15/+15
Virtio mem is modern-only. Use LE accessors for config space. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05drm/virtio: convert to LE accessorsMichael S. Tsirkin1-8/+8
Virtgpu is modern-only. Use LE accessors for config space. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_pmem: convert to LE accessorsMichael S. Tsirkin1-2/+2
Virtio pmem is modern-only. Use LE accessors for config space. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_crypto: convert to LE accessorsMichael S. Tsirkin1-23/+23
Virtio crypto is modern-only. Use LE accessors for config space. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_fs: convert to LE accessorsMichael S. Tsirkin1-2/+2
Virtio fs is modern-only. Use LE accessors for config space. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_input: convert to LE accessorsMichael S. Tsirkin1-16/+16
Virtio input is modern-only. Use LE accessors for config space. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_balloon: use LE config space accessesMichael S. Tsirkin1-17/+9
Balloon is LE, it's cleaner to access it as such directly. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_config: add virtio_cread_le_featureMichael S. Tsirkin1-0/+10
Mirrors virtio_cread_feature but for LE fields. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_caif: correct tags for config space fieldsMichael S. Tsirkin1-3/+3
Tag config space fields as having virtio endian-ness. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_config: LE config space accessorsMichael S. Tsirkin1-0/+65
To be used by modern code, as well as to handle LE only fields such as balloon. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_config: disallow native type fields (again)Michael S. Tsirkin1-14/+2
_Generic version allowed __uXX types but that is no longer necessary: Transitional devices should all use __virtioXX types (and __leXX for fields not present in the legacy devices). Modern ones should use __leXX. _uXX type would be a bug. Let's prevent that. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_config: rewrite using _GenericMichael S. Tsirkin1-85/+76
Min compiler version has been raised, so that's ok now. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_config: cread/write cleanupMichael S. Tsirkin1-12/+19
Use vars of the correct type instead of casting. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vdpa_sim: fix endian-ness of config spaceMichael S. Tsirkin1-5/+28
VDPA sim accesses config space as native endian - this is wrong since it's a modern device and actually uses LE. It only supports modern guests so we could punt and just force LE, but let's use the full virtio APIs since people tend to copy/paste code, and this is not data path anyway. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_vdpa: legacy features handlingMichael S. Tsirkin1-6/+3
We normally expect vdpa to use the modern interface. However for consistency, let's use same APIs as vhost for legacy guests. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vhost/vdpa: switch to new helpersMichael S. Tsirkin1-5/+3
For new helpers handling legacy features to be effective, vhost needs to invoke them. Tie them in. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05vdpa: make sure set_features is invoked for legacyMichael S. Tsirkin2-0/+35
Some legacy guests just assume features are 0 after reset. We detect that config space is accessed before features are set and set features to 0 automatically. Note: some legacy guests might not even access config space, if this is reported in the field we might need to catch a kick to handle these. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05mlxbf-tmfifo: sparse tags for config accessMichael S. Tsirkin1-3/+10
mlxbf-tmfifo accesses config space using native types - which works for it since the legacy virtio native types. This will break if it ever needs to support modern virtio, so with new tags previously introduced for virtio net config, sparse now warns for this in drivers. Since this is a legacy only device, fix it up using virtio_legacy_is_little_endian for now. No functional changes. Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Cornelia Huck <[email protected]> Acked-by: Andy Shevchenko <[email protected]> Acked-by: Andy Shevchenko <[email protected]>
2020-08-05virtio_config: disallow native type fieldsMichael S. Tsirkin1-3/+2
Transitional devices should all use __virtioXX types (and __leXX for fields not present in legacy devices). Modern ones should use __leXX. _uXX type would be a bug. Let's prevent that. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_scsi: correct tags for config space fieldsMichael S. Tsirkin2-12/+12
Tag config space fields as having virtio endian-ness. Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Cornelia Huck <[email protected]>
2020-08-05virtio_pmem: correct tags for config space fieldsMichael S. Tsirkin1-2/+2
Since this is a modern-only device, tag config space fields as having little endian-ness. Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Cornelia Huck <[email protected]>
2020-08-05virtio_net: correct tags for config space fieldsMichael S. Tsirkin1-4/+4
Tag config space fields as having virtio endian-ness. Signed-off-by: Michael S. Tsirkin <[email protected]>
2020-08-05virtio_mem: correct tags for config space fieldsMichael S. Tsirkin1-7/+7
Since this is a modern-only device, tag config space fields as having little endian-ness. TODO: check other uses of __virtioXX types in this header, should probably be __leXX. Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: David Hildenbrand <[email protected]> Reviewed-by: Cornelia Huck <[email protected]>
2020-08-05virtio_iommu: correct tags for config space fieldsMichael S. Tsirkin1-6/+6
Since this is a modern-only device, tag config space fields as having little endian-ness. Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Jean-Philippe Brucker <[email protected]> Reviewed-by: Jean-Philippe Brucker <[email protected]> Reviewed-by: Cornelia Huck <[email protected]>
2020-08-05virtio_input: correct tags for config space fieldsMichael S. Tsirkin1-9/+9
Since this is a modern-only device, tag config space fields as having little endian-ness. Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Gerd Hoffmann <[email protected]> Reviewed-by: Gerd Hoffmann <[email protected]> Reviewed-by: Cornelia Huck <[email protected]>
2020-08-05virtio_gpu: correct tags for config space fieldsMichael S. Tsirkin1-4/+4
Since gpu is a modern-only device, tag config space fields as having little endian-ness. Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Cornelia Huck <[email protected]>
2020-08-05virtio_fs: correct tags for config space fieldsMichael S. Tsirkin1-1/+1
Since fs is a modern-only device, tag config space fields as having little endian-ness. Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Vivek Goyal <[email protected]> Acked-by: Vivek Goyal <[email protected]> Reviewed-by: Cornelia Huck <[email protected]>
2020-08-05virtio_crypto: correct tags for config space fieldsMichael S. Tsirkin1-13/+13
Since crypto is a modern-only device, tag config space fields as having little endian-ness. Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Cornelia Huck <[email protected]>
2020-08-05virtio_console: correct tags for config space fieldsMichael S. Tsirkin1-4/+4
Tag config space fields as having virtio endian-ness. Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Cornelia Huck <[email protected]>
2020-08-05virtio_blk: correct tags for config space fieldsMichael S. Tsirkin1-13/+13
Tag config space fields as having virtio endian-ness. Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]>