From nobody Sun Sep 28 15:27:18 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1759049889; cv=none; d=zohomail.com; s=zohoarc; b=WXwzCKdYJ8QalSIELKf8HWvgTbbeifF/U5tOFRc42w42QuXWJ6AxcKMsuLHMOBzQvN7QTl8QWPvlO+9z9I4fHo+TRKxq+gbIN0TMJxBuA7uevR9ELAIJimzpvUQiuvx5YlUXLDBTgNTmkLnJl5unbZeUpfGzp1IQMJBqA+YUtLs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759049889; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=M9EUekCt+sMf9xYMrEftQEF8OYGi+jT++oPrhWPEwDw=; b=nG2beru627dO49UClUmB346Z6TzO+vUsb/zUetJj/cbJYseebofw8x2cco9O2FMcPPolOs4tObrF19/pvaz97WZ49aMqKzW1uozhlAwzpq6na3qXGpZZlt0FgDsyFCmo7gtFTcEW8nazG+RMbhLVihfUYfX2d8RNMwl1Di/o/M4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759049888996943.0229734519282; Sun, 28 Sep 2025 01:58:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2nCC-0006Tv-1w; Sun, 28 Sep 2025 04:55:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2nC8-0006TE-Dq for qemu-devel@nongnu.org; Sun, 28 Sep 2025 04:55:49 -0400 Received: from mgamail.intel.com ([192.198.163.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2nC1-00045O-TN for qemu-devel@nongnu.org; Sun, 28 Sep 2025 04:55:48 -0400 Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2025 01:55:24 -0700 Received: from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2025 01:55:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1759049742; x=1790585742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3UQj2hJs2Apvsru+FUO6+kmR91IJA7eedlHTGTktHRA=; b=XpMZXS0RA1YZugkL/paQ2LQxf4/eS3OptRCuS0NhORKW+rrqBkyfppkw KWjBlOcZVhZtCWoD2B7m6uwW+dXTWInBNVoPGr4XNnfKDrY7DIdBK5VUW EwaZKVz4pkhiTsb7vev054kQCEvwQqXKgt1EDxe//cAO05ppkKolG/ua6 32O7N4l/WqvbcTU004JY+Brgb5gczyLmCk7s3W7nogULZLHAgYp+81Ww8 +gWTDV1osfmR5EMhMkTopz7JHsLyWcMStB+K4Wp2GyqITGOJyZecNiK3l STjALWAVldDr28qhiff89aRwrrLUBr7ljCV3bZe6hNDHmnex9PlwryZl7 g==; X-CSE-ConnectionGUID: fxEBmT44TBeHhMrDUGzedg== X-CSE-MsgGUID: bp/jEMH/RviWbSZs07KkOg== X-IronPort-AV: E=McAfee;i="6800,10657,11566"; a="65167439" X-IronPort-AV: E=Sophos;i="6.18,299,1751266800"; d="scan'208";a="65167439" X-CSE-ConnectionGUID: ldyHBXjvR2uMmdaZaB8a+A== X-CSE-MsgGUID: NckImwntR7aZfgMDfIOceA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,299,1751266800"; d="scan'208";a="177810815" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, steven.sistare@oracle.com, Zhenzhong Duan Subject: [PATCH v2 4/6] vfio/iommufd: Restore vbasedev's reference to hwpt after CPR transfer Date: Sun, 28 Sep 2025 04:54:30 -0400 Message-ID: <20250928085432.40107-5-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250928085432.40107-1-zhenzhong.duan@intel.com> References: <20250928085432.40107-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.12; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -47 X-Spam_score: -4.8 X-Spam_bar: ---- X-Spam_report: (-4.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1759049890886116600 Content-Type: text/plain; charset="utf-8" After CPR transfer, if there are more than one VFIO devices, device is not added to hwpt->device_list and its 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 Reviewed-by: Steve Sistare --- 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 13c5c49d5e..c6ca5db009 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -560,10 +560,9 @@ static bool iommufd_cdev_attach(const char *name, VFIO= Device *vbasedev, continue; } =20 - if (!cpr_is_incoming()) { + if (!cpr_is_incoming() || + (vbasedev->cpr.ioas_id =3D=3D container->ioas_id)) { res =3D iommufd_cdev_attach_container(vbasedev, container, &er= r); - } else if (vbasedev->cpr.ioas_id =3D=3D container->ioas_id) { - res =3D true; } else { continue; } --=20 2.47.1