aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCindy Lu <lulu@redhat.com>2023-05-10 13:46:30 +0800
committerMichael S. Tsirkin <mst@redhat.com>2023-05-19 10:30:46 -0400
commit2fbef6aad892a3e784041fc5a6d5f5bda0565464 (patch)
treef193905fd99b857079590a09bdfd059abb9b8d93
parent3d1e4d34a81a212e234f674e57e73c824d4b131a (diff)
downloadqemu-2fbef6aad892a3e784041fc5a6d5f5bda0565464.zip
qemu-2fbef6aad892a3e784041fc5a6d5f5bda0565464.tar.gz
qemu-2fbef6aad892a3e784041fc5a6d5f5bda0565464.tar.bz2
vhost-vdpa: Add check for full 64-bit in region delete
The unmap ioctl doesn't accept a full 64-bit span. So need to add check for the section's size in vhost_vdpa_listener_region_del(). Signed-off-by: Cindy Lu <lulu@redhat.com> Message-Id: <20230510054631.2951812-4-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--hw/virtio/vhost-vdpa.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 92c2413..0c8c37e 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -316,10 +316,28 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
vhost_iova_tree_remove(v->iova_tree, *result);
}
vhost_vdpa_iotlb_batch_begin_once(v);
+ /*
+ * The unmap ioctl doesn't accept a full 64-bit. need to check it
+ */
+ if (int128_eq(llsize, int128_2_64())) {
+ llsize = int128_rshift(llsize, 1);
+ ret = vhost_vdpa_dma_unmap(v, VHOST_VDPA_GUEST_PA_ASID, iova,
+ int128_get64(llsize));
+
+ if (ret) {
+ error_report("vhost_vdpa_dma_unmap(%p, 0x%" HWADDR_PRIx ", "
+ "0x%" HWADDR_PRIx ") = %d (%m)",
+ v, iova, int128_get64(llsize), ret);
+ }
+ iova += int128_get64(llsize);
+ }
ret = vhost_vdpa_dma_unmap(v, VHOST_VDPA_GUEST_PA_ASID, iova,
int128_get64(llsize));
+
if (ret) {
- error_report("vhost_vdpa dma unmap error!");
+ error_report("vhost_vdpa_dma_unmap(%p, 0x%" HWADDR_PRIx ", "
+ "0x%" HWADDR_PRIx ") = %d (%m)",
+ v, iova, int128_get64(llsize), ret);
}
memory_region_unref(section->mr);