[PATCH V4 17/43] vfio-pci: skip reset during cpr

2025-05-29 Thread Steve Sistare
Do not reset a vfio-pci device during CPR, and do not complain if the kernel's PCI config space changes for non-emulated bits between the vmstate save and load, which can happen due to ongoing interrupt activity. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 2 ++ hw/vfio/

[PATCH V4 27/43] migration: cpr_get_fd_param helper

2025-05-29 Thread Steve Sistare
changes when sent to new QEMU via SCM_RIGHTS. Hence the user cannot send getfd to new QEMU, but when the user sends a hotplug command that references the fd, cpr_get_fd_param finds its value in CPR state. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas --- include/migration/cpr.h | 2

[PATCH V4 19/43] vfio/pci: vfio_notifier_init

2025-05-29 Thread Steve Sistare
Move event_notifier_init calls to a helper vfio_notifier_init. This version is trivial, but it will be expanded to support CPR in subsequent patches. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/pci.c | 40

[PATCH V4 13/43] vfio/container: mdev cpr blocker

2025-05-29 Thread Steve Sistare
During CPR, after VFIO_DMA_UNMAP_FLAG_VADDR, the vaddr is temporarily invalid, so mediated devices cannot be supported. Add a blocker for them. This restriction will not apply to iommufd containers when CPR is added for them in a future patch. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le

[PATCH V4 23/43] vfio/pci: export MSI functions

2025-05-29 Thread Steve Sistare
Export various MSI functions, renamed with a vfio_pci prefix, for use by CPR in subsequent patches. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.h | 8 hw/vfio/pci.c | 29 + 2 files changed, 25 insertions(+), 12 deletions(-) diff

[PATCH V4 26/43] migration: close kvm after cpr

2025-05-29 Thread Steve Sistare
Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-device.h | 2 ++ include/migration/cpr.h | 2 ++ include/system/kvm.h | 1 + accel/kvm/kvm-all.c | 28 accel/stubs/kvm-stub.c| 5 + hw/vfio/helpers.c | 10

[PATCH V4 21/43] vfio/pci: vfio_notifier_init cpr parameters

2025-05-29 Thread Steve Sistare
Pass vdev and nr to vfio_notifier_init, for use by CPR in a subsequent patch. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/pci.c | 31 +++ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/hw/vfio/pci.c

[PATCH V4 36/43] migration: vfio cpr state hook

2025-05-29 Thread Steve Sistare
device object will be defined by the vfio subsystem in a subsequent patch. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 1 + include/migration/cpr.h| 12 hw/vfio/cpr-iommufd.c | 2 ++ migration/cpr.c| 14 +- 4 files changed, 20

[PATCH V4 03/43] vfio/container: pass MemoryRegion to DMA operations

2025-05-29 Thread Steve Sistare
-off-by: John Levon Reviewed-by: Cédric Le Goater Reviewed-by: Steve Sistare --- include/hw/vfio/vfio-container-base.h | 17 +++-- hw/vfio/container-base.c | 4 ++-- hw/vfio/container.c | 3 ++- hw/vfio/iommufd.c | 3 ++- hw/vfio

[PATCH V4 29/43] backends/iommufd: change process ioctl

2025-05-29 Thread Steve Sistare
Define the change process ioctl Signed-off-by: Steve Sistare --- include/system/iommufd.h | 2 ++ backends/iommufd.c | 24 backends/trace-events| 1 + 3 files changed, 27 insertions(+) diff --git a/include/system/iommufd.h b/include/system/iommufd.h index

[PATCH V4 12/43] vfio/container: restore DMA vaddr

2025-05-29 Thread Steve Sistare
section, and the calls will match the mappings remembered by the kernel. The listener calls a special dma_map handler that passes the new VA of each section to the kernel using VFIO_DMA_MAP_FLAG_VADDR. Restore the normal handler at the end. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio

[PATCH V4 42/43] iommufd: preserve DMA mappings

2025-05-29 Thread Steve Sistare
. Signed-off-by: Steve Sistare --- backends/iommufd.c | 8 1 file changed, 8 insertions(+) diff --git a/backends/iommufd.c b/backends/iommufd.c index 98d83aa..62d1f71 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -245,6 +245,10 @@ int iommufd_backend_map_file_dma

[PATCH V4 04/43] vfio/pci: vfio_pci_put_device on failure

