Net patches
The following changes since commit 352998df1c53b366413690d95b35f76d0721ebed:
Merge tag 'i2c-20220314' of https://github.com/philmd/qemu into staging (2022-03-14 14:39:33 +0000)
are available in the git repository at:
https://github.com/jasowang/qemu.git tags/net-pull-request
for you to fetch changes up to 12a195fa343aae2ead1301ce04727bd0ae25eb15:
vdpa: Expose VHOST_F_LOG_ALL on SVQ (2022-03-15 13:57:44 +0800)
----------------------------------------------------------------
Changes since V2:
- fix 32bit build errros
----------------------------------------------------------------
Eugenio Pérez (14):
vhost: Add VhostShadowVirtqueue
vhost: Add Shadow VirtQueue kick forwarding capabilities
vhost: Add Shadow VirtQueue call forwarding capabilities
vhost: Add vhost_svq_valid_features to shadow vq
virtio: Add vhost_svq_get_vring_addr
vdpa: adapt vhost_ops callbacks to svq
vhost: Shadow virtqueue buffers forwarding
util: Add iova_tree_alloc_map
util: add iova_tree_find_iova
vhost: Add VhostIOVATree
vdpa: Add custom IOTLB translations to SVQ
vdpa: Adapt vhost_vdpa_get_vring_base to SVQ
vdpa: Never set log_base addr if SVQ is enabled
vdpa: Expose VHOST_F_LOG_ALL on SVQ
Jason Wang (1):
virtio-net: fix map leaking on error during receive
hw/net/virtio-net.c | 1 + hw/virtio/meson.build | 2 +- hw/virtio/vhost-iova-tree.c | 110 +++++++ hw/virtio/vhost-iova-tree.h | 27 ++ hw/virtio/vhost-shadow-virtqueue.c | 636 +++++++++++++++++++++++++++++++++++++ hw/virtio/vhost-shadow-virtqueue.h | 87 +++++ hw/virtio/vhost-vdpa.c | 522 +++++++++++++++++++++++++++++- include/hw/virtio/vhost-vdpa.h | 8 + include/qemu/iova-tree.h | 38 ++- util/iova-tree.c | 170 ++++++++++ 10 files changed, 1584 insertions(+), 17 deletions(-) create mode 100644 hw/virtio/vhost-iova-tree.c create mode 100644 hw/virtio/vhost-iova-tree.h create mode 100644 hw/virtio/vhost-shadow-virtqueue.c create mode 100644 hw/virtio/vhost-shadow-virtqueue.h
[PULL V3 01/15] virtio-net: fix map leaking on error during receive
Commit bedd7e93d0196 ("virtio-net: fix use after unmap/free for sg") tries to fix the use after free of the sg by caching the virtqueue elements in an array and unmap them at once after receiving the packets, But it forgot to unmap the cached elements on error which will lead to leaking of mapping and other unexpected results.
Fixing this by detaching the cached elements on error. This addresses CVE-2022-26353.
--- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+)
hw/net/virtio-net.c +1 -0
@@ -1870,6 +1870,7 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf, err:for (j =0 ; j < i; j++) { +virtqueue_detach_element (q->rx_vq, elems[j], lens[j]);g_free (elems[j]); }
Signature · 1 line
2.7.4
[PULL V3 04/15] vhost: Add Shadow VirtQueue call forwarding capabilities
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
This will make qemu aware of the device used buffers, allowing it to write the guest memory with its contents if needed.
--- hw/virtio/vhost-shadow-virtqueue.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/virtio/vhost-shadow-virtqueue.h | 4 ++++ hw/virtio/vhost-vdpa.c | 31 +++++++++++++++++++++++++++++-- 3 files changed, 71 insertions(+), 2 deletions(-)
hw/virtio/vhost-shadow-virtqueue.c +38 -0
@@ -27,6 +27,42 @@ static void vhost_handle_guest_kick(EventNotifier *n) }/** +* Forward vhost notifications +* +* @n: hdev call event notifier, the one that device set to notify svq. +*/ +static void vhost_svq_handle_call (EventNotifier *n) +{ +VhostShadowVirtqueue *svq =container_of (n, VhostShadowVirtqueue, + hdev_call); +event_notifier_test_and_clear (n); +event_notifier_set (&svq->svq_call); +} + +/** +* Set the call notifier for the SVQ to call the guest +* +* @svq: Shadow virtqueue +* @call_fd: call notifier +* +* Called on BQL context. +*/ +void vhost_svq_set_svq_call_fd (VhostShadowVirtqueue *svq,int call_fd) +{ +if (call_fd ==VHOST_FILE_UNBIND ) { +/* +* Fail event_notifier_set if called handling device call. +* +* SVQ still needs device notifications, since it needs to keep +* forwarding used buffers even with the unbind. +*/ +memset (&svq->svq_call,0 ,sizeof (svq->svq_call)); + }else { +event_notifier_init_fd (&svq->svq_call, call_fd); + } +} + +/** * Set a new file descriptor for the guest to kick the SVQ and notify for avail * * @svq: The svq
@@ -93,6 +129,7 @@ VhostShadowVirtqueue *vhost_svq_new(void) }event_notifier_init_fd (&svq->svq_kick,VHOST_FILE_UNBIND ); +event_notifier_set_handler (&svq->hdev_call, vhost_svq_handle_call);return g_steal_pointer (&svq); err_init_hdev_call:
@@ -112,6 +149,7 @@ void vhost_svq_free(gpointer pvq)VhostShadowVirtqueue *vq = pvq;vhost_svq_stop (vq);event_notifier_cleanup (&vq->hdev_kick); +event_notifier_set_handler (&vq->hdev_call,NULL );event_notifier_cleanup (&vq->hdev_call);g_free (vq); }
hw/virtio/vhost-shadow-virtqueue.h +4 -0
@@ -28,9 +28,13 @@ typedef struct VhostShadowVirtqueue {* So shadow virtqueue must not clean it, or we would lose VirtQueue one. */ EventNotifier svq_kick; + +/* Guest's call notifier, where the SVQ calls guest. */ +EventNotifier svq_call; } VhostShadowVirtqueue;void vhost_svq_set_svq_kick_fd (VhostShadowVirtqueue *svq,int svq_kick_fd); +void vhost_svq_set_svq_call_fd (VhostShadowVirtqueue *svq,int call_fd);void vhost_svq_stop (VhostShadowVirtqueue *svq);
hw/virtio/vhost-vdpa.c +29 -2
@@ -725,6 +725,13 @@ static int vhost_vdpa_set_vring_dev_kick(struct vhost_dev *dev,return vhost_vdpa_call (dev,VHOST_SET_VRING_KICK , file); } +static int vhost_vdpa_set_vring_dev_call (struct vhost_dev *dev, +struct vhost_vring_file *file) +{ +trace_vhost_vdpa_set_vring_call (dev, file->index, file->fd); +return vhost_vdpa_call (dev,VHOST_SET_VRING_CALL , file); +} +/** * Set the shadow virtqueue descriptors to the device *
@@ -732,6 +739,9 @@ static int vhost_vdpa_set_vring_dev_kick(struct vhost_dev *dev,* @svq: The shadow virtqueue * @idx: The index of the virtqueue in the vhost device * @errp: Error +* +* Note that this function does not rewind kick file descriptor if cannot set +* call one. */ static bool vhost_vdpa_svq_setup(struct vhost_dev *dev, VhostShadowVirtqueue *svq, unsigned idx,
@@ -747,6 +757,14 @@ static bool vhost_vdpa_svq_setup(struct vhost_dev *dev, r =vhost_vdpa_set_vring_dev_kick (dev, &file);if (unlikely (r !=0 )) {error_setg_errno (errp, -r,"Can't set device kick fd" ); +return false; + } + + event_notifier = &svq->hdev_call; + file.fd =event_notifier_get_fd (event_notifier); + r =vhost_vdpa_set_vring_dev_call (dev, &file); +if (unlikely (r !=0 )) { +error_setg_errno (errp, -r,"Can't set device call fd" ); }return r ==0 ;
@@ -872,8 +890,17 @@ static int vhost_vdpa_set_vring_kick(struct vhost_dev *dev,static int vhost_vdpa_set_vring_call (struct vhost_dev *dev,struct vhost_vring_file *file) { -trace_vhost_vdpa_set_vring_call (dev, file->index, file->fd); -return vhost_vdpa_call (dev,VHOST_SET_VRING_CALL , file); +struct vhost_vdpa *v = dev->opaque; + +if (v->shadow_vqs_enabled) { +int vdpa_idx = file->index - dev->vq_index; +VhostShadowVirtqueue *svq =g_ptr_array_index (v->shadow_vqs, vdpa_idx); + +vhost_svq_set_svq_call_fd (svq, file->fd); +return 0 ; + }else { +return vhost_vdpa_set_vring_dev_call (dev, file); + } } static int vhost_vdpa_get_features(struct vhost_dev *dev,
Signature · 1 line
2.7.4
[PULL V3 14/15] vdpa: Never set log_base addr if SVQ is enabled
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
Setting the log address would make the device start reporting invalid dirty memory because the SVQ vrings are located in qemu's memory.
--- hw/virtio/vhost-vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/vhost-vdpa.c +2 -1
@@ -1090,7 +1090,8 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)static int vhost_vdpa_set_log_base (struct vhost_dev *dev,uint64_t base,struct vhost_log *log) { -if (vhost_vdpa_one_time_request (dev)) { +struct vhost_vdpa *v = dev->opaque; +if (v->shadow_vqs_enabled ||vhost_vdpa_one_time_request (dev)) {return 0 ; }
Signature · 1 line
2.7.4
[PULL V3 09/15] util: Add iova_tree_alloc_map
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
This iova tree function allows it to look for a hole in allocated regions and return a totally new translation for a given translated address.
It's usage is mainly to allow devices to access qemu address space, remapping guest's one into a new iova space where qemu can add chunks of addresses.
--- include/qemu/iova-tree.h | 18 +++++++ util/iova-tree.c | 136 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+)
include/qemu/iova-tree.h +18 -0
@@ -29,6 +29,7 @@#define IOVA_OK (0)#define IOVA_ERR_INVALID (-1)/* Invalid parameters */ #define IOVA_ERR_OVERLAP (-2)/* IOVA range overlapped */ +#define IOVA_ERR_NOMEM (-3)/* Cannot allocate */ typedef struct IOVATree IOVATree ; typedef struct DMAMap {
@@ -120,6 +121,23 @@ const DMAMap *iova_tree_find_address(const IOVATree *tree, hwaddr iova);void iova_tree_foreach (IOVATree *tree,iova_tree_iterator iterator);/** +* iova_tree_alloc_map: +* +* @tree: the iova tree to allocate from +* @map: the new map (as translated addr & size) to allocate in the iova region +* @iova_begin: the minimum address of the allocation +* @iova_end: the maximum addressable direction of the allocation +* +* Allocates a new region of a given size, between iova_min and iova_max. +* +* Return: Same as iova_tree_insert, but cannot overlap and can return error if +* iova tree is out of free contiguous range. The caller gets the assigned iova +* in map->iova. +*/ +int iova_tree_alloc_map (IOVATree *tree,DMAMap *map,hwaddr iova_begin, +hwaddr iova_end); + +/** * iova_tree_destroy: * * @tree: the iova tree to destroy
util/iova-tree.c +136 -0
148 lines not on this page · raw message
Signature · 1 line
2.7.4
[PULL V3 10/15] util: add iova_tree_find_iova
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
This function does the reverse operation of iova_tree_find: To look for a mapping that match a translated address so we can do the reverse.
This have linear complexity instead of logarithmic, but it supports overlapping HVA. Future developments could reduce it.
--- include/qemu/iova-tree.h | 20 +++++++++++++++++++- util/iova-tree.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-)
include/qemu/iova-tree.h +19 -1
@@ -83,7 +83,7 @@ int iova_tree_remove(IOVATree *tree, const DMAMap *map);* @tree: the iova tree to search from * @map: the mapping to search * -* Search for a mapping in the iova tree that overlaps with the +* Search for a mapping in the iova tree that iova overlaps with the * mapping range specified. Only the first found mapping will be * returned. *
@@ -96,6 +96,24 @@ int iova_tree_remove(IOVATree *tree, const DMAMap *map);const DMAMap *iova_tree_find (const IOVATree *tree,const DMAMap *map);/** +* iova_tree_find_iova: +* +* @tree: the iova tree to search from +* @map: the mapping to search +* +* Search for a mapping in the iova tree that translated_addr overlaps with the +* mapping range specified. Only the first found mapping will be +* returned. +* +* Return: DMAMap pointer if found, or NULL if not found. Note that +* the returned DMAMap pointer is maintained internally. User should +* only read the content but never modify or free the content. Also, +* user is responsible to make sure the pointer is valid (say, no +* concurrent deletion in progress). +*/ +const DMAMap *iova_tree_find_iova (const IOVATree *tree,const DMAMap *map); + +/** * iova_tree_find_address: * * @tree: the iova tree to search from
util/iova-tree.c +34 -0
@@ -37,6 +37,11 @@ struct IOVATreeAllocArgs {bool iova_found; }; +typedef struct IOVATreeFindIOVAArgs { +const DMAMap *needle; +const DMAMap *result; +}IOVATreeFindIOVAArgs ; +/** * Iterate args to the next hole *
@@ -81,6 +86,35 @@ const DMAMap *iova_tree_find(const IOVATree *tree, const DMAMap *map)return g_tree_lookup (tree->tree, map); } +static gboolean iova_tree_find_address_iterator (gpointer key,gpointer value, +gpointer data) +{ +const DMAMap *map = key; +IOVATreeFindIOVAArgs *args = data; +const DMAMap *needle; + +g_assert (key == value); + + needle = args->needle; +if (map->translated_addr + map->size < needle->translated_addr || + needle->translated_addr + needle->size < map->translated_addr) { +return false; + } + + args->result = map; +return true; +} + +const DMAMap *iova_tree_find_iova (const IOVATree *tree,const DMAMap *map) +{ +IOVATreeFindIOVAArgs args = { + .needle = map, + }; + +g_tree_foreach (tree->tree, iova_tree_find_address_iterator, &args); +return args.result; +} +const DMAMap *iova_tree_find_address (const IOVATree *tree,hwaddr iova) {const DMAMap map = { .iova = iova, .size =0 };
Signature · 1 line
2.7.4
[PULL V3 02/15] vhost: Add VhostShadowVirtqueue
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
Vhost shadow virtqueue (SVQ) is an intermediate jump for virtqueue notifications and buffers, allowing qemu to track them. While qemu is forwarding the buffers and virtqueue changes, it is able to commit the memory it's being dirtied, the same way regular qemu's VirtIO devices do.
This commit only exposes basic SVQ allocation and free. Next patches of the series add functionality like notifications and buffers forwarding.
--- hw/virtio/meson.build | 2 +- hw/virtio/vhost-shadow-virtqueue.c | 62 ++++++++++++++++++++++++++++++++++++++ hw/virtio/vhost-shadow-virtqueue.h | 28 +++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 hw/virtio/vhost-shadow-virtqueue.c create mode 100644 hw/virtio/vhost-shadow-virtqueue.h
hw/virtio/meson.build +1 -1
@@ -11,7 +11,7 @@ softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c')) virtio_ss = ss.source_set() virtio_ss.add(files('virtio.c')) -virtio_ss.add(when: 'CONFIG_VHOST', if_true: files('vhost.c', 'vhost-backend.c')) +virtio_ss.add(when: 'CONFIG_VHOST', if_true: files('vhost.c', 'vhost-backend.c', 'vhost-shadow-virtqueue.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user.c')) virtio_ss.add(when: 'CONFIG_VHOST_VDPA', if_true: files('vhost-vdpa.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-balloon.c'))
hw/virtio/vhost-shadow-virtqueue.c new file +62 -0
62 lines not on this page · raw message
hw/virtio/vhost-shadow-virtqueue.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* vhost shadow virtqueue +* +* SPDX-FileCopyrightText: Red Hat, Inc. 2021 +* SPDX-FileContributor: Author: Eugenio Pérez <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef VHOST_SHADOW_VIRTQUEUE_H +#define VHOST_SHADOW_VIRTQUEUE_H + +#include "qemu/event_notifier.h" + +/* Shadow virtqueue to relay notifications */ +typedef struct VhostShadowVirtqueue { +/* Shadow kick notifier, sent to vhost */ +EventNotifier hdev_kick; +/* Shadow call notifier, sent to vhost */ +EventNotifier hdev_call; +}VhostShadowVirtqueue ; + +VhostShadowVirtqueue *vhost_svq_new (void ); + +void vhost_svq_free (gpointer vq); +G_DEFINE_AUTOPTR_CLEANUP_FUNC (VhostShadowVirtqueue, vhost_svq_free); + +#endif
Signature · 1 line
2.7.4
[PULL V3 15/15] vdpa: Expose VHOST_F_LOG_ALL on SVQ
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
SVQ is able to log the dirty bits by itself, so let's use it to not block migration.
Also, ignore set and clear of VHOST_F_LOG_ALL on set_features if SVQ is enabled. Even if the device supports it, the reports would be nonsense because SVQ memory is in the qemu region.
The log region is still allocated. Future changes might skip that, but this series is already long enough.
--- hw/virtio/vhost-vdpa.c | 39 +++++++++++++++++++++++++++++++++++---- include/hw/virtio/vhost-vdpa.h | 1 + 2 files changed, 36 insertions(+), 4 deletions(-)
hw/virtio/vhost-vdpa.c +35 -4
@@ -373,6 +373,16 @@ static bool vhost_vdpa_one_time_request(struct vhost_dev *dev)return v->index !=0 ; } +static int vhost_vdpa_get_dev_features (struct vhost_dev *dev, +uint64_t *features) +{ +int ret; + + ret =vhost_vdpa_call (dev,VHOST_GET_FEATURES , features); +trace_vhost_vdpa_get_features (dev, *features); +return ret; +} +static int vhost_vdpa_init_svq (struct vhost_dev *hdev,struct vhost_vdpa *v,Error **errp) {
@@ -385,7 +395,7 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v,return 0 ; } - r = hdev->vhost_ops->vhost_get_features (hdev, &dev_features); + r =vhost_vdpa_get_dev_features (hdev, &dev_features);if (r !=0 ) {error_setg_errno (errp, -r,"Can't get vdpa device features" );return r;
@@ -610,12 +620,29 @@ static int vhost_vdpa_set_mem_table(struct vhost_dev *dev,static int vhost_vdpa_set_features (struct vhost_dev *dev,uint64_t features) { +struct vhost_vdpa *v = dev->opaque;int ret;if (vhost_vdpa_one_time_request (dev)) {return 0 ; } +if (v->shadow_vqs_enabled) { +if ((v->acked_features ^ features) ==BIT_ULL (VHOST_F_LOG_ALL )) { +/* +* QEMU is just trying to enable or disable logging. SVQ handles +* this sepparately, so no need to forward this. +*/ + v->acked_features = features; +return 0 ; + } + + v->acked_features = features; + +/* We must not ack _F_LOG if SVQ is enabled */ + features &= ~BIT_ULL (VHOST_F_LOG_ALL ); + } +trace_vhost_vdpa_set_features (dev, features); ret =vhost_vdpa_call (dev,VHOST_SET_FEATURES , &features);if (ret) {
@@ -1200,10 +1227,14 @@ static int vhost_vdpa_set_vring_call(struct vhost_dev *dev,static int vhost_vdpa_get_features (struct vhost_dev *dev,uint64_t *features) { -int ret; +struct vhost_vdpa *v = dev->opaque; +int ret =vhost_vdpa_get_dev_features (dev, features); + +if (ret ==0 && v->shadow_vqs_enabled) { +/* Add SVQ logging capabilities */ + *features |=BIT_ULL (VHOST_F_LOG_ALL ); + } - ret =vhost_vdpa_call (dev,VHOST_GET_FEATURES , features); -trace_vhost_vdpa_get_features (dev, *features);return ret; }
include/hw/virtio/vhost-vdpa.h +1 -0
@@ -30,6 +30,7 @@ typedef struct vhost_vdpa {bool iotlb_batch_begin_sent;MemoryListener listener;struct vhost_vdpa_iova_range iova_range; +uint64_t acked_features;bool shadow_vqs_enabled;/* IOVA mapping used by the Shadow Virtqueue */ VhostIOVATree *iova_tree;
Signature · 1 line
2.7.4
[PULL V3 12/15] vdpa: Add custom IOTLB translations to SVQ
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
Use translations added in VhostIOVATree in SVQ.
Only introduce usage here, not allocation and deallocation. As with previous patches, we use the dead code paths of shadow_vqs_enabled to avoid commiting too many changes at once. These are impossible to take at the moment.
--- hw/virtio/vhost-shadow-virtqueue.c | 86 +++++++++++++++++++++++--- hw/virtio/vhost-shadow-virtqueue.h | 6 +- hw/virtio/vhost-vdpa.c | 122 +++++++++++++++++++++++++++++++------ include/hw/virtio/vhost-vdpa.h | 3 + 4 files changed, 187 insertions(+), 30 deletions(-)
hw/virtio/vhost-shadow-virtqueue.c +77 -9
@@ -70,7 +70,59 @@ static uint16_t vhost_svq_available_slots(const VhostShadowVirtqueue *svq)return svq->vring.num - (svq->shadow_avail_idx - svq->shadow_used_idx); } -static void vhost_vring_write_descs (VhostShadowVirtqueue *svq, +/** +* Translate addresses between the qemu's virtual address and the SVQ IOVA +* +* @svq: Shadow VirtQueue +* @vaddr: Translated IOVA addresses +* @iovec: Source qemu's VA addresses +* @num: Length of iovec and minimum length of vaddr +*/ +static bool vhost_svq_translate_addr (const VhostShadowVirtqueue *svq, +hwaddr *addrs,const struct iovec *iovec, +size_t num) +{ +if (num ==0 ) { +return true; + } + +for (size_t i =0 ; i < num; ++i) { +DMAMap needle = { + .translated_addr = (hwaddr )(uintptr_t )iovec[i].iov_base, + .size = iovec[i].iov_len, + }; +Int128 needle_last, map_last; +size_t off; + +const DMAMap *map =vhost_iova_tree_find_iova (svq->iova_tree, &needle); +/* +* Map cannot be NULL since iova map contains all guest space and +* qemu already has a physical address mapped +*/ +if (unlikely (!map)) { +qemu_log_mask (LOG_GUEST_ERROR , +"Invalid address 0x%" HWADDR_PRIx" given by guest" , + needle.translated_addr); +return false; + } + + off = needle.translated_addr - map->translated_addr; + addrs[i] = map->iova + off; + + needle_last =int128_add (int128_make64 (needle.translated_addr), +int128_make64 (iovec[i].iov_len)); + map_last =int128_make64 (map->translated_addr + map->size); +if (unlikely (int128_gt (needle_last, map_last))) { +qemu_log_mask (LOG_GUEST_ERROR , +"Guest buffer expands over iova range" ); +return false; + } + } + +return true; +} + +static void vhost_vring_write_descs (VhostShadowVirtqueue *svq,hwaddr *sg,const struct iovec *iovec,size_t num,bool more_descs,bool write) {
@@ -89,7 +141,7 @@ static void vhost_vring_write_descs(VhostShadowVirtqueue *svq, }else { descs[i].flags = flags; } - descs[i].addr =cpu_to_le64 ((hwaddr )(intptr_t )iovec[n].iov_base); + descs[i].addr =cpu_to_le64 (sg[n]); descs[i].len =cpu_to_le32 (iovec[n].iov_len); last = i;
@@ -104,6 +156,8 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq, {unsigned avail_idx;vring_avail_t *avail = svq->vring.avail; +bool ok; + g_autofree hwaddr *sgs = g_new(hwaddr, MAX(elem->out_num, elem->in_num)); *head = svq->free_head;
@@ -114,9 +168,20 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,return false; } -vhost_vring_write_descs (svq, elem->out_sg, elem->out_num, elem->in_num >0 , - false); -vhost_vring_write_descs (svq, elem->in_sg, elem->in_num, false, true); + ok =vhost_svq_translate_addr (svq, sgs, elem->out_sg, elem->out_num); +if (unlikely (!ok)) { +return false; + } +vhost_vring_write_descs (svq, sgs, elem->out_sg, elem->out_num, + elem->in_num >0 , false); + + + ok =vhost_svq_translate_addr (svq, sgs, elem->in_sg, elem->in_num); +if (unlikely (!ok)) { +return false; + } + +vhost_vring_write_descs (svq, sgs, elem->in_sg, elem->in_num, false, true);/* * Put the entry in the available array (but don't update avail->idx until
@@ -395,9 +460,9 @@ void vhost_svq_set_svq_call_fd(VhostShadowVirtqueue *svq, int call_fd)void vhost_svq_get_vring_addr (const VhostShadowVirtqueue *svq,struct vhost_vring_addr *addr) { - addr->desc_user_addr = (uint64_t )(intptr_t )svq->vring.desc; - addr->avail_user_addr = (uint64_t )(intptr_t )svq->vring.avail; - addr->used_user_addr = (uint64_t )(intptr_t )svq->vring.used; + addr->desc_user_addr = (uint64_t )(uintptr_t )svq->vring.desc; + addr->avail_user_addr = (uint64_t )(uintptr_t )svq->vring.avail; + addr->used_user_addr = (uint64_t )(uintptr_t )svq->vring.used; }size_t vhost_svq_driver_area_size (const VhostShadowVirtqueue *svq)
@@ -518,11 +583,13 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq)* Creates vhost shadow virtqueue, and instructs the vhost device to use the * shadow methods and file descriptors. * +* @iova_tree: Tree to perform descriptors translations +* * Returns the new virtqueue or NULL. * * In case of error, reason is reported through error_report. */ -VhostShadowVirtqueue *vhost_svq_new (void ) +VhostShadowVirtqueue *vhost_svq_new (VhostIOVATree *iova_tree) { g_autofree VhostShadowVirtqueue *svq = g_new0(VhostShadowVirtqueue, 1);int r;
@@ -543,6 +610,7 @@ VhostShadowVirtqueue *vhost_svq_new(void)event_notifier_init_fd (&svq->svq_kick,VHOST_FILE_UNBIND );event_notifier_set_handler (&svq->hdev_call, vhost_svq_handle_call); + svq->iova_tree = iova_tree;return g_steal_pointer (&svq); err_init_hdev_call:
hw/virtio/vhost-shadow-virtqueue.h +5 -1
@@ -13,6 +13,7 @@#include "qemu/event_notifier.h" #include "hw/virtio/virtio.h" #include "standard-headers/linux/vhost_types.h" +#include "hw/virtio/vhost-iova-tree.h" /* Shadow virtqueue to relay notifications */ typedef struct VhostShadowVirtqueue {
@@ -43,6 +44,9 @@ typedef struct VhostShadowVirtqueue {/* Virtio device */ VirtIODevice *vdev; +/* IOVA mapping */ +VhostIOVATree *iova_tree; +/* Map for use the guest's descriptors */ VirtQueueElement **ring_id_maps;
@@ -75,7 +79,7 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev, VirtQueue *vq);void vhost_svq_stop (VhostShadowVirtqueue *svq); -VhostShadowVirtqueue *vhost_svq_new (void ); +VhostShadowVirtqueue *vhost_svq_new (VhostIOVATree *iova_tree);void vhost_svq_free (gpointer vq);G_DEFINE_AUTOPTR_CLEANUP_FUNC (VhostShadowVirtqueue, vhost_svq_free);
hw/virtio/vhost-vdpa.c +102 -20
182 lines not on this page · raw message
include/hw/virtio/vhost-vdpa.h +3 -0
@@ -14,6 +14,7 @@#include <gmodule.h> +#include "hw/virtio/vhost-iova-tree.h" #include "hw/virtio/virtio.h" #include "standard-headers/linux/vhost_types.h"
@@ -30,6 +31,8 @@ typedef struct vhost_vdpa {MemoryListener listener;struct vhost_vdpa_iova_range iova_range;bool shadow_vqs_enabled; +/* IOVA mapping used by the Shadow Virtqueue */ +VhostIOVATree *iova_tree;GPtrArray *shadow_vqs;struct vhost_dev *dev;VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX ];
Signature · 1 line
2.7.4
[PULL V3 03/15] vhost: Add Shadow VirtQueue kick forwarding capabilities
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
At this mode no buffer forwarding will be performed in SVQ mode: Qemu will just forward the guest's kicks to the device.
Host memory notifiers regions are left out for simplicity, and they will not be addressed in this series.
--- hw/virtio/vhost-shadow-virtqueue.c | 55 ++++++++++++++ hw/virtio/vhost-shadow-virtqueue.h | 14 ++++ hw/virtio/vhost-vdpa.c | 144 ++++++++++++++++++++++++++++++++++++- include/hw/virtio/vhost-vdpa.h | 4 ++ 4 files changed, 215 insertions(+), 2 deletions(-)
hw/virtio/vhost-shadow-virtqueue.c +55 -0
@@ -11,6 +11,59 @@#include "hw/virtio/vhost-shadow-virtqueue.h" #include "qemu/error-report.h" +#include "qemu/main-loop.h" +#include "linux-headers/linux/vhost.h" + +/** +* Forward guest notifications. +* +* @n: guest kick event notifier, the one that guest set to notify svq. +*/ +static void vhost_handle_guest_kick (EventNotifier *n) +{ +VhostShadowVirtqueue *svq =container_of (n, VhostShadowVirtqueue, svq_kick); +event_notifier_test_and_clear (n); +event_notifier_set (&svq->hdev_kick); +} + +/** +* Set a new file descriptor for the guest to kick the SVQ and notify for avail +* +* @svq: The svq +* @svq_kick_fd: The svq kick fd +* +* Note that the SVQ will never close the old file descriptor. +*/ +void vhost_svq_set_svq_kick_fd (VhostShadowVirtqueue *svq,int svq_kick_fd) +{ +EventNotifier *svq_kick = &svq->svq_kick; +bool poll_stop =VHOST_FILE_UNBIND !=event_notifier_get_fd (svq_kick); +bool poll_start = svq_kick_fd !=VHOST_FILE_UNBIND ; + +if (poll_stop) { +event_notifier_set_handler (svq_kick,NULL ); + } + +/* +* event_notifier_set_handler already checks for guest's notifications if +* they arrive at the new file descriptor in the switch, so there is no +* need to explicitly check for them. +*/ +if (poll_start) { +event_notifier_init_fd (svq_kick, svq_kick_fd); +event_notifier_set (svq_kick); +event_notifier_set_handler (svq_kick, vhost_handle_guest_kick); + } +} + +/** +* Stop the shadow virtqueue operation. +* @svq: Shadow Virtqueue +*/ +void vhost_svq_stop (VhostShadowVirtqueue *svq) +{ +event_notifier_set_handler (&svq->svq_kick,NULL ); +}/** * Creates vhost shadow virtqueue, and instructs the vhost device to use the
@@ -39,6 +92,7 @@ VhostShadowVirtqueue *vhost_svq_new(void) goto err_init_hdev_call; } +event_notifier_init_fd (&svq->svq_kick,VHOST_FILE_UNBIND );return g_steal_pointer (&svq); err_init_hdev_call:
@@ -56,6 +110,7 @@ err_init_hdev_kick:void vhost_svq_free (gpointer pvq) {VhostShadowVirtqueue *vq = pvq; +vhost_svq_stop (vq);event_notifier_cleanup (&vq->hdev_kick);event_notifier_cleanup (&vq->hdev_call);g_free (vq);
hw/virtio/vhost-shadow-virtqueue.h +14 -0
@@ -18,8 +18,22 @@ typedef struct VhostShadowVirtqueue {EventNotifier hdev_kick;/* Shadow call notifier, sent to vhost */ EventNotifier hdev_call; + +/* +* Borrowed virtqueue's guest to host notifier. To borrow it in this event +* notifier allows to recover the VhostShadowVirtqueue from the event loop +* easily. If we use the VirtQueue's one, we don't have an easy way to +* retrieve VhostShadowVirtqueue. +* +* So shadow virtqueue must not clean it, or we would lose VirtQueue one. +*/ +EventNotifier svq_kick; } VhostShadowVirtqueue; +void vhost_svq_set_svq_kick_fd (VhostShadowVirtqueue *svq,int svq_kick_fd); + +void vhost_svq_stop (VhostShadowVirtqueue *svq); +VhostShadowVirtqueue *vhost_svq_new (void );void vhost_svq_free (gpointer vq);
hw/virtio/vhost-vdpa.c +142 -2
224 lines not on this page · raw message
include/hw/virtio/vhost-vdpa.h +4 -0
@@ -12,6 +12,8 @@#ifndef HW_VIRTIO_VHOST_VDPA_H #define HW_VIRTIO_VHOST_VDPA_H +#include <gmodule.h> +#include "hw/virtio/virtio.h" #include "standard-headers/linux/vhost_types.h"
@@ -27,6 +29,8 @@ typedef struct vhost_vdpa {bool iotlb_batch_begin_sent;MemoryListener listener;struct vhost_vdpa_iova_range iova_range; +bool shadow_vqs_enabled; +GPtrArray *shadow_vqs;struct vhost_dev *dev;VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX ]; } VhostVDPA;
Signature · 1 line
2.7.4
[PULL V3 13/15] vdpa: Adapt vhost_vdpa_get_vring_base to SVQ
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
This is needed to achieve migration, so the destination can restore its index.
Setting base as last used idx, so destination will see as available all the entries that the device did not use, including the in-flight processing ones.
This is ok for networking, but other kinds of devices might have problems with these retransmissions.
--- hw/virtio/vhost-vdpa.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
hw/virtio/vhost-vdpa.c +17 -0
@@ -1141,8 +1141,25 @@ static int vhost_vdpa_set_vring_base(struct vhost_dev *dev,static int vhost_vdpa_get_vring_base (struct vhost_dev *dev,struct vhost_vring_state *ring) { +struct vhost_vdpa *v = dev->opaque;int ret; +if (v->shadow_vqs_enabled) { +VhostShadowVirtqueue *svq =g_ptr_array_index (v->shadow_vqs, + ring->index); + +/* +* Setting base as last used idx, so destination will see as available +* all the entries that the device did not use, including the in-flight +* processing ones. +* +* TODO: This is ok for networking, but other kinds of devices might +* have problems with these retransmissions. +*/ + ring->num = svq->last_used_idx; +return 0 ; + } + ret =vhost_vdpa_call (dev,VHOST_GET_VRING_BASE , ring);trace_vhost_vdpa_get_vring_base (dev, ring->index, ring->num);return ret;
Signature · 1 line
2.7.4
[PULL V3 05/15] vhost: Add vhost_svq_valid_features to shadow vq
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
This allows SVQ to negotiate features with the guest and the device. For the device, SVQ is a driver. While this function bypasses all non-transport features, it needs to disable the features that SVQ does not support when forwarding buffers. This includes packed vq layout, indirect descriptors or event idx.
Future changes can add support to offer more features to the guest, since the use of VirtQueue gives this for free. This is left out at the moment for simplicity.
--- hw/virtio/vhost-shadow-virtqueue.c | 44 ++++++++++++++++++++++++++++++++++++++ hw/virtio/vhost-shadow-virtqueue.h | 2 ++ hw/virtio/vhost-vdpa.c | 15 +++++++++++++ 3 files changed, 61 insertions(+)
hw/virtio/vhost-shadow-virtqueue.c +44 -0
@@ -11,10 +11,54 @@#include "hw/virtio/vhost-shadow-virtqueue.h" #include "qemu/error-report.h" +#include "qapi/error.h" #include "qemu/main-loop.h" #include "linux-headers/linux/vhost.h" /** +* Validate the transport device features that both guests can use with the SVQ +* and SVQs can use with the device. +* +* @dev_features: The features +* @errp: Error pointer +*/ +bool vhost_svq_valid_features (uint64_t features,Error **errp) +{ +bool ok = true; +uint64_t svq_features = features; + +for (uint64_t b =VIRTIO_TRANSPORT_F_START ; b <=VIRTIO_TRANSPORT_F_END ; + ++b) { +switch (b) { +case VIRTIO_F_ANY_LAYOUT : +continue ; + +case VIRTIO_F_ACCESS_PLATFORM : +/* SVQ trust in the host's IOMMU to translate addresses */ +case VIRTIO_F_VERSION_1 : +/* SVQ trust that the guest vring is little endian */ +if (!(svq_features &BIT_ULL (b))) { + svq_features |=BIT_ULL (b); + ok = false; + } +continue ; + +default : +if (svq_features &BIT_ULL (b)) { + svq_features &= ~BIT_ULL (b); + ok = false; + } + } + } + +if (!ok) { +error_setg (errp,"SVQ Invalid device feature flags, offer: 0x%" PRIx64 +", ok: 0x%" PRIx64, features, svq_features); + } +return ok; +} + +/** * Forward guest notifications. * * @n: guest kick event notifier, the one that guest set to notify svq.
hw/virtio/vhost-shadow-virtqueue.h +2 -0
@@ -33,6 +33,8 @@ typedef struct VhostShadowVirtqueue {EventNotifier svq_call; } VhostShadowVirtqueue; +bool vhost_svq_valid_features (uint64_t features,Error **errp); +void vhost_svq_set_svq_kick_fd (VhostShadowVirtqueue *svq,int svq_kick_fd);void vhost_svq_set_svq_call_fd (VhostShadowVirtqueue *svq,int call_fd);
hw/virtio/vhost-vdpa.c +15 -0
@@ -348,11 +348,26 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v, Error **errp) {g_autoptr (GPtrArray) shadow_vqs =NULL ; +uint64_t dev_features, svq_features; +int r; +bool ok;if (!v->shadow_vqs_enabled) {return 0 ; } + r = hdev->vhost_ops->vhost_get_features (hdev, &dev_features); +if (r !=0 ) { +error_setg_errno (errp, -r,"Can't get vdpa device features" ); +return r; + } + + svq_features = dev_features; + ok =vhost_svq_valid_features (svq_features, errp); +if (unlikely (!ok)) { +return -1 ; + } + shadow_vqs =g_ptr_array_new_full (hdev->nvqs, vhost_svq_free);for (unsigned n =0 ; n < hdev->nvqs; ++n) {g_autoptr (VhostShadowVirtqueue) svq =vhost_svq_new ();
Signature · 1 line
2.7.4
[PULL V3 06/15] virtio: Add vhost_svq_get_vring_addr
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
It reports the shadow virtqueue address from qemu virtual address space.
Since this will be different from the guest's vaddr, but the device can access it, SVQ takes special care about its alignment & lack of garbage data. It assumes that IOMMU will work in host_page_size ranges for that.
--- hw/virtio/vhost-shadow-virtqueue.c | 29 +++++++++++++++++++++++++++++ hw/virtio/vhost-shadow-virtqueue.h | 9 +++++++++ 2 files changed, 38 insertions(+)
hw/virtio/vhost-shadow-virtqueue.c +29 -0
@@ -107,6 +107,35 @@ void vhost_svq_set_svq_call_fd(VhostShadowVirtqueue *svq, int call_fd) }/** +* Get the shadow vq vring address. +* @svq: Shadow virtqueue +* @addr: Destination to store address +*/ +void vhost_svq_get_vring_addr (const VhostShadowVirtqueue *svq, +struct vhost_vring_addr *addr) +{ + addr->desc_user_addr = (uint64_t )(intptr_t )svq->vring.desc; + addr->avail_user_addr = (uint64_t )(intptr_t )svq->vring.avail; + addr->used_user_addr = (uint64_t )(intptr_t )svq->vring.used; +} + +size_t vhost_svq_driver_area_size (const VhostShadowVirtqueue *svq) +{ +size_t desc_size =sizeof (vring_desc_t) * svq->vring.num; +size_t avail_size = offsetof(vring_avail_t , ring) + +sizeof (uint16_t ) * svq->vring.num; + +return ROUND_UP (desc_size + avail_size, qemu_real_host_page_size); +} + +size_t vhost_svq_device_area_size (const VhostShadowVirtqueue *svq) +{ +size_t used_size = offsetof(vring_used_t , ring) + +sizeof (vring_used_elem_t) * svq->vring.num; +return ROUND_UP (used_size, qemu_real_host_page_size); +} + +/** * Set a new file descriptor for the guest to kick the SVQ and notify for avail * * @svq: The svq
hw/virtio/vhost-shadow-virtqueue.h +9 -0
@@ -11,9 +11,14 @@#define VHOST_SHADOW_VIRTQUEUE_H #include "qemu/event_notifier.h" +#include "hw/virtio/virtio.h" +#include "standard-headers/linux/vhost_types.h" /* Shadow virtqueue to relay notifications */ typedef struct VhostShadowVirtqueue { + /* Shadow vring */ + struct vring vring; + /* Shadow kick notifier, sent to vhost */ EventNotifier hdev_kick; /* Shadow call notifier, sent to vhost */
@@ -37,6 +42,10 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp);void vhost_svq_set_svq_kick_fd (VhostShadowVirtqueue *svq,int svq_kick_fd);void vhost_svq_set_svq_call_fd (VhostShadowVirtqueue *svq,int call_fd); +void vhost_svq_get_vring_addr (const VhostShadowVirtqueue *svq, +struct vhost_vring_addr *addr); +size_t vhost_svq_driver_area_size (const VhostShadowVirtqueue *svq); +size_t vhost_svq_device_area_size (const VhostShadowVirtqueue *svq);void vhost_svq_stop (VhostShadowVirtqueue *svq);
Signature · 1 line
2.7.4
[PULL V3 07/15] vdpa: adapt vhost_ops callbacks to svq
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
First half of the buffers forwarding part, preparing vhost-vdpa callbacks to SVQ to offer it. QEMU cannot enable it at this moment, so this is effectively dead code at the moment, but it helps to reduce patch size.
--- hw/virtio/vhost-vdpa.c | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-)
hw/virtio/vhost-vdpa.c +41 -7
@@ -733,6 +733,13 @@ static int vhost_vdpa_get_config(struct vhost_dev *dev, uint8_t *config,return ret; } +static int vhost_vdpa_set_dev_vring_base (struct vhost_dev *dev, +struct vhost_vring_state *ring) +{ +trace_vhost_vdpa_set_vring_base (dev, ring->index, ring->num); +return vhost_vdpa_call (dev,VHOST_SET_VRING_BASE , ring); +} +static int vhost_vdpa_set_vring_dev_kick (struct vhost_dev *dev,struct vhost_vring_file *file) {
@@ -747,6 +754,18 @@ static int vhost_vdpa_set_vring_dev_call(struct vhost_dev *dev,return vhost_vdpa_call (dev,VHOST_SET_VRING_CALL , file); } +static int vhost_vdpa_set_vring_dev_addr (struct vhost_dev *dev, +struct vhost_vring_addr *addr) +{ +trace_vhost_vdpa_set_vring_addr (dev, addr->index, addr->flags, + addr->desc_user_addr, addr->used_user_addr, + addr->avail_user_addr, + addr->log_guest_addr); + +return vhost_vdpa_call (dev,VHOST_SET_VRING_ADDR , addr); + +} +/** * Set the shadow virtqueue descriptors to the device *
@@ -856,11 +875,17 @@ static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base,static int vhost_vdpa_set_vring_addr (struct vhost_dev *dev,struct vhost_vring_addr *addr) { -trace_vhost_vdpa_set_vring_addr (dev, addr->index, addr->flags, - addr->desc_user_addr, addr->used_user_addr, - addr->avail_user_addr, - addr->log_guest_addr); -return vhost_vdpa_call (dev,VHOST_SET_VRING_ADDR , addr); +struct vhost_vdpa *v = dev->opaque; + +if (v->shadow_vqs_enabled) { +/* +* Device vring addr was set at device start. SVQ base is handled by +* VirtQueue code. +*/ +return 0 ; + } + +return vhost_vdpa_set_vring_dev_addr (dev, addr); } static int vhost_vdpa_set_vring_num(struct vhost_dev *dev,
@@ -873,8 +898,17 @@ static int vhost_vdpa_set_vring_num(struct vhost_dev *dev,static int vhost_vdpa_set_vring_base (struct vhost_dev *dev,struct vhost_vring_state *ring) { -trace_vhost_vdpa_set_vring_base (dev, ring->index, ring->num); -return vhost_vdpa_call (dev,VHOST_SET_VRING_BASE , ring); +struct vhost_vdpa *v = dev->opaque; + +if (v->shadow_vqs_enabled) { +/* +* Device vring base was set at device start. SVQ base is handled by +* VirtQueue code. +*/ +return 0 ; + } + +return vhost_vdpa_set_dev_vring_base (dev, ring); } static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
Signature · 1 line
2.7.4
[PULL V3 08/15] vhost: Shadow virtqueue buffers forwarding
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
Initial version of shadow virtqueue that actually forward buffers. There is no iommu support at the moment, and that will be addressed in future patches of this series. Since all vhost-vdpa devices use forced IOMMU, this means that SVQ is not usable at this point of the series on any device.
For simplicity it only supports modern devices, that expects vring in little endian, with split ring and no event idx or indirect descriptors. Support for them will not be added in this series.
It reuses the VirtQueue code for the device part. The driver part is based on Linux's virtio_ring driver, but with stripped functionality and optimizations so it's easier to review.
However, forwarding buffers have some particular pieces: One of the most unexpected ones is that a guest's buffer can expand through more than one descriptor in SVQ. While this is handled gracefully by qemu's emulated virtio devices, it may cause unexpected SVQ queue full. This patch also solves it by checking for this condition at both guest's kicks and device's calls. The code may be more elegant in the future if SVQ code runs in its own iocontext.
--- hw/virtio/vhost-shadow-virtqueue.c | 352 ++++++++++++++++++++++++++++++++++++- hw/virtio/vhost-shadow-virtqueue.h | 26 +++ hw/virtio/vhost-vdpa.c | 155 +++++++++++++++- 3 files changed, 522 insertions(+), 11 deletions(-)
hw/virtio/vhost-shadow-virtqueue.c +346 -6
@@ -13,6 +13,8 @@#include "qemu/error-report.h" #include "qapi/error.h" #include "qemu/main-loop.h" +#include "qemu/log.h" +#include "qemu/memalign.h" #include "linux-headers/linux/vhost.h" /**
@@ -59,28 +61,307 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp) }/** -* Forward guest notifications. +* Number of descriptors that the SVQ can make available from the guest. +* +* @svq: The svq +*/ +static uint16_t vhost_svq_available_slots (const VhostShadowVirtqueue *svq) +{ +return svq->vring.num - (svq->shadow_avail_idx - svq->shadow_used_idx); +} + +static void vhost_vring_write_descs (VhostShadowVirtqueue *svq, +const struct iovec *iovec,size_t num, +bool more_descs,bool write) +{ +uint16_t i = svq->free_head, last = svq->free_head; +unsigned n; +uint16_t flags = write ?cpu_to_le16 (VRING_DESC_F_WRITE ) :0 ; +vring_desc_t *descs = svq->vring.desc; + +if (num ==0 ) { +return ; + } + +for (n =0 ; n < num; n++) { +if (more_descs || (n +1 < num)) { + descs[i].flags = flags |cpu_to_le16 (VRING_DESC_F_NEXT ); + }else { + descs[i].flags = flags; + } + descs[i].addr =cpu_to_le64 ((hwaddr )(intptr_t )iovec[n].iov_base); + descs[i].len =cpu_to_le32 (iovec[n].iov_len); + + last = i; + i =cpu_to_le16 (descs[i].next); + } + + svq->free_head =le16_to_cpu (descs[last].next); +} + +static bool vhost_svq_add_split (VhostShadowVirtqueue *svq, +VirtQueueElement *elem,unsigned *head) +{ +unsigned avail_idx; +vring_avail_t *avail = svq->vring.avail; + + *head = svq->free_head; + +/* We need some descriptors here */ +if (unlikely (!elem->out_num && !elem->in_num)) { +qemu_log_mask (LOG_GUEST_ERROR , +"Guest provided element with no descriptors" ); +return false; + } + +vhost_vring_write_descs (svq, elem->out_sg, elem->out_num, elem->in_num >0 , + false); +vhost_vring_write_descs (svq, elem->in_sg, elem->in_num, false, true); + +/* +* Put the entry in the available array (but don't update avail->idx until +* they do sync). +*/ + avail_idx = svq->shadow_avail_idx & (svq->vring.num -1 ); + avail->ring[avail_idx] =cpu_to_le16 (*head); + svq->shadow_avail_idx++; + +/* Update the avail index after write the descriptor */ +smp_wmb (); + avail->idx =cpu_to_le16 (svq->shadow_avail_idx); + +return true; +} + +static bool vhost_svq_add (VhostShadowVirtqueue *svq,VirtQueueElement *elem) +{ +unsigned qemu_head; +bool ok =vhost_svq_add_split (svq, elem, &qemu_head); +if (unlikely (!ok)) { +return false; + } + + svq->ring_id_maps[qemu_head] = elem; +return true; +} + +static void vhost_svq_kick (VhostShadowVirtqueue *svq) +{ +/* +* We need to expose the available array entries before checking the used +* flags +*/ +smp_mb (); +if (svq->vring.used->flags &VRING_USED_F_NO_NOTIFY ) { +return ; + } + +event_notifier_set (&svq->hdev_kick); +} + +/** +* Forward available buffers. +* +* @svq: Shadow VirtQueue +* +* Note that this function does not guarantee that all guest's available +* buffers are available to the device in SVQ avail ring. The guest may have +* exposed a GPA / GIOVA contiguous buffer, but it may not be contiguous in +* qemu vaddr. +* +* If that happens, guest's kick notifications will be disabled until the +* device uses some buffers. +*/ +static void vhost_handle_guest_kick (VhostShadowVirtqueue *svq) +{ +/* Clear event notifier */ +event_notifier_test_and_clear (&svq->svq_kick); + +/* Forward to the device as many available buffers as possible */ +do { +virtio_queue_set_notification (svq->vq, false); + +while (true) { +VirtQueueElement *elem; +bool ok; + +if (svq->next_guest_avail_elem) { + elem =g_steal_pointer (&svq->next_guest_avail_elem); + }else { + elem =virtqueue_pop (svq->vq,sizeof (*elem)); + } + +if (!elem) { +break ; + } + +if (elem->out_num + elem->in_num >vhost_svq_available_slots (svq)) { +/* +* This condition is possible since a contiguous buffer in GPA +* does not imply a contiguous buffer in qemu's VA +* scatter-gather segments. If that happens, the buffer exposed +* to the device needs to be a chain of descriptors at this +* moment. +* +* SVQ cannot hold more available buffers if we are here: +* queue the current guest descriptor and ignore further kicks +* until some elements are used. +*/ + svq->next_guest_avail_elem = elem; +return ; + } + + ok =vhost_svq_add (svq, elem); +if (unlikely (!ok)) { +/* VQ is broken, just return and ignore any other kicks */ +return ; + } +vhost_svq_kick (svq); + } + +virtio_queue_set_notification (svq->vq, true); + }while (!virtio_queue_empty (svq->vq)); +} + +/** +* Handle guest's kick. * * @n: guest kick event notifier, the one that guest set to notify svq. */ -static void vhost_handle_guest_kick (EventNotifier *n) +static void vhost_handle_guest_kick_notifier (EventNotifier *n) {VhostShadowVirtqueue *svq =container_of (n, VhostShadowVirtqueue, svq_kick);event_notifier_test_and_clear (n); -event_notifier_set (&svq->hdev_kick); +vhost_handle_guest_kick (svq); +} + +static bool vhost_svq_more_used (VhostShadowVirtqueue *svq) +{ +if (svq->last_used_idx != svq->shadow_used_idx) { +return true; + } + + svq->shadow_used_idx =cpu_to_le16 (svq->vring.used->idx); + +return svq->last_used_idx != svq->shadow_used_idx; }/** -* Forward vhost notifications +* Enable vhost device calls after disable them. +* +* @svq: The svq +* +* It returns false if there are pending used buffers from the vhost device, +* avoiding the possible races between SVQ checking for more work and enabling +* callbacks. True if SVQ used vring has no more pending buffers. +*/ +static bool vhost_svq_enable_notification (VhostShadowVirtqueue *svq) +{ + svq->vring.avail->flags &= ~cpu_to_le16 (VRING_AVAIL_F_NO_INTERRUPT ); +/* Make sure the flag is written before the read of used_idx */ +smp_mb (); +return !vhost_svq_more_used (svq); +} + +static void vhost_svq_disable_notification (VhostShadowVirtqueue *svq) +{ + svq->vring.avail->flags |=cpu_to_le16 (VRING_AVAIL_F_NO_INTERRUPT ); +} + +static VirtQueueElement *vhost_svq_get_buf (VhostShadowVirtqueue *svq, +uint32_t *len) +{ +vring_desc_t *descs = svq->vring.desc; +const vring_used_t *used = svq->vring.used; +vring_used_elem_t used_elem; +uint16_t last_used; + +if (!vhost_svq_more_used (svq)) { +return NULL ; + } + +/* Only get used array entries after they have been exposed by dev */ +smp_rmb (); + last_used = svq->last_used_idx & (svq->vring.num -1 ); + used_elem.id =le32_to_cpu (used->ring[last_used].id); + used_elem.len =le32_to_cpu (used->ring[last_used].len); + + svq->last_used_idx++; +if (unlikely (used_elem.id >= svq->vring.num)) { +qemu_log_mask (LOG_GUEST_ERROR ,"Device %s says index %u is used" , + svq->vdev->name, used_elem.id); +return NULL ; + } + +if (unlikely (!svq->ring_id_maps[used_elem.id])) { +qemu_log_mask (LOG_GUEST_ERROR , +"Device %s says index %u is used, but it was not available" , + svq->vdev->name, used_elem.id); +return NULL ; + } + + descs[used_elem.id].next = svq->free_head; + svq->free_head = used_elem.id; + + *len = used_elem.len; +return g_steal_pointer (&svq->ring_id_maps[used_elem.id]); +} + +static void vhost_svq_flush (VhostShadowVirtqueue *svq, +bool check_for_avail_queue) +{ +VirtQueue *vq = svq->vq; + +/* Forward as many used buffers as possible. */ +do { +unsigned i =0 ; + +vhost_svq_disable_notification (svq); +while (true) { +uint32_t len; + g_autofree VirtQueueElement *elem = vhost_svq_get_buf(svq, &len); +if (!elem) { +break ; + } + +if (unlikely (i >= svq->vring.num)) { +qemu_log_mask (LOG_GUEST_ERROR , +"More than %u used buffers obtained in a %u size SVQ" , + i, svq->vring.num); +virtqueue_fill (vq, elem, len, i); +virtqueue_flush (vq, i); +return ; + } +virtqueue_fill (vq, elem, len, i++); + } + +virtqueue_flush (vq, i); +event_notifier_set (&svq->svq_call); + +if (check_for_avail_queue && svq->next_guest_avail_elem) { +/* +* Avail ring was full when vhost_svq_flush was called, so it's a +* good moment to make more descriptors available if possible. +*/ +vhost_handle_guest_kick (svq); + } + }while (!vhost_svq_enable_notification (svq)); +} + +/** +* Forward used buffers. * * @n: hdev call event notifier, the one that device set to notify svq. +* +* Note that we are not making any buffers available in the loop, there is no +* way that it runs more than virtqueue size times. */ static void vhost_svq_handle_call (EventNotifier *n) {VhostShadowVirtqueue *svq =container_of (n, VhostShadowVirtqueue, hdev_call);event_notifier_test_and_clear (n); -event_notifier_set (&svq->svq_call); +vhost_svq_flush (svq, true); }/**
@@ -161,7 +442,41 @@ void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd)if (poll_start) {event_notifier_init_fd (svq_kick, svq_kick_fd);event_notifier_set (svq_kick); -event_notifier_set_handler (svq_kick, vhost_handle_guest_kick); +event_notifier_set_handler (svq_kick, vhost_handle_guest_kick_notifier); + } +} + +/** +* Start the shadow virtqueue operation. +* +* @svq: Shadow Virtqueue +* @vdev: VirtIO device +* @vq: Virtqueue to shadow +*/ +void vhost_svq_start (VhostShadowVirtqueue *svq,VirtIODevice *vdev, +VirtQueue *vq) +{ +size_t desc_size, driver_size, device_size; + + svq->next_guest_avail_elem =NULL ; + svq->shadow_avail_idx =0 ; + svq->shadow_used_idx =0 ; + svq->last_used_idx =0 ; + svq->vdev = vdev; + svq->vq = vq; + + svq->vring.num =virtio_queue_get_num (vdev,virtio_get_queue_index (vq)); + driver_size =vhost_svq_driver_area_size (svq); + device_size =vhost_svq_device_area_size (svq); + svq->vring.desc =qemu_memalign (qemu_real_host_page_size, driver_size); + desc_size =sizeof (vring_desc_t) * svq->vring.num; + svq->vring.avail = (void *)((char *)svq->vring.desc + desc_size); +memset (svq->vring.desc,0 , driver_size); + svq->vring.used =qemu_memalign (qemu_real_host_page_size, device_size); +memset (svq->vring.used,0 , device_size); + svq->ring_id_maps = g_new0(VirtQueueElement *, svq->vring.num); +for (unsigned i =0 ; i < svq->vring.num -1 ; i++) { + svq->vring.desc[i].next =cpu_to_le16 (i +1 ); } }
@@ -172,6 +487,31 @@ void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd)void vhost_svq_stop (VhostShadowVirtqueue *svq) {event_notifier_set_handler (&svq->svq_kick,NULL ); + g_autofree VirtQueueElement *next_avail_elem = NULL; + +if (!svq->vq) { +return ; + } + +/* Send all pending used descriptors to guest */ +vhost_svq_flush (svq, false); + +for (unsigned i =0 ; i < svq->vring.num; ++i) { + g_autofree VirtQueueElement *elem = NULL; + elem =g_steal_pointer (&svq->ring_id_maps[i]); +if (elem) { +virtqueue_detach_element (svq->vq, elem,0 ); + } + } + + next_avail_elem =g_steal_pointer (&svq->next_guest_avail_elem); +if (next_avail_elem) { +virtqueue_detach_element (svq->vq, next_avail_elem,0 ); + } + svq->vq =NULL ; +g_free (svq->ring_id_maps); +qemu_vfree (svq->vring.desc); +qemu_vfree (svq->vring.used); }/**
hw/virtio/vhost-shadow-virtqueue.h +26 -0
@@ -36,6 +36,30 @@ typedef struct VhostShadowVirtqueue {/* Guest's call notifier, where the SVQ calls guest. */ EventNotifier svq_call; + +/* Virtio queue shadowing */ +VirtQueue *vq; + +/* Virtio device */ +VirtIODevice *vdev; + +/* Map for use the guest's descriptors */ +VirtQueueElement **ring_id_maps; + +/* Next VirtQueue element that guest made available */ +VirtQueueElement *next_guest_avail_elem; + +/* Next head to expose to the device */ +uint16_t shadow_avail_idx; + +/* Next free descriptor */ +uint16_t free_head; + +/* Last seen used idx */ +uint16_t shadow_used_idx; + +/* Next head to consume from the device */ +uint16_t last_used_idx; } VhostShadowVirtqueue;bool vhost_svq_valid_features (uint64_t features,Error **errp);
@@ -47,6 +71,8 @@ void vhost_svq_get_vring_addr(const VhostShadowVirtqueue *svq,size_t vhost_svq_driver_area_size (const VhostShadowVirtqueue *svq);size_t vhost_svq_device_area_size (const VhostShadowVirtqueue *svq); +void vhost_svq_start (VhostShadowVirtqueue *svq,VirtIODevice *vdev, +VirtQueue *vq);void vhost_svq_stop (VhostShadowVirtqueue *svq);VhostShadowVirtqueue *vhost_svq_new (void );
hw/virtio/vhost-vdpa.c +150 -5
188 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PULL V3 08/15] vhost: Shadow virtqueue buffers forwarding
Quoted 17 lines · Jason Wang
From: Eugenio Pérez <[email protected]>
Initial version of shadow virtqueue that actually forward buffers. There is no iommu support at the moment, and that will be addressed in future patches of this series. Since all vhost-vdpa devices use forced IOMMU, this means that SVQ is not usable at this point of the series on any device.
For simplicity it only supports modern devices, that expects vring in little endian, with split ring and no event idx or indirect descriptors. Support for them will not be added in this series.
It reuses the VirtQueue code for the device part. The driver part is based on Linux's
virtio_ringdriver, but with stripped functionality and optimizations so it's easier to review.
Quoted 7 lines
However, forwarding buffers have some particular pieces: One of the most unexpected ones is that a guest's buffer can expand through more than one descriptor in SVQ. While this is handled gracefully by qemu's emulated virtio devices, it may cause unexpected SVQ queue full. This patch also solves it by checking for this condition at both guest's kicks and device's calls. The code may be more elegant in the future if SVQ code runs in its own iocontext.
Hi; Coverity thinks there's a memory leak in an error handling path in this code (CID 1487559):
Quoted 21 lines
hw/virtio/vhost-shadow-virtqueue.c +21
-0+/** +* Forward available buffers. +* +* @svq: Shadow VirtQueue +* +* Note that this function does not guarantee that all guest's available +* buffers are available to the device in SVQ avail ring. The guest may have +* exposed a GPA / GIOVA contiguous buffer, but it may not be contiguous in +* qemu vaddr. +* +* If that happens, guest's kick notifications will be disabled until the +* device uses some buffers. +*/ +static void vhost_handle_guest_kick (VhostShadowVirtqueue *svq) +{ +/* Clear event notifier */ +event_notifier_test_and_clear (&svq->svq_kick); + +/* Forward to the device as many available buffers as possible */ + do { + virtio_queue_set_notification(svq->vq, false);
hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 192
Quoted 10 lines
hw/virtio/vhost-shadow-virtqueue.c +10
-0+ +while (true) { +VirtQueueElement *elem; +bool ok; + +if (svq->next_guest_avail_elem) { + elem =g_steal_pointer (&svq->next_guest_avail_elem); + }else { + elem =virtqueue_pop (svq->vq,sizeof (*elem)); + }
Here virtqueue_pop() returns allocated memory...
Quoted 15 lines
hw/virtio/vhost-shadow-virtqueue.c +15
-0+ +if (!elem) { +break ; + } + +if (elem->out_num + elem->in_num >vhost_svq_available_slots (svq)) { +/* +* This condition is possible since a contiguous buffer in GPA +* does not imply a contiguous buffer in qemu's VA +* scatter-gather segments. If that happens, the buffer exposed +* to the device needs to be a chain of descriptors at this +* moment. +* +* SVQ cannot hold more available buffers if we are here: +* queue the current guest descriptor and ignore further kicks
hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 217
Quoted 10 lines
hw/virtio/vhost-shadow-virtqueue.c +10
-0+* until some elements are used. +*/ + svq->next_guest_avail_elem = elem; +return ; + } + + ok =vhost_svq_add (svq, elem); +if (unlikely (!ok)) { +/* VQ is broken, just return and ignore any other kicks */ +return ;
...but in this error return path we have neither put elem anywhere, nor freed it, so the memory is leaked.
hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 224
Quoted 7 lines
hw/virtio/vhost-shadow-virtqueue.c +7
-0+ } +vhost_svq_kick (svq); + } + +virtio_queue_set_notification (svq->vq, true); + }while (!virtio_queue_empty (svq->vq)); +}
thanks
-- PMM
Re: [PULL V3 08/15] vhost: Shadow virtqueue buffers forwarding
Quoted 93 lines · Peter Maydell
Quoted 17 lines · Jason Wang
From: Eugenio Pérez <[email protected]>
Initial version of shadow virtqueue that actually forward buffers. There is no iommu support at the moment, and that will be addressed in future patches of this series. Since all vhost-vdpa devices use forced IOMMU, this means that SVQ is not usable at this point of the series on any device.
For simplicity it only supports modern devices, that expects vring in little endian, with split ring and no event idx or indirect descriptors. Support for them will not be added in this series.
It reuses the VirtQueue code for the device part. The driver part is based on Linux's
virtio_ringdriver, but with stripped functionality and optimizations so it's easier to review.Quoted 7 lines
However, forwarding buffers have some particular pieces: One of the most unexpected ones is that a guest's buffer can expand through more than one descriptor in SVQ. While this is handled gracefully by qemu's emulated virtio devices, it may cause unexpected SVQ queue full. This patch also solves it by checking for this condition at both guest's kicks and device's calls. The code may be more elegant in the future if SVQ code runs in its own iocontext.
Hi; Coverity thinks there's a memory leak in an error handling path in this code (CID 1487559):
Quoted 21 lines
hw/virtio/vhost-shadow-virtqueue.c +21
-0+/** +* Forward available buffers. +* +* @svq: Shadow VirtQueue +* +* Note that this function does not guarantee that all guest's available +* buffers are available to the device in SVQ avail ring. The guest may have +* exposed a GPA / GIOVA contiguous buffer, but it may not be contiguous in +* qemu vaddr. +* +* If that happens, guest's kick notifications will be disabled until the +* device uses some buffers. +*/ +static void vhost_handle_guest_kick (VhostShadowVirtqueue *svq) +{ +/* Clear event notifier */ +event_notifier_test_and_clear (&svq->svq_kick); + +/* Forward to the device as many available buffers as possible */ + do { + virtio_queue_set_notification(svq->vq, false);hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 192
Quoted 10 lines
hw/virtio/vhost-shadow-virtqueue.c +10
-0+ +while (true) { +VirtQueueElement *elem; +bool ok; + +if (svq->next_guest_avail_elem) { + elem =g_steal_pointer (&svq->next_guest_avail_elem); + }else { + elem =virtqueue_pop (svq->vq,sizeof (*elem)); + }Here
virtqueue_pop()returns allocated memory...Quoted 15 lines
hw/virtio/vhost-shadow-virtqueue.c +15
-0+ +if (!elem) { +break ; + } + +if (elem->out_num + elem->in_num >vhost_svq_available_slots (svq)) { +/* +* This condition is possible since a contiguous buffer in GPA +* does not imply a contiguous buffer in qemu's VA +* scatter-gather segments. If that happens, the buffer exposed +* to the device needs to be a chain of descriptors at this +* moment. +* +* SVQ cannot hold more available buffers if we are here: +* queue the current guest descriptor and ignore further kicks hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 217
Quoted 10 lines
hw/virtio/vhost-shadow-virtqueue.c +10
-0+* until some elements are used. +*/ + svq->next_guest_avail_elem = elem; +return ; + } + + ok =vhost_svq_add (svq, elem); +if (unlikely (!ok)) { +/* VQ is broken, just return and ignore any other kicks */ +return ;...but in this error return path we have neither put elem anywhere, nor freed it, so the memory is leaked.
Quoted 8 lines
hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 224
Quoted 7 lines
hw/virtio/vhost-shadow-virtqueue.c +7
-0+ } +vhost_svq_kick (svq); + } + +virtio_queue_set_notification (svq->vq, true); + }while (!virtio_queue_empty (svq->vq)); +}
Thank you very much for the analysis. There is no way to enable SVQ at this moment, so we cannot trigger the leak in master. Should we backport the fix to stable?
Sending patches for this and other bugs detected while working on the next iteration of SVQ.
Thanks!
Quoted 3 lines
thanks
-- PMM
[PULL V3 11/15] vhost: Add VhostIOVATree
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
This tree is able to look for a translated address from an IOVA address.
At first glance it is similar to util/iova-tree. However, SVQ working on devices with limited IOVA space need more capabilities, like allocating IOVA chunks or performing reverse translations (qemu addresses to iova).
The allocation capability, as "assign a free IOVA address to this chunk of memory in qemu's address space" allows shadow virtqueue to create a new address space that is not restricted by guest's addressable one, so we can allocate shadow vqs vrings outside of it.
It duplicates the tree so it can search efficiently in both directions, and it will signal overlap if iova or the translated address is present in any tree.
--- hw/virtio/meson.build | 2 +- hw/virtio/vhost-iova-tree.c | 110 ++++++++++++++++++++++++++++++++++++++++++++ hw/virtio/vhost-iova-tree.h | 27 +++++++++++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 hw/virtio/vhost-iova-tree.c create mode 100644 hw/virtio/vhost-iova-tree.h
hw/virtio/meson.build +1 -1
@@ -11,7 +11,7 @@ softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c')) virtio_ss = ss.source_set() virtio_ss.add(files('virtio.c')) -virtio_ss.add(when: 'CONFIG_VHOST', if_true: files('vhost.c', 'vhost-backend.c', 'vhost-shadow-virtqueue.c')) +virtio_ss.add(when: 'CONFIG_VHOST', if_true: files('vhost.c', 'vhost-backend.c', 'vhost-shadow-virtqueue.c', 'vhost-iova-tree.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user.c')) virtio_ss.add(when: 'CONFIG_VHOST_VDPA', if_true: files('vhost-vdpa.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-balloon.c'))
hw/virtio/vhost-iova-tree.c new file +110 -0
110 lines not on this page · raw message
hw/virtio/vhost-iova-tree.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* vhost software live migration iova tree +* +* SPDX-FileCopyrightText: Red Hat, Inc. 2021 +* SPDX-FileContributor: Author: Eugenio Pérez <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_VIRTIO_VHOST_IOVA_TREE_H +#define HW_VIRTIO_VHOST_IOVA_TREE_H + +#include "qemu/iova-tree.h" +#include "exec/memory.h" + +typedef struct VhostIOVATree VhostIOVATree ; + +VhostIOVATree *vhost_iova_tree_new (uint64_t iova_first,uint64_t iova_last); +void vhost_iova_tree_delete (VhostIOVATree *iova_tree); +G_DEFINE_AUTOPTR_CLEANUP_FUNC (VhostIOVATree, vhost_iova_tree_delete); + +const DMAMap *vhost_iova_tree_find_iova (const VhostIOVATree *iova_tree, +const DMAMap *map); +int vhost_iova_tree_map_alloc (VhostIOVATree *iova_tree,DMAMap *map); +void vhost_iova_tree_remove (VhostIOVATree *iova_tree,const DMAMap *map); + +#endif
Signature · 1 line
2.7.4
Peter Maydell
AppliedQuoted 9 lines · Jason Wang
The following changes since commit
352998df1c53b366413690d95b35f76d0721ebed:Merge tag 'i2c-20220314' of https://github.com/philmd/qemu into staging (2022-03-14 14:39:33 +0000)
are available in the git repository at:
https://github.com/jasowang/qemu.git tags/net-pull-request
Quoted 9 lines
for you to fetch changes up to
12a195fa343aae2ead1301ce04727bd0ae25eb15:vdpa: Expose
VHOST_F_LOG_ALLon SVQ (2022-03-15 13:57:44 +0800)----------------------------------------------------------------
Changes since V2:
- fix 32bit build errros
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/7.0
for any user-visible changes.
-- PMM