Handling aliased guest memory maps in vhost-vDPA SVQs
v2 cover Handling aliased guest memory maps in vhost-vDPA SVQs
An issue arises from aliased memory mappings in the guest, where different GPAs map to the same HVA. For example:
- GPA1->HVA1
- GPA2->HVA1
When these mappings exist in the IOVA->HVA tree, a lookup by an HVA backed by guest memory results in ambiguities because the same HVA could correspond to multiple GPAs. This duplication causes issues in managing IOVA trees for SVQs in vDPA, leading to incorrect behavior.
For example, consider these mapped guest memory regions:
HVA GPA IOVA
------------------------------- --------------------------- ----------------------------
[0x7f7903e00000, 0x7f7983e00000) [0x0, 0x80000000) [0x1000, 0x80000000)
[0x7f7983e00000, 0x7f9903e00000) [0x100000000, 0x2080000000) [0x80001000, 0x2000001000)
[0x7f7903ea0000, 0x7f7903ec0000) [0xfeda0000, 0xfedc0000) [0x2000001000, 0x2000021000)
The last HVA range [0x7f7903ea0000, 0x7f7903ec0000) is contained within the first HVA range [0x7f7903e00000, 0x7f7983e00000). Despite this, the GPA ranges for the first and third mappings do not overlap, so the guest sees them as distinct physical memory regions.
Now consider an operation to unmap the mapping associated with HVA 0x7f7903eb0000. This HVA fits into both the first and third HVA ranges.
When searching the HVA->IOVA tree, the search stops at the first matching HVA range [0x7f7903e00000, 0x7f7983e00000) due to the behavior of the red-black tree (GTree). However, the correct mapping to remove is the third mappings, as the HVA translates to GPA 0xfedb0000, which only fits in the third mapping's GPA range.
To address this, we implement a GPA->IOVA tree and use the GPAs of descriptors backed by guest memory when translating to IOVA.
When a descriptor's GPA is used for translation, the GPA->IOVA tree ensures that each GPA maps to exactly one IOVA, regardless of any overlapping HVAs. This guarantees that operations such as unmapping or accessing a descriptor correctly targets the intended memory region in the guest's address space.
For descriptors not backed by guest memory, the existing IOVA->HVA tree is still used.
GPAs are unique and non-overlapping within the guest's address space. By translating GPAs to IOVAs, the ambiguity caused by multiple GPAs mapping to the same HVA is avoided.
--------
This series is a different approach of [1] and is based off of [2], where this issue was originally discovered.
Patch v2:
---------
* Squashed "Support translations via GPAs in vhost_svq_translate_addr" into "Implement GPA->IOVA & partial IOVA->HVA trees".
* Added signatures to commit messages where appropriate.
Patch v1:
---------
* Created separate alloc functions for guest-backed and host-only memory.
* Alloc functions also insert mappings to their respective trees.
* Make patches self-contained and functional to prevent breakage during bisection.
* Don't move range checks from alloc functions.
* Use existing VirtQueueElement members 'in_addr' & 'out_addr' instead of creating custom 'in_xlat_addr' & 'out_xlat_addr' members.
* Move documentation changes to separate patch.
RFC v3:
-------
* Decouple the IOVA allocator to support a SVQ IOVA->HVA tree for host-only mappings.
* Move range check for IOVA allocator to its own patch.
* Implement a GPA->IOVA tree alongside the SVQ IOVA->HVA & IOVA-only trees.
* Add in_xlat_addr & out_xlat_addr VirtQueueElement members to hold the GPAs of an element's input/output descriptors (to be used during translation).
RFC v2:
-------
* Don't decouple IOVA allocator.
* Build a IOVA->GPA tree (instead of GPA->IOVA tree).
* Remove IOVA-only tree and keep the full IOVA->HVA tree.
* Only search through RAMBlocks when we know the HVA is backed by guest memory.
* Slight rewording of function names.
RFC v1:
-------
* Alternative approach of [1].
* First attempt to address this issue found in [2].
[1] https://lore.kernel.org/qemu-devel/[email protected]
[2] https://lore.kernel.org/qemu-devel/[email protected]
Jonah Palmer (3):
vhost-iova-tree: Implement an IOVA-only tree vhost-iova-tree, svq: Implement GPA->IOVA & partial IOVA->HVA trees
vhost-iova-tree: Update documentation
hw/virtio/vhost-iova-tree.c | 115 ++++++++++++++++++++++++----- hw/virtio/vhost-iova-tree.h | 8 +- hw/virtio/vhost-shadow-virtqueue.c | 55 +++++++++----- hw/virtio/vhost-shadow-virtqueue.h | 5 +- hw/virtio/vhost-vdpa.c | 40 ++++++---- include/qemu/iova-tree.h | 22 ++++++ net/vhost-vdpa.c | 12 ++- util/iova-tree.c | 46 ++++++++++++ 8 files changed, 248 insertions(+), 55 deletions(-)
Signature · 1 line
2.43.5
PATCH v2 1/3 vhost-iova-tree: Implement an IOVA-only tree
Creates and supports an IOVA-only tree to support a SVQ IOVA->HVA and GPA->IOVA tree for host-only and guest-backed memory, respectively, in the next patch.
The IOVA allocator still allocates an IOVA range but now adds this range to the IOVA-only tree as well as to the full IOVA->HVA tree.
In the next patch, the full IOVA->HVA tree will be split into a partial SVQ IOVA->HVA tree and a GPA->IOVA tree. The motivation behind having an IOVA-only tree was to have a single tree that would keep track of all allocated IOVA ranges between the partial SVQ IOVA->HVA and GPA->IOVA trees.
--- hw/virtio/vhost-iova-tree.c | 26 ++++++++++++++++++++------ hw/virtio/vhost-iova-tree.h | 3 ++- hw/virtio/vhost-vdpa.c | 29 +++++++++++++++++++++-------- net/vhost-vdpa.c | 10 ++++++++-- 4 files changed, 51 insertions(+), 17 deletions(-)
hw/virtio/vhost-iova-tree.c +20 -6
@@ -28,6 +28,9 @@ struct VhostIOVATree {/* IOVA address to qemu memory maps. */ IOVATree *iova_taddr_map; + +/* Allocated IOVA addresses */ +IOVATree *iova_map; };/**
@@ -44,6 +47,7 @@ VhostIOVATree *vhost_iova_tree_new(hwaddr iova_first, hwaddr iova_last) tree->iova_last = iova_last; tree->iova_taddr_map =iova_tree_new (); + tree->iova_map =iova_tree_new ();return tree; }
@@ -53,6 +57,7 @@ VhostIOVATree *vhost_iova_tree_new(hwaddr iova_first, hwaddr iova_last)void vhost_iova_tree_delete (VhostIOVATree *iova_tree) {iova_tree_destroy (iova_tree->iova_taddr_map); +iova_tree_destroy (iova_tree->iova_map);g_free (iova_tree); }
@@ -75,6 +80,7 @@ const DMAMap *vhost_iova_tree_find_iova(const VhostIOVATree *tree,* * @tree: The iova tree * @map: The iova map +* @taddr: The translated address (HVA) * * Returns: * - IOVA_OK if the map fits in the container
@@ -83,19 +89,26 @@ const DMAMap *vhost_iova_tree_find_iova(const VhostIOVATree *tree,* * It returns assignated iova in map->iova if return value is VHOST_DMA_MAP_OK. */ -int vhost_iova_tree_map_alloc (VhostIOVATree *tree,DMAMap *map) +int vhost_iova_tree_map_alloc (VhostIOVATree *tree,DMAMap *map,hwaddr taddr) { +int ret; +/* Some vhost devices do not like addr 0. Skip first page */ hwaddr iova_first = tree->iova_first ?:qemu_real_host_page_size (); -if (map->translated_addr + map->size < map->translated_addr || - map->perm ==IOMMU_NONE ) { +if (taddr + map->size < taddr || map->perm ==IOMMU_NONE ) {return IOVA_ERR_INVALID ; } -/* Allocate a node in IOVA address */ -return iova_tree_alloc_map (tree->iova_taddr_map, map, iova_first, - tree->iova_last); +/* Allocate a node in the IOVA-only tree */ + ret =iova_tree_alloc_map (tree->iova_map, map, iova_first, tree->iova_last); +if (unlikely (ret !=IOVA_OK )) { +return ret; + } + +/* Insert a node in the IOVA->HVA tree */ + map->translated_addr = taddr; +return iova_tree_insert (tree->iova_taddr_map, map); }/**
@@ -107,4 +120,5 @@ int vhost_iova_tree_map_alloc(VhostIOVATree *tree, DMAMap *map)void vhost_iova_tree_remove (VhostIOVATree *iova_tree,DMAMap map) {iova_tree_remove (iova_tree->iova_taddr_map, map); +iova_tree_remove (iova_tree->iova_map, map); }
hw/virtio/vhost-iova-tree.h +2 -1
@@ -21,7 +21,8 @@ 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); +int vhost_iova_tree_map_alloc (VhostIOVATree *iova_tree,DMAMap *map, +hwaddr taddr);void vhost_iova_tree_remove (VhostIOVATree *iova_tree,DMAMap map);#endif
hw/virtio/vhost-vdpa.c +21 -8
@@ -360,14 +360,20 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, llsize =int128_sub (llend,int128_make64 (iova));if (s->shadow_data) {int r; +hwaddr hw_vaddr = (hwaddr )(uintptr_t )vaddr; - mem_region.translated_addr = (hwaddr )(uintptr_t )vaddr, mem_region.size =int128_get64 (llsize) -1 , mem_region.perm =IOMMU_ACCESS_FLAG (true, section->readonly), - r =vhost_iova_tree_map_alloc (s->iova_tree, &mem_region); + r =vhost_iova_tree_map_alloc (s->iova_tree, &mem_region, hw_vaddr);if (unlikely (r !=IOVA_OK )) {error_report ("Can't allocate a mapping (%d)" , r); + +if (mem_region.translated_addr == hw_vaddr) { +error_report ("Insertion to IOVA->HVA tree failed" ); +/* Remove the mapping from the IOVA-only tree */ + goto fail_map; + } goto fail; }
@@ -1142,16 +1148,23 @@ static void vhost_vdpa_svq_unmap_rings(struct vhost_dev *dev,* * @v: Vhost-vdpa device * @needle: The area to search iova +* @taddr: The translated address (HVA) * @errorp: Error pointer */ static bool vhost_vdpa_svq_map_ring (struct vhost_vdpa *v,DMAMap *needle, -Error **errp) +hwaddr taddr,Error **errp) {int r; - r =vhost_iova_tree_map_alloc (v->shared->iova_tree, needle); + r =vhost_iova_tree_map_alloc (v->shared->iova_tree, needle, taddr);if (unlikely (r !=IOVA_OK )) {error_setg (errp,"Cannot allocate iova (%d)" , r); + +if (needle->translated_addr == taddr) { +error_append_hint (errp,"Insertion to IOVA->HVA tree failed" ); +/* Remove the mapping from the IOVA-only tree */ +vhost_iova_tree_remove (v->shared->iova_tree, *needle); + }return false; }
@@ -1192,11 +1205,11 @@ static bool vhost_vdpa_svq_map_rings(struct vhost_dev *dev,vhost_svq_get_vring_addr (svq, &svq_addr); driver_region = (DMAMap ) { - .translated_addr = svq_addr.desc_user_addr, .size = driver_size -1 , .perm =IOMMU_RO , }; - ok =vhost_vdpa_svq_map_ring (v, &driver_region, errp); + ok =vhost_vdpa_svq_map_ring (v, &driver_region, svq_addr.desc_user_addr, + errp);if (unlikely (!ok)) {error_prepend (errp,"Cannot create vq driver region: " );return false;
@@ -1206,11 +1219,11 @@ static bool vhost_vdpa_svq_map_rings(struct vhost_dev *dev, addr->avail_user_addr = driver_region.iova + avail_offset; device_region = (DMAMap ) { - .translated_addr = svq_addr.used_user_addr, .size = device_size -1 , .perm =IOMMU_RW , }; - ok =vhost_vdpa_svq_map_ring (v, &device_region, errp); + ok =vhost_vdpa_svq_map_ring (v, &device_region, svq_addr.used_user_addr, + errp);if (unlikely (!ok)) {error_prepend (errp,"Cannot create vq device region: " );vhost_vdpa_svq_unmap_ring (v, driver_region.translated_addr);
net/vhost-vdpa.c +8 -2
@@ -510,14 +510,20 @@ static int vhost_vdpa_cvq_map_buf(struct vhost_vdpa *v, void *buf, size_t size, bool write) {DMAMap map = {}; +hwaddr taddr = (hwaddr )(uintptr_t )buf;int r; - map.translated_addr = (hwaddr )(uintptr_t )buf; map.size = size -1 ; map.perm = write ?IOMMU_RW :IOMMU_RO , - r =vhost_iova_tree_map_alloc (v->shared->iova_tree, &map); + r =vhost_iova_tree_map_alloc (v->shared->iova_tree, &map, taddr);if (unlikely (r !=IOVA_OK )) {error_report ("Cannot map injected element" ); + +if (map.translated_addr == taddr) { +error_report ("Insertion to IOVA->HVA tree failed" ); +/* Remove the mapping from the IOVA-only tree */ + goto dma_map_err; + }return r; }
Signature · 1 line
2.43.5
PATCH v2 2/3 vhost-iova-tree, svq: Implement GPA->IOVA & partial IOVA->HVA trees
In reply to Jonah PalmerCreates and supports a GPA->IOVA tree and a partial IOVA->HVA tree by splitting up guest-backed memory maps and host-only memory maps from the full IOVA->HVA tree. That is, any guest-backed memory maps are now stored in the GPA->IOVA tree and host-only memory maps stay in the IOVA->HVA tree.
Also propagates the GPAs (in_addr/out_addr) of a VirtQueueElement to vhost_svq_translate_addr() to translate GPAs to IOVAs via the GPA->IOVA tree (when descriptors are backed by guest memory). For descriptors backed by host-only memory, the existing partial SVQ IOVA->HVA tree is used.
GPAs are unique in the guest's address space, ensuring unambiguous IOVA translations. This avoids the issue where different GPAs map to the same HVA, causing the original HVA->IOVA translation to potentially return an IOVA associated with the wrong intended GPA.
--- hw/virtio/vhost-iova-tree.c | 67 ++++++++++++++++++++++++++++++ hw/virtio/vhost-iova-tree.h | 5 +++ hw/virtio/vhost-shadow-virtqueue.c | 55 ++++++++++++++++-------- hw/virtio/vhost-shadow-virtqueue.h | 5 ++- hw/virtio/vhost-vdpa.c | 19 ++++----- include/qemu/iova-tree.h | 22 ++++++++++ net/vhost-vdpa.c | 2 +- util/iova-tree.c | 46 ++++++++++++++++++++ 8 files changed, 190 insertions(+), 31 deletions(-)
hw/virtio/vhost-iova-tree.c +67 -0
@@ -31,6 +31,9 @@ struct VhostIOVATree {/* Allocated IOVA addresses */ IOVATree *iova_map; + +/* GPA->IOVA address memory maps */ +IOVATree *gpa_iova_map; };/**
@@ -48,6 +51,7 @@ VhostIOVATree *vhost_iova_tree_new(hwaddr iova_first, hwaddr iova_last) tree->iova_taddr_map =iova_tree_new (); tree->iova_map =iova_tree_new (); + tree->gpa_iova_map =gpa_tree_new ();return tree; }
@@ -58,6 +62,7 @@ void vhost_iova_tree_delete(VhostIOVATree *iova_tree) {iova_tree_destroy (iova_tree->iova_taddr_map);iova_tree_destroy (iova_tree->iova_map); +iova_tree_destroy (iova_tree->gpa_iova_map);g_free (iova_tree); }
@@ -122,3 +127,65 @@ void vhost_iova_tree_remove(VhostIOVATree *iova_tree, DMAMap map)iova_tree_remove (iova_tree->iova_taddr_map, map);iova_tree_remove (iova_tree->iova_map, map); } + +/** +* Find the IOVA address stored from a guest memory address (GPA) +* +* @tree: The VhostIOVATree +* @map: The map with the guest memory address +* +* Returns the stored GPA->IOVA mapping, or NULL if not found. +*/ +const DMAMap *vhost_iova_tree_find_gpa (const VhostIOVATree *tree, +const DMAMap *map) +{ +return iova_tree_find_iova (tree->gpa_iova_map, map); +} + +/** +* Allocate a new IOVA range and add the mapping to the GPA->IOVA tree +* +* @tree: The VhostIOVATree +* @map: The IOVA mapping +* @taddr: The translated address (GPA) +* +* Returns: +* - IOVA_OK if the map fits both containers +* - IOVA_ERR_INVALID if the map does not make sense (like size overflow) +* - IOVA_ERR_NOMEM if the IOVA-only tree cannot allocate more space +* +* It returns an assigned IOVA in map->iova if the return value is IOVA_OK. +*/ +int vhost_iova_tree_map_alloc_gpa (VhostIOVATree *tree,DMAMap *map,hwaddr taddr) +{ +int ret; + +/* Some vhost devices don't like addr 0. Skip first page */ +hwaddr iova_first = tree->iova_first ?:qemu_real_host_page_size (); + +if (taddr + map->size < taddr || map->perm ==IOMMU_NONE ) { +return IOVA_ERR_INVALID ; + } + +/* Allocate a node in the IOVA-only tree */ + ret =iova_tree_alloc_map (tree->iova_map, map, iova_first, tree->iova_last); +if (unlikely (ret !=IOVA_OK )) { +return ret; + } + +/* Insert a node in the GPA->IOVA tree */ + map->translated_addr = taddr; +return gpa_tree_insert (tree->gpa_iova_map, map); +} + +/** +* Remove existing mappings from the IOVA-only and GPA->IOVA trees +* +* @tree: The VhostIOVATree +* @map: The map to remove +*/ +void vhost_iova_tree_remove_gpa (VhostIOVATree *iova_tree,DMAMap map) +{ +iova_tree_remove (iova_tree->gpa_iova_map, map); +iova_tree_remove (iova_tree->iova_map, map); +}
hw/virtio/vhost-iova-tree.h +5 -0
@@ -24,5 +24,10 @@ const DMAMap *vhost_iova_tree_find_iova(const VhostIOVATree *iova_tree,int vhost_iova_tree_map_alloc (VhostIOVATree *iova_tree,DMAMap *map,hwaddr taddr);void vhost_iova_tree_remove (VhostIOVATree *iova_tree,DMAMap map); +const DMAMap *vhost_iova_tree_find_gpa (const VhostIOVATree *iova_tree, +const DMAMap *map); +int vhost_iova_tree_map_alloc_gpa (VhostIOVATree *iova_tree,DMAMap *map, +hwaddr taddr); +void vhost_iova_tree_remove_gpa (VhostIOVATree *iova_tree,DMAMap map);#endif
hw/virtio/vhost-shadow-virtqueue.c +38 -17
126 lines not on this page · raw message
hw/virtio/vhost-shadow-virtqueue.h +3 -2
@@ -118,8 +118,9 @@ uint16_t vhost_svq_available_slots(const VhostShadowVirtqueue *svq);void vhost_svq_push_elem (VhostShadowVirtqueue *svq,const VirtQueueElement *elem,uint32_t len);int vhost_svq_add (VhostShadowVirtqueue *svq,const struct iovec *out_sg, -size_t out_num,const struct iovec *in_sg,size_t in_num, -VirtQueueElement *elem); +size_t out_num,const hwaddr *out_addr, +const struct iovec *in_sg,size_t in_num, +const hwaddr *in_addr,VirtQueueElement *elem);size_t vhost_svq_poll (VhostShadowVirtqueue *svq,size_t num);void vhost_svq_set_svq_kick_fd (VhostShadowVirtqueue *svq,int svq_kick_fd);
hw/virtio/vhost-vdpa.c +8 -11
@@ -360,17 +360,17 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, llsize =int128_sub (llend,int128_make64 (iova));if (s->shadow_data) {int r; -hwaddr hw_vaddr = (hwaddr )(uintptr_t )vaddr; +hwaddr gpa = section->offset_within_address_space; mem_region.size =int128_get64 (llsize) -1 , mem_region.perm =IOMMU_ACCESS_FLAG (true, section->readonly), - r =vhost_iova_tree_map_alloc (s->iova_tree, &mem_region, hw_vaddr); + r =vhost_iova_tree_map_alloc_gpa (s->iova_tree, &mem_region, gpa);if (unlikely (r !=IOVA_OK )) {error_report ("Can't allocate a mapping (%d)" , r); -if (mem_region.translated_addr == hw_vaddr) { -error_report ("Insertion to IOVA->HVA tree failed" ); +if (mem_region.translated_addr == gpa) { +error_report ("Insertion to GPA->IOVA tree failed" );/* Remove the mapping from the IOVA-only tree */ goto fail_map; }
@@ -392,7 +392,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, fail_map:if (s->shadow_data) { -vhost_iova_tree_remove (s->iova_tree, mem_region); +vhost_iova_tree_remove_gpa (s->iova_tree, mem_region); } fail:
@@ -446,21 +446,18 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,if (s->shadow_data) {const DMAMap *result; -const void *vaddr =memory_region_get_ram_ptr (section->mr) + - section->offset_within_region + - (iova - section->offset_within_address_space);DMAMap mem_region = { - .translated_addr = (hwaddr )(uintptr_t )vaddr, + .translated_addr = section->offset_within_address_space, .size =int128_get64 (llsize) -1 , }; - result =vhost_iova_tree_find_iova (s->iova_tree, &mem_region); + result =vhost_iova_tree_find_gpa (s->iova_tree, &mem_region);if (!result) {/* The memory listener map wasn't mapped */ return ; } iova = result->iova; -vhost_iova_tree_remove (s->iova_tree, *result); +vhost_iova_tree_remove_gpa (s->iova_tree, *result); }vhost_vdpa_iotlb_batch_begin_once (s);/*
include/qemu/iova-tree.h +22 -0
@@ -40,6 +40,28 @@ typedef struct DMAMap { }QEMU_PACKED DMAMap;typedef gboolean (*iova_tree_iterator )(DMAMap *map); +/** +* gpa_tree_new: +* +* Create a new GPA->IOVA tree. +* +* Returns: the tree point on success, or NULL otherwise. +*/ +IOVATree *gpa_tree_new (void ); + +/** +* gpa_tree_insert: +* +* @tree: The GPA->IOVA tree we're inserting the mapping to +* @map: The GPA->IOVA mapping to insert +* +* Inserts a GPA range to the GPA->IOVA tree. If there are overlapped +* ranges, IOVA_ERR_OVERLAP will be returned. +* +* Return: 0 if successful, < 0 otherwise. +*/ +int gpa_tree_insert (IOVATree *tree,const DMAMap *map); +/** * iova_tree_new: *
net/vhost-vdpa.c +1 -1
@@ -649,7 +649,7 @@ static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState *s,VhostShadowVirtqueue *svq =g_ptr_array_index (s->vhost_vdpa.shadow_vqs,0 );int r; - r =vhost_svq_add (svq, out_sg, out_num, in_sg, in_num,NULL ); + r =vhost_svq_add (svq, out_sg, out_num,NULL , in_sg, in_num,NULL ,NULL );if (unlikely (r !=0 )) {if (unlikely (r == -ENOSPC )) { qemu_log_mask(LOG_GUEST_ERROR, "%s: No space on device queue\n",
util/iova-tree.c +46 -0
49 lines not on this page · raw message
Signature · 1 line
2.43.5
PATCH v2 3/3 vhost-iova-tree: Update documentation
In reply to Jonah PalmerMinor update to some of the documentation / comments in hw/virtio/vhost-iova-tree.c.
--- hw/virtio/vhost-iova-tree.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
hw/virtio/vhost-iova-tree.c +11 -11
@@ -37,9 +37,9 @@ struct VhostIOVATree { };/** -* Create a new IOVA tree +* Create a new VhostIOVATree * -* Returns the new IOVA tree +* Returns the new VhostIOVATree. */ VhostIOVATree *vhost_iova_tree_new (hwaddr iova_first,hwaddr iova_last) {
@@ -56,7 +56,7 @@ VhostIOVATree *vhost_iova_tree_new(hwaddr iova_first, hwaddr iova_last) }/** -* Delete an iova tree +* Delete a VhostIOVATree */ void vhost_iova_tree_delete (VhostIOVATree *iova_tree) {
@@ -69,10 +69,10 @@ void vhost_iova_tree_delete(VhostIOVATree *iova_tree)/** * Find the IOVA address stored from a memory address * -* @tree: The iova tree +* @tree: The VhostIOVATree * @map: The map with the memory address * -* Return the stored mapping, or NULL if not found. +* Returns the stored IOVA->HVA mapping, or NULL if not found. */ const DMAMap *vhost_iova_tree_find_iova (const VhostIOVATree *tree,const DMAMap *map)
@@ -81,10 +81,10 @@ const DMAMap *vhost_iova_tree_find_iova(const VhostIOVATree *tree, }/** -* Allocate a new mapping +* Allocate a new IOVA range and add the mapping to the IOVA->HVA tree * -* @tree: The iova tree -* @map: The iova map +* @tree: The VhostIOVATree +* @map: The IOVA mapping * @taddr: The translated address (HVA) * * Returns:
@@ -92,7 +92,7 @@ const DMAMap *vhost_iova_tree_find_iova(const VhostIOVATree *tree,* - IOVA_ERR_INVALID if the map does not make sense (like size overflow) * - IOVA_ERR_NOMEM if tree cannot allocate more space. * -* It returns assignated iova in map->iova if return value is VHOST_DMA_MAP_OK. +* It returns an assigned IOVA in map->iova if the return value is IOVA_OK. */ int vhost_iova_tree_map_alloc (VhostIOVATree *tree,DMAMap *map,hwaddr taddr) {
@@ -117,9 +117,9 @@ int vhost_iova_tree_map_alloc(VhostIOVATree *tree, DMAMap *map, hwaddr taddr) }/** -* Remove existing mappings from iova tree +* Remove existing mappings from the IOVA-only and IOVA->HVA trees * -* @iova_tree: The vhost iova tree +* @iova_tree: The VhostIOVATree * @map: The map to remove */ void vhost_iova_tree_remove (VhostIOVATree *iova_tree,DMAMap map)
Signature · 1 line
2.43.5