2025-05-29 Thread Steve Sistare
ed-off-by: Steve Sistare --- hw/vfio/pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index a1bfdfe..7d3b9ff 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3296,6 +3296,7 @@ out_teardown: vfio_bars_exit(vdev); error: error_prepen

[PATCH V4 37/43] vfio/iommufd: cpr state

2025-05-29 Thread Steve Sistare
-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 3 ++ hw/vfio/cpr-iommufd.c | 96 +- hw/vfio/iommufd.c | 2 + 3 files changed, 100 insertions(+), 1 deletion(-) diff --git a/include/hw/vfio/vfio-cpr.h b/include/hw/vfio/vfio-cpr.h

[PATCH V4 30/43] physmem: qemu_ram_get_fd_offset

2025-05-29 Thread Steve Sistare
Define qemu_ram_get_fd_offset, so CPR can map a memory region using IOMMU_IOAS_MAP_FILE in a subsequent patch. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: Zhenzhong Duan --- include/exec/cpu-common.h | 1 + system/physmem.c | 5 + 2 files changed, 6 insertions

[PATCH V4 06/43] migration: lower handler priority

2025-05-29 Thread Steve Sistare
handlers for the devices that they contain. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu --- include/migration/vmstate.h | 6 +- migration/savevm.c | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/migration/vmstate.h

[PATCH V4 24/43] vfio-pci: preserve MSI

2025-05-29 Thread Steve Sistare
tance. Signed-off-by: Steve Sistare --- hw/vfio/pci.h | 2 + include/hw/vfio/vfio-cpr.h | 8 hw/vfio/cpr.c | 97 ++ hw/vfio/pci.c | 54 -- 4 files changed, 158 insertions(+), 3 dele

[PATCH V4 40/43] vfio/iommufd: reconstruct hwpt

2025-05-29 Thread Steve Sistare
Skip allocation of, and attachment to, hwpt_id. Recover it from CPR state. Signed-off-by: Steve Sistare --- hw/vfio/iommufd.c | 30 ++ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 5119c17..f0abd41 100644

[PATCH V4 14/43] vfio/container: recover from unmap-all-vaddr failure

2025-05-29 Thread Steve Sistare
a new "remap" flag that tells it to restore a mapping without re-allocating new userland data structures. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-container-base.h | 3 ++ include/hw/vfio/vfio-cpr.h| 10 hw/vfio/cp

[PATCH V4 32/43] vfio/iommufd: invariant device name

2025-05-29 Thread Steve Sistare
QEMU must know the fd number to construct a name to find the fd number. To fix, create an invariant name based on the id command-line parameter, if id is defined. The user will need to provide such an id to use CPR. Signed-off-by: Steve Sistare --- hw/vfio/device.c | 15 ++- 1 file

[PATCH V4 41/43] vfio/iommufd: change process

2025-05-29 Thread Steve Sistare
Finish CPR by change the owning process of the iommufd device in post load. Signed-off-by: Steve Sistare --- hw/vfio/cpr-iommufd.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/hw/vfio/cpr-iommufd.c b/hw/vfio/cpr-iommufd.c index 152a661..a9e3f68 100644

[PATCH V4 01/43] MAINTAINERS: Add reviewer for CPR

2025-05-29 Thread Steve Sistare
CPR is integrated with live migration, and has the same maintainers. But, add a CPR section to add a reviewer. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- MAINTAINERS | 9 + 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index e27d145

[PATCH V4 35/43] vfio/iommufd: register container for cpr

2025-05-29 Thread Steve Sistare
subsequent patches. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 12 +++ include/system/iommufd.h | 1 + backends/iommufd.c | 10 ++ hw/vfio/cpr-iommufd.c | 84 ++ hw/vfio/iommufd.c | 6 ++-- hw/vfio

[PATCH V4 15/43] pci: export msix_is_pending

2025-05-29 Thread Steve Sistare
Export msix_is_pending for use by cpr. No functional change. Signed-off-by: Steve Sistare Acked-by: Michael S. Tsirkin --- include/hw/pci/msix.h | 1 + hw/pci/msix.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h

[PATCH V4 11/43] vfio/container: discard old DMA vaddr

2025-05-29 Thread Steve Sistare
In the container pre_save handler, discard the virtual addresses in DMA mappings with VFIO_DMA_UNMAP_FLAG_VADDR, because guest RAM will be remapped at a different VA after in new QEMU. DMA to already-mapped pages continues. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw

[PATCH V4 28/43] backends/iommufd: iommufd_backend_map_file_dma

