From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39380606A322 for ; Fri, 4 Dec 2026 10:48:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BoRdCQqY Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xZQpn-0002na-3n; Fri, 04 Dec 2026 05:48:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xZQpY-0002kW-M2 for qemu-devel@nongnu.org; Fri, 04 Dec 2026 05:48:02 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xZQpW-00056G-SY for qemu-devel@nongnu.org; Fri, 04 Dec 2026 05:47:56 -0500 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-3b53db3d0a5so407772a91.0 for ; Fri, 04 Dec 2026 02:47:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796381273; x=1796986073; darn=nongnu.org; h=cc:to:message-id:content-transfer-encoding:content-type :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=DUlYlKogKcPn/KxOZ6QSIW5yJ8O4BeeLgTdu8OGkwAA=; b=BoRdCQqY3CrEA79c2HPVHP6Y/5kCH90xG+zB2/YYk1st3juustBN8ozFK74vfgdB0Z jD8Puntz6Eos09/1MeHHME0nhgSFkLFlx9XYhSTm9iXcgIUlNn5bUxfqLIFlsj7bJsTw lmlg+fZL3S0uMq0LCkOpVw9e5pn7MC9T4R6+OmojE1XUgepLDbN6shhN0Shps/P9le0C NT6lEYFiBuP/Kwrrgs7cw6fZNFWpHVo4lOXjW+IMJhGr6UEG18xC0U06Zce4vTiPBT3A Jm0++vRlKeLu1qDg51dEQj+yjmswjRmsJwKrFGT6gDU+dLUcRSutTTGfQ9OX6+uovRyr VTxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796381273; x=1796986073; h=cc:to:message-id:content-transfer-encoding:content-type :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=DUlYlKogKcPn/KxOZ6QSIW5yJ8O4BeeLgTdu8OGkwAA=; b=yBiB2PbAY1c8370D134eF0zgaJjrt/ml9H2gPgXhm8CpX3u5nZSLQHkuMsh0Y5BgYH /nyZS21ANlt53qIUz+0mj5+YliQYE4PAa/z4xzNtLiGeVZ5URuTG3YkxICWvDTHcu4H+ JShDWf37ycKhmGuNpGrODoDODIZ5yxq/Pd6rjL8acaKB3b32KXItpPwoO5Lf9kxjXWZu M24Cpo9fI0D7nX6njXjPTE2SJ9Ak0TIR1evupTHA8Bl8/vHL7aqeVYrOmOOQQM/1vw3d S98bDQlWuM7D5rEc9F9xHwxPkIVTNiRpYAI1PmXM5srAcL1kQMZBmCSLBSuURsKgy4ko r8TA== X-Gm-Message-State: AB4q+uFq7iP1vT5B6yHX8dCaJxemx8XcUBJqZ9v64EoBGUT+ZAZU0oA9 zeLyfhERBz3oMFXx6sa/svYGSt1Eyr+R59/vB5uzgEHpv4RLn/N8I6Fm X-Gm-Gg: AZFdTZcrTUg+oW61T/jA1ifXFgZJZg5LYs4UU6vHbO2HMt+bPJKQu3DN9eF4KtuH6tK tMMOwwtVeUKvLfT5BhJS+2JXMeK406ezQ4koDKNQoAE1pr6Q91aNfigKCA7yp7sk1CyCf9xHLVq 7GuZbC82SBSG2WDqySght9iNb08VC0+T9JEupLuawDIUFgz43hESpnWPMA+zqYJoqUTkoEJIJyu eUB4rV7LGTrKo8B9KAj2+eQ0uiwE+mVzavT6c5/u6vaYGYMGe1bb9r/27r3i7yI+VVauNIZ7B7/ ZKK3yr1EMmqhFiPEew3W78LODZjqwUzg1FxpmaCxcPzkfwjS9VALctY2wW1KA9AU0YRaLaCgwNB ghEQdqVhuFCi8U1RLbLcUg7A6AphrK0w/HTX5pe5T+VKjlLlppMQjAydYIIRcoSaLqZIBgmwZhi E8WzxvKjWZ7eqhgY3JlG7OWyIrOiiriaR1XIuznV+FD+pKtfxxapFFIfwBbbtUKRKCGDYJ1IkbP Vdg5x1NAaPigorLV1i6Ow6ON4FSD7yJfFpa0q3kfNqMr8HEcHUE9LxFsBIRUtEnq/fcSJ5XHW4G VKyQVmPMDWI+zml9LDUUa8N+RawKku2trqyWYZiqQq9EjsIrVPd6odDAq4LDLsvGUapFoOSbHrW sAKBwNd+gn2n3nLxKdJo5Xjwx9pX88N0= X-Received: by 2002:a17:90b:4b81:b0:3b3:b5b4:e4a9 with SMTP id 98e67ed59e1d1-3b5e0537a4fmr1355254a91.3.1796381273258; Fri, 04 Dec 2026 02:47:53 -0800 (PST) Received: from cfarm136.osuosl.org (cfarm136.osuosl.org. [2605:bc80:3010:104:21e:67ff:fefd:7034]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8de12db32besm1309853b3a.34.2026.12.04.02.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 02:47:52 -0800 (PST) From: =?utf-8?q?Oscar_Alejandro_S=C3=A1nchez_Lucero?= Date: Fri, 04 Dec 2026 10:47:41 +0000 Subject: [PATCH] system/memory: Convert MemoryRegion properties to class properties X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20261204-memory-class-props-v1-1-a58840aa9cd6@gmail.com> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yXMwQrCMAyA4VcZORtoyyjOVxEPNYua4daSqGyMv fuqHr/D/69grMIGp2YF5Y+Y5KnCHxqgR5rujNJXQ3Ah+uBaHHnMuiA9kxkWzcUwtrGjkOLRkYc aFuWbzL/p+fK3va8D0+t7gm3bAedBd252AAAA X-Change-ID: 20261204-memory-class-props-6469c2a680c1 To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Oscar_Alejandro_S=C3=A1nchez_Lucero?= X-Mailer: b4 0.16.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=aleszlucero@gmail.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Instance-level property registration via object_property_add*() is deprecated in favor of class-level registration in class_init (see include/qom/object.h). Move the "container", "addr" (guarded with QEMU_BUILD_BUG_ON to ensure hwaddr remains 64-bit), "priority", and "size" properties from memory_region_initfn() to a new memory_region_class_init() callback. Because MemoryRegion objects are instantiated dozens or hundreds of times per machine (for example, 74 instances even on a minimal arm 'virt' board), registering these properties on the class eliminates redundant per-instance heap allocations and hash table insertions while allowing class-level QOM property introspection. Verified with tests/unit/check-qom-proplist, recursive QMP qom-list across all 74 MemoryRegion instances on arm 'virt', and live QMP qom-get queries on both root and mapped MMIO regions. Signed-off-by: Oscar Alejandro Sánchez Lucero --- system/memory.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/system/memory.c b/system/memory.c index 56c5dd6c8a..3880e0ee27 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1285,23 +1285,6 @@ static void memory_region_initfn(Object *obj) mr->destructor = memory_region_destructor_none; QTAILQ_INIT(&mr->subregions); QTAILQ_INIT(&mr->coalesced); - - object_property_add_link(obj, "container", - TYPE_MEMORY_REGION, - (Object **)&mr->container, - NULL, /* read-only: no check means no setter */ - 0); - - object_property_add_uint64_ptr(OBJECT(mr), "addr", - &mr->addr, OBJ_PROP_FLAG_READ); - object_property_add(OBJECT(mr), "priority", "int32", &int32_type_info, - memory_region_get_priority, - NULL, /* memory_region_set_priority */ - NULL, NULL); - object_property_add(OBJECT(mr), "size", "uint64", &uint64_type_info, - memory_region_get_size, - NULL, /* memory_region_set_size, */ - NULL, NULL); } static void iommu_memory_region_initfn(Object *obj) @@ -3650,11 +3633,34 @@ void __attribute__((weak)) fuzz_dma_read_cb(size_t addr, } #endif +static void memory_region_class_init(ObjectClass *oc, const void *data) +{ + object_class_property_add_link(oc, "container", + TYPE_MEMORY_REGION, + offsetof(MemoryRegion, container), + NULL, /* read-only: no setter */ + 0); + + QEMU_BUILD_BUG_ON(sizeof_field(MemoryRegion, addr) != sizeof(uint64_t)); + object_class_property_add_uint64_ptr(oc, "addr", + offsetof(MemoryRegion, addr), + OBJ_PROP_FLAG_READ); + object_class_property_add(oc, "priority", "int32", &int32_type_info, + memory_region_get_priority, + NULL, /* memory_region_set_priority */ + NULL, NULL); + object_class_property_add(oc, "size", "uint64", &uint64_type_info, + memory_region_get_size, + NULL, /* memory_region_set_size, */ + NULL, NULL); +} + static const TypeInfo memory_region_info = { .parent = TYPE_OBJECT, .name = TYPE_MEMORY_REGION, .class_size = sizeof(MemoryRegionClass), .instance_size = sizeof(MemoryRegion), + .class_init = memory_region_class_init, .instance_init = memory_region_initfn, .instance_finalize = memory_region_finalize, }; --- base-commit: f210851c088e477e9b79fa906b60c4f15a8bb011 change-id: 20261204-memory-class-props-6469c2a680c1 Best regards, -- Oscar Alejandro Sánchez Lucero