On 9/25/2025 10:23 PM, Zhenzhong Duan wrote:
After CPR transfer, if there are more than one VFIO devices, the second
device's reference to hwpt isn't restored on destination.
More specifically, the device is not added to hwpt->device_list.
We still need
to call iommufd_cdev_attach_container() to restore it after a matching
container is found, or else SIGSEV triggers.
Fixes: 4296ee07455e ("vfio/iommufd: reconstruct device")
Signed-off-by: Zhenzhong Duan <[email protected]>
Thanks again.
Reviewed-by: Steve Sistare <[email protected]>
---
hw/vfio/iommufd.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 103ff43426..6df99d3aa6 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -565,10 +565,9 @@ static bool iommufd_cdev_attach(const char *name,
VFIODevice *vbasedev,
continue;
}
- if (!cpr_is_incoming()) {
+ if (!cpr_is_incoming() ||
+ (vbasedev->cpr.ioas_id == container->ioas_id)) {
res = iommufd_cdev_attach_container(vbasedev, container, &err);
- } else if (vbasedev->cpr.ioas_id == container->ioas_id) {
- res = true;
} else {
continue;
}