2025-05-29 Thread Steve Sistare
Define iommufd_backend_map_file_dma to implement IOMMU_IOAS_MAP_FILE. This will be called as a substitute for iommufd_backend_map_dma, so the error conditions for BARs are copied as-is from that function. Signed-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan --- include/system/iommufd.h

[PATCH V4 34/43] vfio/iommufd: device name blocker

2025-05-29 Thread Steve Sistare
If an invariant device name cannot be created, block CPR. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 1 + hw/vfio/device.c | 11 +++ 2 files changed, 12 insertions(+) diff --git a/include/hw/vfio/vfio-cpr.h b/include/hw/vfio/vfio-cpr.h index 25e74ee

[PATCH V4 20/43] vfio/pci: pass vector to virq functions

2025-05-29 Thread Steve Sistare
Pass the vector number to vfio_connect_kvm_msi_virq and vfio_remove_kvm_msi_virq, so it can be passed to their subroutines in a subsequent patch. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/pci.c | 13 +++-- 1 file changed, 7 insertions

[PATCH V4 43/43] vfio/container: delete old cpr register

2025-05-29 Thread Steve Sistare
vfio_cpr_[un]register_container is no longer used since they were subsumed by container type-specific registration. Delete them. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 4 hw/vfio/cpr.c | 13 - 2 files changed, 17 deletions(-) diff --git a

[PATCH V4 39/43] vfio/iommufd: reconstruct device

2025-05-29 Thread Steve Sistare
a matching container, if any, before creating a new one. This reconstruction is not complete. hwpt_id is handled in a subsequent patch. Signed-off-by: Steve Sistare --- hw/vfio/iommufd.c | 30 -- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/hw/vfio

[PATCH V4 22/43] vfio/pci: vfio_notifier_cleanup

2025-05-29 Thread Steve Sistare
Move event_notifier_cleanup calls to a helper vfio_notifier_cleanup. This version is trivial, and does not yet use the vdev and nr parameters. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/pci.c | 28 +--- 1 file changed

[PATCH V4 31/43] vfio/iommufd: use IOMMU_IOAS_MAP_FILE

2025-05-29 Thread Steve Sistare
Use IOMMU_IOAS_MAP_FILE when the mapped region is backed by a file. Such a mapping can be preserved without modification during CPR, because it depends on the file's address space, which does not change, rather than on the process's address space, which does change. Signed-off-by: Ste

[PATCH V4 16/43] pci: skip reset during cpr

2025-05-29 Thread Steve Sistare
Do not reset a vfio-pci device during CPR. Signed-off-by: Steve Sistare --- include/hw/pci/pci_device.h | 3 +++ hw/pci/pci.c| 5 + hw/vfio/pci.c | 7 +++ 3 files changed, 15 insertions(+) diff --git a/include/hw/pci/pci_device.h b/include/hw/pci

[PATCH V4 25/43] vfio-pci: preserve INTx

2025-05-29 Thread Steve Sistare
initialization, but still perform kvm initialization. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c | 27 ++- hw/vfio/pci.c | 32 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c index e467373

[PATCH V4 05/43] migration: cpr helpers

2025-05-29 Thread Steve Sistare
Add the cpr_incoming_needed, cpr_open_fd, and cpr_resave_fd helpers, for use when adding cpr support for vfio and iommufd. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- include/migration/cpr.h | 5 + migration/cpr.c | 36 2

[PATCH V4 33/43] vfio/iommufd: add vfio_device_free_name

2025-05-29 Thread Steve Sistare
Define vfio_device_free_name to free the name created by vfio_device_get_name. A subsequent patch will do more there. No functional change. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-device.h | 1 + hw/vfio/ap.c | 2 +- hw/vfio/ccw.c | 2 +- hw/vfio

[PATCH V4 02/43] vfio: return mr from vfio_get_xlat_addr

2025-05-29 Thread Steve Sistare
parameters that can be trivially derived from mr and xlat. Lastly, rename the functions to to memory_translate_iotlb() and vfio_translate_iotlb(). Signed-off-by: Steve Sistare Acked-by: David Hildenbrand Reviewed-by: John Levon Reviewed-by: Cédric Le Goater Acked-by: Michael S. Tsirkin

[PATCH V4 38/43] vfio/iommufd: preserve descriptors

2025-05-29 Thread Steve Sistare
Save the iommu and vfio device fd in CPR state when it is created. After CPR, the fd number is found in CPR state and reused. Signed-off-by: Steve Sistare --- backends/iommufd.c| 25 - hw/vfio/cpr-iommufd.c | 10 ++ hw/vfio/device.c | 9 + 3

