[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 2/2] vdpa: identify aliased maps in iova_tree
From: |
Eugenio Pérez |
Subject: |
[RFC 2/2] vdpa: identify aliased maps in iova_tree |
Date: |
Wed, 10 Apr 2024 12:03:45 +0200 |
The guest may have overlapped memory regions, where different GPA leads
to the same HVA. This causes a problem when overlapped regions
(different GPA but same translated HVA) exists in the tree, as looking
them by HVA will return them twice.
To solve this, track GPA in the DMA entry that acs as unique identifiers
to the maps. When the map needs to be removed, iova tree is able to
find the right one.
Users that does not go to this extra layer of indirection can use the
iova tree as usual, with id = 0.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-vdpa.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index e827b9175f..90adff597c 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -361,6 +361,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener
*listener,
mem_region.translated_addr = (hwaddr)(uintptr_t)vaddr,
mem_region.size = int128_get64(llsize) - 1,
mem_region.perm = IOMMU_ACCESS_FLAG(true, section->readonly),
+ mem_region.id = iova;
r = vhost_iova_tree_map_alloc(s->iova_tree, &mem_region);
if (unlikely(r != IOVA_OK)) {
@@ -443,6 +444,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener
*listener,
DMAMap mem_region = {
.translated_addr = (hwaddr)(uintptr_t)vaddr,
.size = int128_get64(llsize) - 1,
+ .id = iova,
};
result = vhost_iova_tree_find_iova(s->iova_tree, &mem_region);
--
2.44.0
- Re: [RFC 1/2] iova_tree: add an id member to DMAMap, (continued)
- Re: [RFC 1/2] iova_tree: add an id member to DMAMap, Eugenio Perez Martin, 2024/04/19
- Re: [RFC 1/2] iova_tree: add an id member to DMAMap, Si-Wei Liu, 2024/04/19
- Re: [RFC 1/2] iova_tree: add an id member to DMAMap, Eugenio Perez Martin, 2024/04/22
- Re: [RFC 1/2] iova_tree: add an id member to DMAMap, Si-Wei Liu, 2024/04/23
- Re: [RFC 1/2] iova_tree: add an id member to DMAMap, Eugenio Perez Martin, 2024/04/24
- Re: [RFC 1/2] iova_tree: add an id member to DMAMap, Si-Wei Liu, 2024/04/25
- Re: [RFC 1/2] iova_tree: add an id member to DMAMap, Eugenio Perez Martin, 2024/04/29
- Re: [RFC 1/2] iova_tree: add an id member to DMAMap, Jonah Palmer, 2024/04/29
- Re: [RFC 1/2] iova_tree: add an id member to DMAMap, Si-Wei Liu, 2024/04/30
- Re: [RFC 1/2] iova_tree: add an id member to DMAMap, Eugenio Perez Martin, 2024/04/30
- [RFC 2/2] vdpa: identify aliased maps in iova_tree,
Eugenio Pérez <=
- Re: [RFC 0/2] Identify aliased maps in vdpa SVQ iova_tree, Jason Wang, 2024/04/12