vhost-vdpa: Avoid unbalanced IOMMU region unref
PATCH 1/1 vhost-vdpa: Avoid unbalanced IOMMU region unref
vhost_vdpa_listener_region_add() handles IOMMU regions separately and returns without calling memory_region_ref(). Its delete counterpart removes the IOMMU notifier, continues through the shared DMA unmap path, and then unconditionally drops an owner reference that was never acquired.
Limit memory_region_unref() to non-IOMMU regions. This keeps the existing full-range DMA unmap for IOMMU teardown while balancing the references acquired for RAM sections.
--- hw/virtio/vhost-vdpa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/virtio/vhost-vdpa.c +3 -1
@@ -487,7 +487,9 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, s, iova, int128_get64(llsize), ret); } -memory_region_unref (section->mr); +if (!memory_region_is_iommu (section->mr)) { +memory_region_unref (section->mr); + } }/* * IOTLB API is used by vhost-vdpa which requires incremental updating
Signature · 1 line
2.43.0
Hi,
Gentle ping on this patch.
Any feedback would be appreciated.
Thanks,
Yuho
Quoted 34 lines · Yuho Choi
vhost_vdpa_listener_region_add()handles IOMMU regions separately and returns without callingmemory_region_ref(). Its delete counterpart removes the IOMMU notifier, continues through the shared DMA unmap path, and then unconditionally drops an owner reference that was never acquired.Limit
memory_region_unref()to non-IOMMU regions. This keeps the existing full-range DMA unmap for IOMMU teardown while balancing the references acquired for RAM sections.Fixes bc7b0cac7bf4 ("vhost-vdpa: Add support for vIOMMU.")Signed-off-by Yuho Choi <[email protected]>--- hw/virtio/vhost-vdpa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)hw/virtio/vhost-vdpa.c +3
-2@@ -487,7 +487,9 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, s, iova, int128_get64(llsize), ret); } -memory_region_unref (section->mr); +if (!memory_region_is_iommu (section->mr)) { +memory_region_unref (section->mr); + } }/* * IOTLB API is used by vhost-vdpa which requires incremental updating -- 2.43.0