From nobody Sat Nov 15 01:20:40 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758116119631136.47413871605556; Wed, 17 Sep 2025 06:35:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uyroD-0004Yc-Cp; Wed, 17 Sep 2025 09:02:55 -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 1uyrlY-00012C-Mt; Wed, 17 Sep 2025 09:00:12 -0400 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uyrlL-0005Gc-Jh; Wed, 17 Sep 2025 09:00:06 -0400 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 58HCuN7B008967 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 17 Sep 2025 21:56:56 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=QBwrwrnsE1FoC507zgp90eTWpyZH/hajqME9o3OUmT4=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Date:Subject:Message-Id:To; s=rs20250326; t=1758113817; v=1; b=kYxhy6+9dqTDk/uCvtp8qrxm6EFeDZp+tr0d4KtbPV3tOn6ezkr/WCTdJhOqhN2s /ldESHLVVgrZ2ZgMTakYedXLE2tsNxs5WMMy+mdKXWKGMFmlMa6TtKlnoW3G7nIp 1u6KYk8jrVsmGSP8/jyzKMvei5raAklSfI0GjrFEoijcKg50cu9RiorVHt6dX3Vw 4cwNeDvMERqWMj0aapNap1/TfbiUpn+LlKMULQl8NjcplNhEEhzm3VA9NyCidwbD V2vVeR4E992wgVQnFahlId4fRs6WJWJ3P5rUzkIKW8BN8OZ/h7561tDF4+Gf7bgm 6oojDAoTjZJg92PfQyhC/w== From: Akihiko Odaki Date: Wed, 17 Sep 2025 21:56:43 +0900 Subject: [PATCH 31/35] system/physmem: QOM-ify AddressSpace MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250917-qom-v1-31-7262db7b0a84@rsg.ci.i.u-tokyo.ac.jp> References: <20250917-qom-v1-0-7262db7b0a84@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20250917-qom-v1-0-7262db7b0a84@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Richard Henderson , Peter Maydell , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Steven Lee , Troy Lee , Jamin Lin , Andrew Jeffery , Joel Stanley , Eric Auger , Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Aleksandar Rikalo , "Edgar E. Iglesias" , Alistair Francis , Ninad Palsule , Paolo Bonzini , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Jason Wang , Yi Liu , =?utf-8?q?Cl=C3=A9ment_Mathieu--Drif?= , Nicholas Piggin , Aditya Gupta , Gautam Menghani , Song Gao , Bibo Mao , Jiaxun Yang , Jonathan Cameron , Fan Ni , David Hildenbrand , Igor Mammedov , Xiao Guangrong , Beniamino Galvani , Strahinja Jankovic , Subbaraya Sundeep , Jan Kiszka , Laurent Vivier , Andrey Smirnov , Aurelien Jarno , BALATON Zoltan , Bernhard Beschow , Harsh Prateek Bora , Elena Ufimtseva , Jagannathan Raman , Palmer Dabbelt , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Matthew Rosato , Eric Farman , Thomas Huth , Halil Pasic , Christian Borntraeger , Ilya Leoshkevich , Fam Zheng , Bin Meng , Mark Cave-Ayland , Artyom Tarasenko , Peter Xu , Marcelo Tosatti , Max Filippov , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, qemu-block@nongnu.org, kvm@vger.kernel.org, Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Stefano Garzarella , Alistair Francis , Akihiko Odaki X-Mailer: b4 0.15-dev-179e8 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=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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-ZM-MESSAGEID: 1758116121500116600 Make AddressSpaces QOM objects to ensure that they are destroyed when their owners are finalized and also to get a unique path for debugging output. The name arguments were used to distinguish AddresSpaces in debugging output, but they will represent property names after QOM-ification and debugging output will show QOM paths. So change them to make them more concise and also avoid conflicts with other properties. Signed-off-by: Akihiko Odaki --- include/exec/cpu-common.h | 4 ++-- system/physmem.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 9b658a3f48f7..420e7a71001a 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -105,7 +105,7 @@ size_t qemu_ram_pagesize_largest(void); * cpu_address_space_init: * @cpu: CPU to add this address space to * @asidx: integer index of this address space - * @prefix: prefix to be used as name of address space + * @name: name of address space * @mr: the root memory region of address space * * Add the specified address space to the CPU's cpu_ases list. @@ -121,7 +121,7 @@ size_t qemu_ram_pagesize_largest(void); * Note that with KVM only one address space is supported. */ void cpu_address_space_init(CPUState *cpu, int asidx, - const char *prefix, MemoryRegion *mr); + const char *name, MemoryRegion *mr); /** * cpu_address_space_destroy: * @cpu: CPU for which address space needs to be destroyed diff --git a/system/physmem.c b/system/physmem.c index 6190eca7daed..7fa7b9ee6b76 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -774,16 +774,13 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, #endif /* CONFIG_TCG */ =20 void cpu_address_space_init(CPUState *cpu, int asidx, - const char *prefix, MemoryRegion *mr) + const char *name, MemoryRegion *mr) { CPUAddressSpace *newas; AddressSpace *as =3D g_new0(AddressSpace, 1); - char *as_name; =20 assert(mr); - as_name =3D g_strdup_printf("%s-%d", prefix, cpu->cpu_index); - address_space_init(as, NULL, mr, as_name); - g_free(as_name); + address_space_init(as, OBJECT(cpu), mr, name); =20 /* Target code should have set num_ases before calling us */ assert(asidx < cpu->num_ases); @@ -831,7 +828,7 @@ void cpu_address_space_destroy(CPUState *cpu, int asidx) memory_listener_unregister(&cpuas->tcg_as_listener); } =20 - address_space_destroy(cpuas->as); + object_unparent(OBJECT(cpuas->as)); call_rcu1(&cpuas->as->rcu, address_space_free); =20 if (asidx =3D=3D 0) { @@ -2814,15 +2811,17 @@ static void tcg_commit(MemoryListener *listener) =20 static void memory_map_init(void) { - system_memory =3D g_malloc(sizeof(*system_memory)); + Object *owner =3D machine_get_container("unattached"); =20 + system_memory =3D g_malloc(sizeof(*system_memory)); memory_region_init(system_memory, NULL, "system", UINT64_MAX); - address_space_init(&address_space_memory, NULL, system_memory, "memory= "); + address_space_init(&address_space_memory, owner, system_memory, + "system-as"); =20 system_io =3D g_malloc(sizeof(*system_io)); memory_region_init_io(system_io, NULL, &unassigned_io_ops, NULL, "io", 65536); - address_space_init(&address_space_io, NULL, system_io, "I/O"); + address_space_init(&address_space_io, owner, system_io, "io-as"); } =20 MemoryRegion *get_system_memory(void) --=20 2.51.0