[PATCH V4 10/43] vfio/container: preserve descriptors

2025-05-29 Thread Steve Sistare
, such as vfio ioctl's, are skipped. The result is that vfio_realize constructs qemu data structures that reflect the current state of the device. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 6 + hw/vfio/container.c

[PATCH V4 18/43] vfio/pci: vfio_pci_vector_init

2025-05-29 Thread Steve Sistare
Extract a subroutine vfio_pci_vector_init. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 24 +--- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 840590c..2d6dc54 100644 --- a/hw/vfio/pci.c +++ b/hw

[PATCH V4 09/43] vfio/container: register container for cpr

2025-05-29 Thread Steve Sistare
in subsequent patches. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-container.h | 2 ++ include/hw/vfio/vfio-cpr.h | 15 + hw/vfio/container.c | 6 ++-- hw/vfio/cpr-legacy.c | 69 hw/vfio/cpr.c

[PATCH V4 00/43] Live update: vfio and iommufd

2025-05-29 Thread Steve Sistare
cpr_open_fd * deleted "export iommufd_cdev_get_info_iova_range" * deleted "reconstruct device" * deleted "reconstruct hw_caps" * deleted "define hwpt constructors" * seperated cpr registration for iommufd be and vfio container * correctly a

[PATCH V4 07/43] vfio: vfio_find_ram_discard_listener

2025-05-29 Thread Steve Sistare
Define vfio_find_ram_discard_listener as a subroutine so additional calls to it may be added in a subsequent patch. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-container-base.h | 3 +++ hw/vfio/listener.c| 35

[PATCH V4 08/43] vfio: move vfio-cpr.h

2025-05-29 Thread Steve Sistare
Move vfio-cpr.h to include/hw/vfio, because it will need to be included by other files there. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- MAINTAINERS| 1 + hw/vfio/vfio-cpr.h | 15 --- include/hw/vfio/vfio-cpr.h | 18

[PATCH] vfio/pci: vfio_pci_put_device on failure

2025-05-27 Thread Steve Sistare
ed-off-by: Steve Sistare --- hw/vfio/pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index a1bfdfe..7d3b9ff 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3296,6 +3296,7 @@ out_teardown: vfio_bars_exit(vdev); error: error_prepen

[PATCH V5] vfio: return mr from vfio_get_xlat_addr

2025-05-19 Thread Steve Sistare
parameters that can be trivially derived from mr and xlat. Lastly, rename the functions to to memory_translate_iotlb() and vfio_translate_iotlb(). Signed-off-by: Steve Sistare Acked-by: David Hildenbrand --- hw/vfio/listener.c | 33 ++--- hw/virtio/vhost-vdpa.c

[PATCH V4] vfio: return mr from vfio_get_xlat_addr

2025-05-16 Thread Steve Sistare
parameters that can be trivially derived from mr and xlat. Lastly, rename the functions to to memory_translate_iotlb() and vfio_translate_iotlb(). Signed-off-by: Steve Sistare --- hw/vfio/listener.c | 33 ++--- hw/virtio/vhost-vdpa.c | 9 +++-- include/system

[PATCH V3 22/42] vfio-pci: preserve MSI

2025-05-12 Thread Steve Sistare
tance. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c | 91 ++ hw/vfio/pci.c | 40 ++-- include/hw/vfio/vfio-cpr.h | 8 3 files changed, 136 insertions(+), 3 deletions(-) diff --git a/hw/vfio/cpr.c b/hw

[PATCH V3 08/42] vfio/container: export vfio_legacy_dma_map

2025-05-12 Thread Steve Sistare
Export vfio_legacy_dma_map so it may be referenced outside the file in a subsequent patch. Signed-off-by: Steve Sistare --- hw/vfio/container.c | 4 ++-- include/hw/vfio/vfio-container-base.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/vfio

[PATCH V3 24/42] migration: close kvm after cpr

2025-05-12 Thread Steve Sistare
cpr-transfer breaks vfio network connectivity to and from the guest, and the host system log shows: irq bypass consumer (token a03c32e5) registration fails: -16 which is EBUSY. This occurs because KVM descriptors are still open in the old QEMU process. Close them. Signed-off-by: Steve

[PATCH V3 06/42] vfio/container: register container for cpr

