qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, clg@redhat.com,
	eric.auger@redhat.com, steven.sistare@oracle.com,
	Zhenzhong Duan <zhenzhong.duan@intel.com>
Subject: [PATCH 4/5] vfio/iommufd: Restore vbasedev's reference to hwpt after CPR transfer
Date: Thu, 25 Sep 2025 22:23:47 -0400	[thread overview]
Message-ID: <20250926022348.1883776-5-zhenzhong.duan@intel.com> (raw)
In-Reply-To: <20250926022348.1883776-1-zhenzhong.duan@intel.com>

After CPR transfer, if there are more than one VFIO devices, the second
device's reference to hwpt isn't restored on destination. 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 <zhenzhong.duan@intel.com>
---
 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;
         }
-- 
2.47.1



  parent reply	other threads:[~2025-09-26  2:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-26  2:23 [PATCH 0/5] VFIO: cpr-transfer fixes Zhenzhong Duan
2025-09-26  2:23 ` [PATCH 1/5] vfio/container: Remap only populated parts in a section Zhenzhong Duan
2025-09-26 13:25   ` Steven Sistare
2025-09-26  2:23 ` [PATCH 2/5] vfio/cpr-legacy: drop an erroneous assert Zhenzhong Duan
2025-09-26 13:25   ` Steven Sistare
2025-09-26  2:23 ` [PATCH 3/5] vfio/iommufd: Save cpr.ioas_id on source side for CPR transfer Zhenzhong Duan
2025-09-26 13:55   ` Steven Sistare
2025-09-26  2:23 ` Zhenzhong Duan [this message]
2025-09-26 14:22   ` [PATCH 4/5] vfio/iommufd: Restore vbasedev's reference to hwpt after " Steven Sistare
2025-09-27 16:09 ` [PATCH 0/5] VFIO: cpr-transfer fixes Cédric Le Goater
2025-09-28  8:15   ` Duan, Zhenzhong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250926022348.1883776-5-zhenzhong.duan@intel.com \
    --to=zhenzhong.duan@intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=clg@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=steven.sistare@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).