From nobody Sun Sep 28 15:28:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1758688798306750.8049819749974; Tue, 23 Sep 2025 21:39:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1128837.1469053 (Exim 4.92) (envelope-from ) id 1v1HHy-0004BR-A2; Wed, 24 Sep 2025 04:39:34 +0000 Received: by outflank-mailman (output) from mailman id 1128837.1469053; Wed, 24 Sep 2025 04:39:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HHy-0004At-3l; Wed, 24 Sep 2025 04:39:34 +0000 Received: by outflank-mailman (input) for mailman id 1128837; Wed, 24 Sep 2025 04:39:32 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HHw-0003tj-3L for xen-devel@lists.xenproject.org; Wed, 24 Sep 2025 04:39:32 +0000 Received: from www3579.sakura.ne.jp (www3579.sakura.ne.jp [49.212.243.89]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7478f1a8-9900-11f0-9d14-b5c5bf9af7f9; Wed, 24 Sep 2025 06:39:30 +0200 (CEST) Received: from h205.csg.ci.i.u-tokyo.ac.jp (h205.csg.ci.i.u-tokyo.ac.jp [133.11.54.205]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 58O4bSmt091795 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 24 Sep 2025 13:37:39 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7478f1a8-9900-11f0-9d14-b5c5bf9af7f9 DKIM-Signature: a=rsa-sha256; bh=stt1PYHjZPmmH11DgDaK1e3bftbIHLz7TmtRdVRF/9A=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Date:Subject:Message-Id:To; s=rs20250326; t=1758688659; v=1; b=lKHDilw5Fq1/cnZFtWrkLQsf0wSND4A4CU0I4JhwbBbzg1lFKYlm5Q6wiWuBCtxG CBRYgMu6tQ2BVB7pBZ4GKpjKjWSZFTvVUm0oTmudZfXEsN8GNwYfzHYCC7V2sEjn SWwyuMCezPLlRWJoNUlfxXyyK+NclfnGNRTrHEZnjUWn2czlf+auXXMRtpwS0RGD 0eOCj+jtWsvogScD6U0vQbVzanTlRUywY+cLXorEA1hhfKVYP1sH1Uj43IJdxQUo kvY6GCE+/eIZjhpVu+LCvIvEwMqhx+YtYzSwQh4kYV8v9fTB/B5MDHg2SQtUp3+c sOnfgKokiFWh2MNIuOFJvA== From: Akihiko Odaki Date: Wed, 24 Sep 2025 13:37:20 +0900 Subject: [PATCH v4 1/7] docs/devel: Do not unparent in instance_finalize() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250924-use-v4-1-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> References: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Helge Deller , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , "Michael S. Tsirkin" , Gerd Hoffmann , John Snow , qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Jesper Devantier , Marcel Apfelbaum , Nicholas Piggin , qemu-ppc@nongnu.org, John Levon , Thanos Makatos , Yanan Wang , BALATON Zoltan , Jiaxun Yang , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , =?utf-8?q?Alex_Benn=C3=A9e?= , Fabiano Rosas , Thomas Huth , Laurent Vivier , Peter Maydell , Aurelien Jarno , Aleksandar Rikalo , Max Filippov , =?utf-8?q?Herv=C3=A9_Poussineau?= , Mark Cave-Ayland , Artyom Tarasenko , Alistair Francis , "Maciej S. Szmigiero" , Bin Meng , Stefano Stabellini , Anthony PERARD , Paul Durrant , "Edgar E. Iglesias" , xen-devel@lists.xenproject.org, Akihiko Odaki X-Mailer: b4 0.15-dev-179e8 X-ZM-MESSAGEID: 1758688799276116600 Children are automatically unparented so manually unparenting is unnecessary. Worse, automatic unparenting happens before the instance_finalize() callback of the parent gets called, so object_unparent() calls in the callback will refer to objects that are already unparented, which is semantically incorrect. Remove the instruction to call object_unparent(), and the exception of the "do not call object_unparent()" rule for instance_finalize(). Signed-off-by: Akihiko Odaki Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/devel/memory.rst | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/docs/devel/memory.rst b/docs/devel/memory.rst index 42d3ca29c431..11858543f256 100644 --- a/docs/devel/memory.rst +++ b/docs/devel/memory.rst @@ -165,17 +165,14 @@ and finalized one by one. The order in which memory = regions will be finalized is not guaranteed. =20 If however the memory region is part of a dynamically allocated data -structure, you should call object_unparent() to destroy the memory region -before the data structure is freed. For an example see VFIOMSIXInfo -and VFIOQuirk in hw/vfio/pci.c. +structure, you should free the memory region in the instance_finalize +callback. For an example see VFIOMSIXInfo and VFIOQuirk in +hw/vfio/pci.c. =20 You must not destroy a memory region as long as it may be in use by a device or CPU. In order to do this, as a general rule do not create or -destroy memory regions dynamically during a device's lifetime, and only -call object_unparent() in the memory region owner's instance_finalize -callback. The dynamically allocated data structure that contains the -memory region then should obviously be freed in the instance_finalize -callback as well. +destroy memory regions dynamically during a device's lifetime, and must +never call object_unparent(). =20 If you break this rule, the following situation can happen: =20 @@ -201,9 +198,7 @@ this exception is rarely necessary, and therefore it is= discouraged, but nevertheless it is used in a few places. =20 For regions that "have no owner" (NULL is passed at creation time), the -machine object is actually used as the owner. Since instance_finalize is -never called for the machine object, you must never call object_unparent -on regions that have no owner, unless they are aliases or containers. +machine object is actually used as the owner. =20 =20 Overlapping regions and priority --=20 2.51.0 From nobody Sun Sep 28 15:28:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17586888051331012.0757716743872; Tue, 23 Sep 2025 21:40:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1128835.1469040 (Exim 4.92) (envelope-from ) id 1v1HHx-0003ws-Lr; Wed, 24 Sep 2025 04:39:33 +0000 Received: by outflank-mailman (output) from mailman id 1128835.1469040; Wed, 24 Sep 2025 04:39:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HHx-0003wN-FC; Wed, 24 Sep 2025 04:39:33 +0000 Received: by outflank-mailman (input) for mailman id 1128835; Wed, 24 Sep 2025 04:39:31 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HHu-0003tk-6P for xen-devel@lists.xenproject.org; Wed, 24 Sep 2025 04:39:31 +0000 Received: from www3579.sakura.ne.jp (www3579.sakura.ne.jp [49.212.243.89]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 730b5eda-9900-11f0-9809-7dc792cee155; Wed, 24 Sep 2025 06:39:27 +0200 (CEST) Received: from h205.csg.ci.i.u-tokyo.ac.jp (h205.csg.ci.i.u-tokyo.ac.jp [133.11.54.205]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 58O4bSmu091795 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 24 Sep 2025 13:37:39 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 730b5eda-9900-11f0-9809-7dc792cee155 DKIM-Signature: a=rsa-sha256; bh=jWpLp8n23CdClF2nwSY2mTKMJfX9C2XmSiyVTvW4DxU=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Date:Subject:Message-Id:To; s=rs20250326; t=1758688660; v=1; b=Z/ywqlxOJlUU34+E0osmWrMy3ELkCuh2OmBTrboInpXjOqD4SffZwY/4CYZU9EMl Dzx+hMFZXJ69msVRzYu3/rva7z862cW0LJjoo/7a+OQagfk8KQoAs9iIRpTaSSa0 pt61xjJaSVVPqRurq0vu8rPC19jEuObo8buUpNjAPokMhv64OcpL5QB9Y95TzlPO DlIeieX9/8KQLvSGtaM+M1bC9SwqmIQfS3fxvyYmqXzx7aCq3R7AM6yqLJEfDQ+v CJWE+1FHrkF22D4QuYAryKLCEdfm+xmGbKGgorUxyLRleupCLTsp+J1Kg+Ny5fWK 7e33gFmpWCJMRvhjM4Rrxw== From: Akihiko Odaki Date: Wed, 24 Sep 2025 13:37:21 +0900 Subject: [PATCH v4 2/7] vfio/pci: Do not unparent in instance_finalize() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250924-use-v4-2-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> References: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Helge Deller , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , "Michael S. Tsirkin" , Gerd Hoffmann , John Snow , qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Jesper Devantier , Marcel Apfelbaum , Nicholas Piggin , qemu-ppc@nongnu.org, John Levon , Thanos Makatos , Yanan Wang , BALATON Zoltan , Jiaxun Yang , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , =?utf-8?q?Alex_Benn=C3=A9e?= , Fabiano Rosas , Thomas Huth , Laurent Vivier , Peter Maydell , Aurelien Jarno , Aleksandar Rikalo , Max Filippov , =?utf-8?q?Herv=C3=A9_Poussineau?= , Mark Cave-Ayland , Artyom Tarasenko , Alistair Francis , "Maciej S. Szmigiero" , Bin Meng , Stefano Stabellini , Anthony PERARD , Paul Durrant , "Edgar E. Iglesias" , xen-devel@lists.xenproject.org, Akihiko Odaki X-Mailer: b4 0.15-dev-179e8 X-ZM-MESSAGEID: 1758688806904116600 Children are automatically unparented so manually unparenting is unnecessary. Worse, automatic unparenting happens before the insntance_finalize() callback of the parent gets called, so object_unparent() calls in the callback will refer to objects that are already unparented, which is semantically incorrect. Signed-off-by: Akihiko Odaki Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index d14e96b2f82d..bc0b4c4d562b 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2025,7 +2025,6 @@ static void vfio_bars_finalize(VFIOPCIDevice *vdev) vfio_region_finalize(&bar->region); if (bar->mr) { assert(bar->size); - object_unparent(OBJECT(bar->mr)); g_free(bar->mr); bar->mr =3D NULL; } @@ -2033,9 +2032,6 @@ static void vfio_bars_finalize(VFIOPCIDevice *vdev) =20 if (vdev->vga) { vfio_vga_quirk_finalize(vdev); - for (i =3D 0; i < ARRAY_SIZE(vdev->vga->region); i++) { - object_unparent(OBJECT(&vdev->vga->region[i].mem)); - } g_free(vdev->vga); } } --=20 2.51.0 From nobody Sun Sep 28 15:28:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1758689077496916.1951719888381; Tue, 23 Sep 2025 21:44:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1128903.1469103 (Exim 4.92) (envelope-from ) id 1v1HMb-0008Hc-Uc; Wed, 24 Sep 2025 04:44:21 +0000 Received: by outflank-mailman (output) from mailman id 1128903.1469103; Wed, 24 Sep 2025 04:44:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HMb-0008HV-Rr; Wed, 24 Sep 2025 04:44:21 +0000 Received: by outflank-mailman (input) for mailman id 1128903; Wed, 24 Sep 2025 04:44:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HMa-0008Gs-Sd for xen-devel@lists.xenproject.org; Wed, 24 Sep 2025 04:44:20 +0000 Received: from www3579.sakura.ne.jp (www3579.sakura.ne.jp [49.212.243.89]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 201c4b3c-9901-11f0-9809-7dc792cee155; Wed, 24 Sep 2025 06:44:18 +0200 (CEST) Received: from h205.csg.ci.i.u-tokyo.ac.jp (h205.csg.ci.i.u-tokyo.ac.jp [133.11.54.205]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 58O4bSmv091795 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 24 Sep 2025 13:37:40 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 201c4b3c-9901-11f0-9809-7dc792cee155 DKIM-Signature: a=rsa-sha256; bh=kiY10umG59rX3Ai7tv8N39IcOWzLTG5ZJdgQouDTy2w=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Date:Subject:Message-Id:To; s=rs20250326; t=1758688660; v=1; b=bYISStphDJwegYwwc2rICh89XnoVbrBbd3Jr4ouFuJjLVwyeUjtqjTleQ7UE6nED 5vJ/TcBEBn6sqzYTNLaB0oj75gpOKIDdYgCYt5vEDn3Mh8WY/o+35Ii2LIHZkf4e i53fFpswin9p5Dm26bNuRVKY1LjWr0XkMmbBPdYo07Jdh9cSvgRGW4Nw0i6V/Sac oeN0eaoO9HSSEzaOTVMKg4JVUIVXrmZozVIxOLaPkgluMFw3jzAe5zFT85PN1xe8 yYj56giV4oVv2QBk7zRIo+fuDGTQ5cYYRBMn5TcacbjlD+WA4psk/qNrLJOGp3yq 4VVjbYMEuou5BrRW0FwIqw== From: Akihiko Odaki Date: Wed, 24 Sep 2025 13:37:22 +0900 Subject: [PATCH v4 3/7] hw/core/register: Do not unparent in instance_finalize() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250924-use-v4-3-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> References: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Helge Deller , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , "Michael S. Tsirkin" , Gerd Hoffmann , John Snow , qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Jesper Devantier , Marcel Apfelbaum , Nicholas Piggin , qemu-ppc@nongnu.org, John Levon , Thanos Makatos , Yanan Wang , BALATON Zoltan , Jiaxun Yang , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , =?utf-8?q?Alex_Benn=C3=A9e?= , Fabiano Rosas , Thomas Huth , Laurent Vivier , Peter Maydell , Aurelien Jarno , Aleksandar Rikalo , Max Filippov , =?utf-8?q?Herv=C3=A9_Poussineau?= , Mark Cave-Ayland , Artyom Tarasenko , Alistair Francis , "Maciej S. Szmigiero" , Bin Meng , Stefano Stabellini , Anthony PERARD , Paul Durrant , "Edgar E. Iglesias" , xen-devel@lists.xenproject.org, Akihiko Odaki X-Mailer: b4 0.15-dev-179e8 X-ZM-MESSAGEID: 1758689077999116600 Children are automatically unparented so manually unparenting is unnecessary. Worse, automatic unparenting happens before the instance_finalize() callback of the parent gets called, so object_unparent() calls in the callback will refer to objects that are already unparented, which is semantically incorrect. Signed-off-by: Akihiko Odaki Reviewed-by: Daniel P. Berrang=C3=A9 --- hw/core/register.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/core/register.c b/hw/core/register.c index 8f63d9f227c4..3340df70b06e 100644 --- a/hw/core/register.c +++ b/hw/core/register.c @@ -314,7 +314,6 @@ RegisterInfoArray *register_init_block64(DeviceState *o= wner, =20 void register_finalize_block(RegisterInfoArray *r_array) { - object_unparent(OBJECT(&r_array->mem)); g_free(r_array->r); g_free(r_array); } --=20 2.51.0 From nobody Sun Sep 28 15:28:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1758688803320346.13673137055105; Tue, 23 Sep 2025 21:40:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1128836.1469046 (Exim 4.92) (envelope-from ) id 1v1HHx-00044I-VD; Wed, 24 Sep 2025 04:39:33 +0000 Received: by outflank-mailman (output) from mailman id 1128836.1469046; Wed, 24 Sep 2025 04:39:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HHx-00042t-PW; Wed, 24 Sep 2025 04:39:33 +0000 Received: by outflank-mailman (input) for mailman id 1128836; Wed, 24 Sep 2025 04:39:32 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HHw-0003tk-30 for xen-devel@lists.xenproject.org; Wed, 24 Sep 2025 04:39:32 +0000 Received: from www3579.sakura.ne.jp (www3579.sakura.ne.jp [49.212.243.89]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 73138fe5-9900-11f0-9809-7dc792cee155; Wed, 24 Sep 2025 06:39:27 +0200 (CEST) Received: from h205.csg.ci.i.u-tokyo.ac.jp (h205.csg.ci.i.u-tokyo.ac.jp [133.11.54.205]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 58O4bSmw091795 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 24 Sep 2025 13:37:40 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 73138fe5-9900-11f0-9809-7dc792cee155 DKIM-Signature: a=rsa-sha256; bh=7V8/qJWDXy9ssgUKD3EAH/SqAL55N0OPmxt1YNRhgjg=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Date:Subject:Message-Id:To; s=rs20250326; t=1758688661; v=1; b=fpEBclbjIpKxVrq15ObmeGZp2X/hB8cpT+Fe9ZF5ZwtxWHg367i9ECVMpItYYweS DohE22Tg/9jZhCUI5s7FKc1H9W8MlVuCMARv6JIyr9D1c0NGzhDk38GWl3Jz5q1Q YAVE8A1GB/BpemF3PehrsfWVyGLx1vCtH3YsngVEfqcRhi9+YPgRGYG0xATeQakf HVIfH42Ks5Db+qbIX5PdX/z41TkljcGjQagV5kudvXnF0DNKDzVqwMlwubuCP0Ut QxcNW98yc5qReI0Pr5yJWdlE5fRwA7dRt504qTCEgqhDK6WEw2+MpzoUpE6FY0Za ciOhUwfZuaYV4vSgEyu1YA== From: Akihiko Odaki Date: Wed, 24 Sep 2025 13:37:23 +0900 Subject: [PATCH v4 4/7] hv-balloon: hw/core/register: Do not unparent in instance_finalize() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250924-use-v4-4-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> References: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Helge Deller , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , "Michael S. Tsirkin" , Gerd Hoffmann , John Snow , qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Jesper Devantier , Marcel Apfelbaum , Nicholas Piggin , qemu-ppc@nongnu.org, John Levon , Thanos Makatos , Yanan Wang , BALATON Zoltan , Jiaxun Yang , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , =?utf-8?q?Alex_Benn=C3=A9e?= , Fabiano Rosas , Thomas Huth , Laurent Vivier , Peter Maydell , Aurelien Jarno , Aleksandar Rikalo , Max Filippov , =?utf-8?q?Herv=C3=A9_Poussineau?= , Mark Cave-Ayland , Artyom Tarasenko , Alistair Francis , "Maciej S. Szmigiero" , Bin Meng , Stefano Stabellini , Anthony PERARD , Paul Durrant , "Edgar E. Iglesias" , xen-devel@lists.xenproject.org, Akihiko Odaki X-Mailer: b4 0.15-dev-179e8 X-ZM-MESSAGEID: 1758688805038116600 Children are automatically unparented so manually unparenting is unnecessary. Worse, automatic unparenting happens before the instance_finalize() callback of the parent gets called, so object_unparent() calls in the callback will refer to objects that are already unparented, which is semantically incorrect. Signed-off-by: Akihiko Odaki Reviewed-by: Daniel P. Berrang=C3=A9 --- hw/hyperv/hv-balloon.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/hw/hyperv/hv-balloon.c b/hw/hyperv/hv-balloon.c index 6dbcb2d9a29d..2d6d7db4ee0e 100644 --- a/hw/hyperv/hv-balloon.c +++ b/hw/hyperv/hv-balloon.c @@ -1475,16 +1475,6 @@ static void hv_balloon_ensure_mr(HvBalloon *balloon) balloon->mr->align =3D memory_region_get_alignment(hostmem_mr); } =20 -static void hv_balloon_free_mr(HvBalloon *balloon) -{ - if (!balloon->mr) { - return; - } - - object_unparent(OBJECT(balloon->mr)); - g_clear_pointer(&balloon->mr, g_free); -} - static void hv_balloon_vmdev_realize(VMBusDevice *vdev, Error **errp) { ERRP_GUARD(); @@ -1580,7 +1570,7 @@ static void hv_balloon_vmdev_reset(VMBusDevice *vdev) */ static void hv_balloon_unrealize_finalize_common(HvBalloon *balloon) { - hv_balloon_free_mr(balloon); + g_clear_pointer(&balloon->mr, g_free); balloon->addr =3D 0; =20 balloon->memslot_count =3D 0; --=20 2.51.0 From nobody Sun Sep 28 15:28:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1758688797869880.4480624368415; Tue, 23 Sep 2025 21:39:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1128839.1469071 (Exim 4.92) (envelope-from ) id 1v1HHz-0004aP-99; Wed, 24 Sep 2025 04:39:35 +0000 Received: by outflank-mailman (output) from mailman id 1128839.1469071; Wed, 24 Sep 2025 04:39:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HHz-0004XL-2I; Wed, 24 Sep 2025 04:39:35 +0000 Received: by outflank-mailman (input) for mailman id 1128839; Wed, 24 Sep 2025 04:39:33 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HHx-0003tk-34 for xen-devel@lists.xenproject.org; Wed, 24 Sep 2025 04:39:33 +0000 Received: from www3579.sakura.ne.jp (www3579.sakura.ne.jp [49.212.243.89]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 73fc3e63-9900-11f0-9809-7dc792cee155; Wed, 24 Sep 2025 06:39:29 +0200 (CEST) Received: from h205.csg.ci.i.u-tokyo.ac.jp (h205.csg.ci.i.u-tokyo.ac.jp [133.11.54.205]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 58O4bSmx091795 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 24 Sep 2025 13:37:41 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 73fc3e63-9900-11f0-9809-7dc792cee155 DKIM-Signature: a=rsa-sha256; bh=p0MeB9ovOb3PqHuXUYX0hwqcDvAIFVXeIlzsht53Eeo=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Date:Subject:Message-Id:To; s=rs20250326; t=1758688662; v=1; b=LTCUXD0uGPlzR8Pa60OGDZF2aSHGue6kyd2Ye2fG7uK+uilOq14/6lNS7XZ/MHqv yeCEKtcHEdSgIBWEK4yEhreziwwT8hweA32gXhao6fR4WuxoVV0pwTW0YcjgGRze zKqRaeiZWcNTHJ5YL/kY3ezAkhJqQKVftt29SWB+FTHQ4fmIwizwua2Wpzll4YcY 86gZkXM5JmqpjsvX87KMH6S7y6t4iKQsv0kklqPtbfd3AGZFovDPCWJMZhAdf3LQ rog7FQrQ9kJVXn4NHY3cRcUM0z+5AIUkP+GOPIp2VghG3n3bZLeUQoo920VLYnFc skkyPiU+ovb54jjVOFps8Q== From: Akihiko Odaki Date: Wed, 24 Sep 2025 13:37:24 +0900 Subject: [PATCH v4 5/7] hw/sd/sdhci: Do not unparent in instance_finalize() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250924-use-v4-5-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> References: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Helge Deller , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , "Michael S. Tsirkin" , Gerd Hoffmann , John Snow , qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Jesper Devantier , Marcel Apfelbaum , Nicholas Piggin , qemu-ppc@nongnu.org, John Levon , Thanos Makatos , Yanan Wang , BALATON Zoltan , Jiaxun Yang , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , =?utf-8?q?Alex_Benn=C3=A9e?= , Fabiano Rosas , Thomas Huth , Laurent Vivier , Peter Maydell , Aurelien Jarno , Aleksandar Rikalo , Max Filippov , =?utf-8?q?Herv=C3=A9_Poussineau?= , Mark Cave-Ayland , Artyom Tarasenko , Alistair Francis , "Maciej S. Szmigiero" , Bin Meng , Stefano Stabellini , Anthony PERARD , Paul Durrant , "Edgar E. Iglesias" , xen-devel@lists.xenproject.org, Akihiko Odaki X-Mailer: b4 0.15-dev-179e8 X-ZM-MESSAGEID: 1758688799196116600 Children are automatically unparented so manually unparenting is unnecessary. Worse, automatic unparenting happens before the instance_finalize() callback of the parent gets called, so object_unparent() calls in the callback will refer to objects that are already unparented, which is semantically incorrect. Signed-off-by: Akihiko Odaki Reviewed-by: Daniel P. Berrang=C3=A9 --- hw/sd/sdhci.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 3c897e54b721..89b595ce4a5a 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1578,10 +1578,6 @@ static void sdhci_sysbus_finalize(Object *obj) { SDHCIState *s =3D SYSBUS_SDHCI(obj); =20 - if (s->dma_mr) { - object_unparent(OBJECT(s->dma_mr)); - } - sdhci_uninitfn(s); } =20 --=20 2.51.0 From nobody Sun Sep 28 15:28:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1758689073613315.4214742953941; Tue, 23 Sep 2025 21:44:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1128902.1469093 (Exim 4.92) (envelope-from ) id 1v1HMY-00082t-O8; Wed, 24 Sep 2025 04:44:18 +0000 Received: by outflank-mailman (output) from mailman id 1128902.1469093; Wed, 24 Sep 2025 04:44:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HMY-00082m-Kz; Wed, 24 Sep 2025 04:44:18 +0000 Received: by outflank-mailman (input) for mailman id 1128902; Wed, 24 Sep 2025 04:44:18 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HMY-00082g-16 for xen-devel@lists.xenproject.org; Wed, 24 Sep 2025 04:44:18 +0000 Received: from www3579.sakura.ne.jp (www3579.sakura.ne.jp [49.212.243.89]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1f0acf47-9901-11f0-9d14-b5c5bf9af7f9; Wed, 24 Sep 2025 06:44:16 +0200 (CEST) Received: from h205.csg.ci.i.u-tokyo.ac.jp (h205.csg.ci.i.u-tokyo.ac.jp [133.11.54.205]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 58O4bSn0091795 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 24 Sep 2025 13:37:42 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1f0acf47-9901-11f0-9d14-b5c5bf9af7f9 DKIM-Signature: a=rsa-sha256; bh=ZLD6q50HK2lQwLzxRbQaSBBUwzyTsangDxSOgNJJx8I=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Date:Subject:Message-Id:To; s=rs20250326; t=1758688662; v=1; b=HoN1iIkjYTsHEWCTgud6NoTyf1nD5F3t22JXFPqbYILfMLp+Xrv09z7OyGyuwUSk YYTcgI7g/+wZoGi91mRCqJFylcf+umFGGjaeZoaPi4MZwGG/W+j/T5X7jHjQYz6W ZcIRQ+yOnar0zOtxrCDqHIvyOsXVRnI8GS8sclqgSjFxHKXsPZOliFvo2dR2qGyo wwkcnvo1PhlyJ9qEjPaI+Ifqu5GIL1FKT++9yCSM6DDEEwNPND0Loz+98LE4Ta2b 7OfpePR7t1PFBMnbhLklDPAfrosOVAlQHA/niUjo66Ttb31aBuFGkLYkcPcWkWNW jurSTzbiNvWzl9uoid98OQ== From: Akihiko Odaki Date: Wed, 24 Sep 2025 13:37:25 +0900 Subject: [PATCH v4 6/7] vfio: Do not unparent in instance_finalize() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250924-use-v4-6-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> References: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Helge Deller , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , "Michael S. Tsirkin" , Gerd Hoffmann , John Snow , qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Jesper Devantier , Marcel Apfelbaum , Nicholas Piggin , qemu-ppc@nongnu.org, John Levon , Thanos Makatos , Yanan Wang , BALATON Zoltan , Jiaxun Yang , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , =?utf-8?q?Alex_Benn=C3=A9e?= , Fabiano Rosas , Thomas Huth , Laurent Vivier , Peter Maydell , Aurelien Jarno , Aleksandar Rikalo , Max Filippov , =?utf-8?q?Herv=C3=A9_Poussineau?= , Mark Cave-Ayland , Artyom Tarasenko , Alistair Francis , "Maciej S. Szmigiero" , Bin Meng , Stefano Stabellini , Anthony PERARD , Paul Durrant , "Edgar E. Iglesias" , xen-devel@lists.xenproject.org, Akihiko Odaki X-Mailer: b4 0.15-dev-179e8 X-ZM-MESSAGEID: 1758689074002116600 Children are automatically unparented so manually unparenting is unnecessary. Worse, automatic unparenting happens before the instance_finalize() callback of the parent gets called, so object_unparent() calls in the callback will refer to objects that are already unparented, which is semantically incorrect. Signed-off-by: Akihiko Odaki Reviewed-by: Daniel P. Berrang=C3=A9 --- hw/vfio/pci-quirks.c | 9 +-------- hw/vfio/region.c | 3 --- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index c97606dbf194..b5da6afbf5b0 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1159,15 +1159,12 @@ void vfio_vga_quirk_exit(VFIOPCIDevice *vdev) =20 void vfio_vga_quirk_finalize(VFIOPCIDevice *vdev) { - int i, j; + int i; =20 for (i =3D 0; i < ARRAY_SIZE(vdev->vga->region); i++) { while (!QLIST_EMPTY(&vdev->vga->region[i].quirks)) { VFIOQuirk *quirk =3D QLIST_FIRST(&vdev->vga->region[i].quirks); QLIST_REMOVE(quirk, next); - for (j =3D 0; j < quirk->nr_mem; j++) { - object_unparent(OBJECT(&quirk->mem[j])); - } g_free(quirk->mem); g_free(quirk->data); g_free(quirk); @@ -1207,14 +1204,10 @@ void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int n= r) void vfio_bar_quirk_finalize(VFIOPCIDevice *vdev, int nr) { VFIOBAR *bar =3D &vdev->bars[nr]; - int i; =20 while (!QLIST_EMPTY(&bar->quirks)) { VFIOQuirk *quirk =3D QLIST_FIRST(&bar->quirks); QLIST_REMOVE(quirk, next); - for (i =3D 0; i < quirk->nr_mem; i++) { - object_unparent(OBJECT(&quirk->mem[i])); - } g_free(quirk->mem); g_free(quirk->data); g_free(quirk); diff --git a/hw/vfio/region.c b/hw/vfio/region.c index d04c57db630f..b165ab0b9378 100644 --- a/hw/vfio/region.c +++ b/hw/vfio/region.c @@ -365,12 +365,9 @@ void vfio_region_finalize(VFIORegion *region) for (i =3D 0; i < region->nr_mmaps; i++) { if (region->mmaps[i].mmap) { munmap(region->mmaps[i].mmap, region->mmaps[i].size); - object_unparent(OBJECT(®ion->mmaps[i].mem)); } } =20 - object_unparent(OBJECT(region->mem)); - g_free(region->mem); g_free(region->mmaps); =20 --=20 2.51.0 From nobody Sun Sep 28 15:28:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1758688805257714.8455040107286; Tue, 23 Sep 2025 21:40:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1128838.1469060 (Exim 4.92) (envelope-from ) id 1v1HHy-0004LL-MI; Wed, 24 Sep 2025 04:39:34 +0000 Received: by outflank-mailman (output) from mailman id 1128838.1469060; Wed, 24 Sep 2025 04:39:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HHy-0004KW-FM; Wed, 24 Sep 2025 04:39:34 +0000 Received: by outflank-mailman (input) for mailman id 1128838; Wed, 24 Sep 2025 04:39:32 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v1HHw-0003tk-9s for xen-devel@lists.xenproject.org; Wed, 24 Sep 2025 04:39:32 +0000 Received: from www3579.sakura.ne.jp (www3579.sakura.ne.jp [49.212.243.89]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 737f76b0-9900-11f0-9809-7dc792cee155; Wed, 24 Sep 2025 06:39:28 +0200 (CEST) Received: from h205.csg.ci.i.u-tokyo.ac.jp (h205.csg.ci.i.u-tokyo.ac.jp [133.11.54.205]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 58O4bSn1091795 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 24 Sep 2025 13:37:42 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 737f76b0-9900-11f0-9809-7dc792cee155 DKIM-Signature: a=rsa-sha256; bh=vi4sMCmLJjgfxvWMbOYby11DlXiXjOhpwer283mUMTs=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Date:Subject:Message-Id:To; s=rs20250326; t=1758688663; v=1; b=vMUFXDPYCmcF3lkI3BSe8blrWRLpmkSDNiuoijwb8afjg4NFFoXRVFRUcZKqSDWZ UxyHm40QSJbHGmhdgwFt2tLNGNwgCN9rY3rBjQRTYhwEgeOZHxvqM8it4xuvLD2I Y64/RVkv+TGrq1SHjZX01HPGzBAE1tXU/+8KZ9eiHUy+bjnBFdvJZGS56faG53Pm ayjh52pqL+SyZAbZWvtUf/zdn43pa9CblMdEmFQi+w3kalRFalhT9Gcto4h5FPcD kHSwZrG/MFphOqwon+RkDuWJB+7ep1P8/2N8JN+8Xus32JicITr97APzWeqPas3v utrloMLlNHbmgml831WcIQ== From: Akihiko Odaki Date: Wed, 24 Sep 2025 13:37:26 +0900 Subject: [PATCH v4 7/7] hw/xen: Do not unparent in instance_finalize() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250924-use-v4-7-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> References: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20250924-use-v4-0-07c6c598f53d@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Peter Xu , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Helge Deller , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , "Michael S. Tsirkin" , Gerd Hoffmann , John Snow , qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Jesper Devantier , Marcel Apfelbaum , Nicholas Piggin , qemu-ppc@nongnu.org, John Levon , Thanos Makatos , Yanan Wang , BALATON Zoltan , Jiaxun Yang , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , =?utf-8?q?Alex_Benn=C3=A9e?= , Fabiano Rosas , Thomas Huth , Laurent Vivier , Peter Maydell , Aurelien Jarno , Aleksandar Rikalo , Max Filippov , =?utf-8?q?Herv=C3=A9_Poussineau?= , Mark Cave-Ayland , Artyom Tarasenko , Alistair Francis , "Maciej S. Szmigiero" , Bin Meng , Stefano Stabellini , Anthony PERARD , Paul Durrant , "Edgar E. Iglesias" , xen-devel@lists.xenproject.org, Akihiko Odaki X-Mailer: b4 0.15-dev-179e8 X-ZM-MESSAGEID: 1758688806907116600 Children are automatically unparented so manually unparenting is unnecessary. Worse, automatic unparenting happens before the instance_finalize() callback of the parent gets called, so object_unparent() calls in the callback will refer to objects that are already unparented, which is semantically incorrect. Signed-off-by: Akihiko Odaki Reviewed-by: Daniel P. Berrang=C3=A9 --- hw/xen/xen_pt_msi.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c index 09cca4eecb1c..e9ba17317aba 100644 --- a/hw/xen/xen_pt_msi.c +++ b/hw/xen/xen_pt_msi.c @@ -637,14 +637,5 @@ void xen_pt_msix_unmap(XenPCIPassthroughState *s) =20 void xen_pt_msix_delete(XenPCIPassthroughState *s) { - XenPTMSIX *msix =3D s->msix; - - if (!msix) { - return; - } - - object_unparent(OBJECT(&msix->mmio)); - - g_free(s->msix); - s->msix =3D NULL; + g_clear_pointer(&s->msix, g_free); } --=20 2.51.0