2025-05-12 Thread Steve Sistare
in subsequent patches. Signed-off-by: Steve Sistare --- hw/vfio/container.c | 6 ++-- hw/vfio/cpr-legacy.c | 70 hw/vfio/cpr.c| 5 ++- hw/vfio/meson.build | 1 + include/hw/vfio/vfio-container.h

[PATCH V3 35/42] vfio/iommufd: register container for cpr

2025-05-12 Thread Steve Sistare
subsequent patches. Signed-off-by: Steve Sistare --- hw/vfio/cpr-iommufd.c | 97 ++ hw/vfio/iommufd.c | 6 ++- hw/vfio/meson.build| 1 + hw/vfio/vfio-iommufd.h | 1 + include/hw/vfio/vfio-cpr.h | 8 5 files changed, 111

[PATCH V3 21/42] vfio/pci: export MSI functions

2025-05-12 Thread Steve Sistare
Export various MSI functions, for use by CPR in subsequent patches. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 21 ++--- hw/vfio/pci.h | 12 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c

[PATCH V3 38/42] vfio/iommufd: reconstruct hw_caps

2025-05-12 Thread Steve Sistare
all to post_load time, after devid has been recovered from vmstate. Signed-off-by: Steve Sistare --- hw/vfio/cpr-iommufd.c | 15 +++ hw/vfio/iommufd.c | 6 ++ hw/vfio/vfio-iommufd.h | 3 +++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/hw/vfio/cpr-iommu

[PATCH V3 40/42] vfio/iommufd: change process

2025-05-12 Thread Steve Sistare
Finish CPR by change the owning process of the iommufd device in post load. Signed-off-by: Steve Sistare --- hw/vfio/cpr-iommufd.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/hw/vfio/cpr-iommufd.c b/hw/vfio/cpr-iommufd.c index 6d3f4e0..67be775 100644

[PATCH V3 27/42] vfio: pass ramblock to vfio_container_dma_map

2025-05-12 Thread Steve Sistare
Pass ramblock to vfio_container_dma_map for use in a subsequent patch. The ramblock's attributes will be needed to map the block using IOMMU_IOAS_MAP_FILE. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/container-base.c | 3 ++- hw/vfio/liste

[PATCH V3 42/42] vfio/container: delete old cpr register

2025-05-12 Thread Steve Sistare
vfio_cpr_[un]register_container is no longer used since they were subsumed by container type-specific registration. Delete them. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c | 13 - include/hw/vfio/vfio-cpr.h | 4 2 files changed, 17 deletions(-) diff --git a

[PATCH V3 39/42] vfio/iommufd: reconstruct hwpt

2025-05-12 Thread Steve Sistare
stored by the post_load call to vfio_device_hiod_create_and_realize. Signed-off-by: Steve Sistare --- hw/vfio/cpr-iommufd.c | 7 +++ hw/vfio/iommufd.c | 24 ++-- hw/vfio/trace-events | 1 + hw/vfio/vfio-iommufd.h | 3 +++ include/hw/vfio/vfio

[PATCH V3 04/42] vfio: vfio_find_ram_discard_listener

2025-05-12 Thread Steve Sistare
Define vfio_find_ram_discard_listener as a subroutine so additional calls to it may be added in a subsequent patch. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/listener.c| 35 ++- include/hw/vfio/vfio-container

[PATCH V3 28/42] backends/iommufd: iommufd_backend_map_file_dma

2025-05-12 Thread Steve Sistare
Define iommufd_backend_map_file_dma to implement IOMMU_IOAS_MAP_FILE. This will be called as a substitute for iommufd_backend_map_dma, so the error conditions for BARs are copied as-is from that function. Signed-off-by: Steve Sistare --- backends/iommufd.c | 36

[PATCH V3 18/42] vfio/pci: pass vector to virq functions

2025-05-12 Thread Steve Sistare
Pass the vector number to vfio_connect_kvm_msi_virq and vfio_remove_kvm_msi_virq, so it can be passed to their subroutines in a subsequent patch. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git

[PATCH V3 16/42] vfio/pci: vfio_vector_init

2025-05-12 Thread Steve Sistare
Extract a subroutine vfio_vector_init. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 24 +--- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 4aa83b1..b46c42e 100644 --- a/hw/vfio/pci.c +++ b/hw

[PATCH V3 36/42] vfio/iommufd: preserve descriptors

2025-05-12 Thread Steve Sistare
Save the iommu and vfio device fd in CPR state when it is created. After CPR, the fd number is found in CPR state and reused. Remember the reused status for subsequent patches. The reused status is cleared when vmstate load finishes. Signed-off-by: Steve Sistare --- backends/iommufd.c

[PATCH V3 10/42] vfio/container: restore DMA vaddr

2025-05-12 Thread Steve Sistare
section, and the calls will match the mappings remembered by the kernel. The listener calls a special dma_map handler that passes the new VA of each section to the kernel using VFIO_DMA_MAP_FLAG_VADDR. Restore the normal handler at the end. Signed-off-by: Steve Sistare --- hw/vfio/container.c

[PATCH V3 33/42] vfio/iommufd: define hwpt constructors

2025-05-12 Thread Steve Sistare
an extra call to iommufd_backend_get_device_info No functional change. Signed-off-by: Steve Sistare --- hw/vfio/iommufd.c | 116 ++ 1 file changed, 65 insertions(+), 51 deletions(-) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index f645

[PATCH V3 32/42] vfio/iommufd: export iommufd_cdev_get_info_iova_range

2025-05-12 Thread Steve Sistare
Export iommufd_cdev_get_info_iova_range, for use by CPR in a subsequent patch to reconstruct the userland device state. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/iommufd.c | 4 ++-- hw/vfio/vfio-iommufd.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff

[PATCH V3 30/42] physmem: qemu_ram_get_fd_offset

2025-05-12 Thread Steve Sistare
Define qemu_ram_get_fd_offset, so CPR can map a memory region using IOMMU_IOAS_MAP_FILE in a subsequent patch. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- include/exec/cpu-common.h | 1 + system/physmem.c | 5 + 2 files changed, 6 insertions(+) diff --git a/include

[PATCH V3 07/42] vfio/container: preserve descriptors

2025-05-12 Thread Steve Sistare
reuse, device and iommu state is already configured, so operations in vfio_realize that would modify the configuration, such as vfio ioctl's, are skipped. The result is that vfio_realize constructs qemu data structures that reflect the current state of the device. Signed-off-by: Steve Sistare --

[PATCH V3 29/42] backends/iommufd: change process ioctl

2025-05-12 Thread Steve Sistare
Define the change process ioctl Signed-off-by: Steve Sistare --- backends/iommufd.c | 20 backends/trace-events| 1 + include/system/iommufd.h | 2 ++ 3 files changed, 23 insertions(+) diff --git a/backends/iommufd.c b/backends/iommufd.c index 5c1958f..6fed1c1

[PATCH V3 41/42] iommufd: preserve DMA mappings

2025-05-12 Thread Steve Sistare
the reused flag is set. The reused flag is cleared in the post_load handler. Signed-off-by: Steve Sistare --- 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 492747c..c765f2d 100644

[PATCH V3 25/42] migration: cpr_get_fd_param helper

2025-05-12 Thread Steve Sistare
changes when sent to new QEMU via SCM_RIGHTS. Hence the user cannot send getfd to new QEMU, but when the user sends a hotplug command that references the fd, cpr_get_fd_param finds its value in CPR state. Signed-off-by: Steve Sistare --- include/migration/cpr.h | 2 ++ migration/cpr.c | 40

[PATCH V3 12/42] vfio/container: recover from unmap-all-vaddr failure

2025-05-12 Thread Steve Sistare
a new "remap" flag that tells it to restore a mapping without re-allocating new userland data structures. Signed-off-by: Steve Sistare --- hw/vfio/cpr-legacy.c | 91 +++ hw/vfio/listener.c| 19 +++- include/hw

[PATCH V3 14/42] pci: skip reset during cpr

2025-05-12 Thread Steve Sistare
Do not reset a vfio-pci device during CPR. Signed-off-by: Steve Sistare --- hw/pci/pci.c | 13 + 1 file changed, 13 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index fe38c4c..2ba2e0f 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -32,6 +32,8 @@ #include "h

[PATCH V3 11/42] vfio/container: mdev cpr blocker

2025-05-12 Thread Steve Sistare
During CPR, after VFIO_DMA_UNMAP_FLAG_VADDR, the vaddr is temporarily invalid, so mediated devices cannot be supported. Add a blocker for them. This restriction will not apply to iommufd containers when CPR is added for them in a future patch. Signed-off-by: Steve Sistare --- hw/vfio

[PATCH V3 02/42] migration: cpr helpers

2025-05-12 Thread Steve Sistare
Add the cpr_needed_for_reuse and cpr_open_fd, for use when adding cpr support for vfio and iommufd. Signed-off-by: Steve Sistare --- include/migration/cpr.h | 4 migration/cpr.c | 24 2 files changed, 28 insertions(+) diff --git a/include/migration/cpr.h

[PATCH V3 23/42] vfio-pci: preserve INTx

2025-05-12 Thread Steve Sistare
initialization, but still perform kvm initialization. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c | 27 ++- hw/vfio/pci.c | 29 ++--- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c index be132fa

[PATCH V3 37/42] vfio/iommufd: reconstruct device

2025-05-12 Thread Steve Sistare
we do need the range info, so defer the call to iommufd_cdev_get_info_iova_range to a post_load handler, at which time the ioas_id is known. This reconstruction is not complete. hwpt_id and devid need special treatment, handled in subsequent patches. Signed-off-by: Steve Sistare --- hw/vfi

[PATCH V3 03/42] migration: lower handler priority

2025-05-12 Thread Steve Sistare
handlers for the devices that they contain. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu --- include/migration/vmstate.h | 6 +- migration/savevm.c | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/migration/vmstate.h

[PATCH V3 19/42] vfio/pci: vfio_notifier_init cpr parameters

2025-05-12 Thread Steve Sistare
Pass vdev and nr to vfio_notifier_init, for use by CPR in a subsequent patch. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 22 ++ 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index dad6209..bfeaafa

[PATCH V3 13/42] pci: export msix_is_pending

2025-05-12 Thread Steve Sistare
Export msix_is_pending for use by cpr. No functional change. Signed-off-by: Steve Sistare Acked-by: Michael S. Tsirkin --- hw/pci/msix.c | 2 +- include/hw/pci/msix.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/pci/msix.c b/hw/pci/msix.c index 66f27b9

[PATCH V3 20/42] vfio/pci: vfio_notifier_cleanup

2025-05-12 Thread Steve Sistare
Move event_notifier_cleanup calls to a helper vfio_notifier_cleanup. This version is trivial, and does not yet use the vdev and nr parameters. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 28 +--- 1 file changed, 17 insertions(+), 11 deletions

[PATCH V3 26/42] vfio: return mr from vfio_get_xlat_addr

2025-05-12 Thread Steve Sistare
parameters that can be trivially derived from mr and xlat. Signed-off-by: Steve Sistare --- hw/vfio/listener.c | 29 +++-- hw/virtio/vhost-vdpa.c | 8 ++-- include/system/memory.h | 16 +++- system/memory.c | 25 - 4 files

[PATCH V3 09/42] vfio/container: discard old DMA vaddr

2025-05-12 Thread Steve Sistare
In the container pre_save handler, discard the virtual addresses in DMA mappings with VFIO_DMA_UNMAP_FLAG_VADDR, because guest RAM will be remapped at a different VA after in new QEMU. DMA to already-mapped pages continues. Signed-off-by: Steve Sistare --- hw/vfio/cpr-legacy.c | 29

[PATCH V3 15/42] vfio-pci: skip reset during cpr

2025-05-12 Thread Steve Sistare
Do not reset a vfio-pci device during CPR, and do not complain if the kernel's PCI config space changes for non-emulated bits between the vmstate save and load, which can happen due to ongoing interrupt activity. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c

[PATCH V3 34/42] vfio/iommufd: invariant device name

2025-05-12 Thread Steve Sistare
QEMU must know the fd number to construct a name to find the fd number. To fix, create an invariant name based on the id command-line parameter. If id is not defined, add a CPR blocker. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c | 21 + hw/vfio/device.c

[PATCH V3 17/42] vfio/pci: vfio_notifier_init

2025-05-12 Thread Steve Sistare
Move event_notifier_init calls to a helper vfio_notifier_init. This version is trivial, but it will be expanded to support CPR in subsequent patches. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 40 +--- 1 file changed, 25

[PATCH V3 31/42] vfio/iommufd: use IOMMU_IOAS_MAP_FILE

2025-05-12 Thread Steve Sistare
Use IOMMU_IOAS_MAP_FILE when the mapped region is backed by a file. Such a mapping can be preserved without modification during CPR, because it depends on the file's address space, which does not change, rather than on the process's address space, which does change. Signed-off-by: Ste

[PATCH V3 01/42] MAINTAINERS: Add reviewer for CPR

2025-05-12 Thread Steve Sistare
CPR is integrated with live migration, and has the same maintainers. But, add a CPR section to add a reviewer. Signed-off-by: Steve Sistare --- MAINTAINERS | 9 + 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 6dacd6d..d54a532 100644 --- a/MAINTAINERS

[PATCH V3 00/42] Live update: vfio and iommufd

2025-05-12 Thread Steve Sistare
oved cleanup patches that were already pulled * rebased to latest master Steve Sistare (42): MAINTAINERS: Add reviewer for CPR migration: cpr helpers migration: lower handler priority vfio: vfio_find_ram_discard_listener vfio: move vfio-cpr.h vfio/container: register container for

[PATCH V3 05/42] vfio: move vfio-cpr.h

2025-05-12 Thread Steve Sistare
Move vfio-cpr.h to include/hw/vfio, because it will need to be included by other files there. Signed-off-by: Steve Sistare --- MAINTAINERS| 1 + hw/vfio/container.c| 2 +- hw/vfio/cpr.c | 2 +- hw/vfio/iommufd.c | 2 +- hw/vfio/vfio-cpr.h

[PATCH V2 0/5] fast qom tree get

2025-05-12 Thread Steve Sistare
"qom: qom_resolve_path", which was pulled separately * dropped the error member * fixed missing _list_tree in qom.py * updated 10.0 to 10.1 Steve Sistare (5): qom: qom-tree-get python: use qom-tree-get tests/qtest/qom-test: unit test for qom-tree-get qom: qom-list-getv tes

[PATCH V2 4/5] qom: qom-list-getv

2025-05-12 Thread Steve Sistare
Define the qom-list-getv command, which fetches all the properties and values for a list of paths. This is faster than qom-tree-get when fetching a subset of the QOM tree. See qom.json for details. Signed-off-by: Steve Sistare --- qapi/qom.json | 34

[PATCH V2 3/5] tests/qtest/qom-test: unit test for qom-tree-get

2025-05-12 Thread Steve Sistare
Add a unit test for qom-tree-get Signed-off-by: Steve Sistare --- tests/qtest/qom-test.c | 49 + 1 file changed, 49 insertions(+) diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c index 27d70bc..d8792bd 100644 --- a/tests/qtest/qom

[PATCH V2 1/5] qom: qom-tree-get

2025-05-12 Thread Steve Sistare
Define the qom-tree-get QAPI command, which fetches an entire tree of properties and values with a single QAPI call. This is much faster than using qom-list plus qom-get for every node and property of the tree. See qom.json for details. Signed-off-by: Steve Sistare --- qapi/qom.json | 56

[PATCH V2 2/5] python: use qom-tree-get

2025-05-12 Thread Steve Sistare
Use qom-tree-get to speed up the qom-tree command. Signed-off-by: Steve Sistare --- python/qemu/utils/qom.py| 36 +++ python/qemu/utils/qom_common.py | 48 + 2 files changed, 66 insertions(+), 18 deletions(-) diff

[PATCH V2 5/5] tests/qtest/qom-test: unit test for qom-list-getv

2025-05-12 Thread Steve Sistare
Add a unit test for qom-list-getv. Signed-off-by: Steve Sistare --- tests/qtest/qom-test.c | 64 ++ 1 file changed, 64 insertions(+) diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c index d8792bd..671b757 100644 --- a/tests/qtest/qom

[PATCH V3 3/3] vfio/container: vfio_container_group_add

2025-05-02 Thread Steve Sistare
Add vfio_container_group_add to de-dup some code. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cedric Le Goater --- hw/vfio/container.c | 47 +-- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/hw/vfio/container.c

[PATCH V3 2/3] vfio/container: reform vfio_container_connect cleanup

2025-05-02 Thread Steve Sistare
Replace the proliferation of exit labels in vfio_container_connect with conditionals for cleaning each piece of state. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cedric Le Goater --- hw/vfio/container.c | 60 + 1 file

[PATCH V3 0/3] vfio cleanup, pre-cpr

2025-05-02 Thread Steve Sistare
Cleanup a few vfio functions prior to the introduction of CPR. These were extracted from https://lore.kernel.org/qemu-devel/1739542467-226739-1-git-send-email-steven.sist...@oracle.com/ Changes in V3: * update to master Steve Sistare (3): vfio/container: ram discard disable helper

[PATCH V3 1/3] vfio/container: ram discard disable helper

2025-05-02 Thread Steve Sistare
equivalent. Signed-off-by: Steve Sistare Reviewed-by: Cedric Le Goater --- hw/vfio/container.c | 48 +++- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 77ff56b..bf4bbd2 100644 --- a/hw

  1   2   3   4   5   6   7   8   9   10   >