mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
vfio: Don't issue full 2^64 unmap
IOMMUs may declare memory regions spanning from 0 to UINT64_MAX. When attempting to deal with such region, vfio_listener_region_del() passes a size of 2^64 to int128_get64() which throws an assertion failure. Even ignoring this, the VFIO_IOMMU_DMA_MAP ioctl cannot handle this size since the size field is 64-bit. Split the request in two. Acked-by: Alex Williamson <alex.williamson@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Message-Id: <20201030180510.747225-11-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
5c3cfe33f4
commit
1b296c3def
1 changed files with 11 additions and 0 deletions
|
@ -950,6 +950,17 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (try_unmap) {
|
if (try_unmap) {
|
||||||
|
if (int128_eq(llsize, int128_2_64())) {
|
||||||
|
/* The unmap ioctl doesn't accept a full 64-bit span. */
|
||||||
|
llsize = int128_rshift(llsize, 1);
|
||||||
|
ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
|
||||||
|
if (ret) {
|
||||||
|
error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
||||||
|
"0x%"HWADDR_PRIx") = %d (%m)",
|
||||||
|
container, iova, int128_get64(llsize), ret);
|
||||||
|
}
|
||||||
|
iova += int128_get64(llsize);
|
||||||
|
}
|
||||||
ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
|
ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue