[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V1 26/26] iommufd: preserve DMA mappings
From: |
Steve Sistare |
Subject: |
[PATCH V1 26/26] iommufd: preserve DMA mappings |
Date: |
Wed, 29 Jan 2025 06:43:22 -0800 |
During cpr-transfer load in new QEMU, the vfio_memory_listener causes
spurious calls to map and unmap DMA regions, as devices are created and
the address space is built. This memory was already already mapped by the
device in old QEMU, so suppress the map and unmap callbacks during CPR --
eg, if the reused flag is set. Clear the reused flag in the post_load
handler.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
backends/iommufd.c | 8 ++++++++
hw/vfio/cpr-iommufd.c | 1 +
2 files changed, 9 insertions(+)
diff --git a/backends/iommufd.c b/backends/iommufd.c
index e9452e4..cc61432 100644
--- a/backends/iommufd.c
+++ b/backends/iommufd.c
@@ -226,6 +226,10 @@ int iommufd_backend_map_file_dma(IOMMUFDBackend *be,
uint32_t ioas_id,
.length = size,
};
+ if (be->reused) {
+ return 0;
+ }
+
if (!readonly) {
map.flags |= IOMMU_IOAS_MAP_WRITEABLE;
}
@@ -257,6 +261,10 @@ int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t
ioas_id,
.length = size,
};
+ if (be->reused) {
+ return 0;
+ }
+
ret = ioctl(fd, IOMMU_IOAS_UNMAP, &unmap);
/*
* IOMMUFD takes mapping as some kind of object, unmapping
diff --git a/hw/vfio/cpr-iommufd.c b/hw/vfio/cpr-iommufd.c
index 711e5cf..5b93b24 100644
--- a/hw/vfio/cpr-iommufd.c
+++ b/hw/vfio/cpr-iommufd.c
@@ -63,6 +63,7 @@ static const VMStateDescription vfio_container_vmstate = {
.name = "vfio-iommufd-container",
.version_id = 0,
.minimum_version_id = 0,
+ .priority = MIG_PRI_LOW, /* Must happen after devices and groups */
.pre_save = vfio_container_pre_save,
.post_load = vfio_container_post_load,
.needed = cpr_needed_for_reuse,
--
1.8.3.1
- [PATCH V1 12/26] vfio-pci: preserve MSI, (continued)
- [PATCH V1 12/26] vfio-pci: preserve MSI, Steve Sistare, 2025/01/29
- [PATCH V1 16/26] vfio: return mr from vfio_get_xlat_addr, Steve Sistare, 2025/01/29
- [PATCH V1 17/26] vfio: pass ramblock to vfio_container_dma_map, Steve Sistare, 2025/01/29
- [PATCH V1 15/26] migration: cpr_get_fd_param helper, Steve Sistare, 2025/01/29
- [PATCH V1 18/26] vfio/iommufd: define iommufd_cdev_make_hwpt, Steve Sistare, 2025/01/29
- [PATCH V1 10/26] vfio-pci: refactor for cpr, Steve Sistare, 2025/01/29
- [PATCH V1 23/26] vfio/iommufd: register container for cpr, Steve Sistare, 2025/01/29
- [PATCH V1 22/26] vfio/iommufd: invariant device name, Steve Sistare, 2025/01/29
- [PATCH V1 24/26] vfio/iommufd: preserve descriptors, Steve Sistare, 2025/01/29
- [PATCH V1 25/26] vfio/iommufd: reconstruct device, Steve Sistare, 2025/01/29
- [PATCH V1 26/26] iommufd: preserve DMA mappings,
Steve Sistare <=