From nobody Sun Feb 8 17:37:03 2026 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=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769703689229324.5871141714475; Thu, 29 Jan 2026 08:21:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vlUku-0004uy-5a; Thu, 29 Jan 2026 11:20:28 -0500 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 1vlUko-0004sh-TJ for qemu-devel@nongnu.org; Thu, 29 Jan 2026 11:20:24 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vlUkk-0000e1-Lm for qemu-devel@nongnu.org; Thu, 29 Jan 2026 11:20:22 -0500 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 6DFDE596AE1; Thu, 29 Jan 2026 17:20:15 +0100 (CET) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id W-2937ki1alH; Thu, 29 Jan 2026 17:20:13 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 54489596A38; Thu, 29 Jan 2026 17:20:13 +0100 (CET) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: <87d6eafa7c7f7f62de0e82dd5c70cd0d0a4f59b8.1769703287.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 1/4] memory: Remove memory_region_init_rom_device_nomigrate() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org Cc: Peter Xu , Akihiko Odaki , Paolo Bonzini , Mark Cave-Ayland , Gerd Hoffmann , Max Filippov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Thu, 29 Jan 2026 17:20:13 +0100 (CET) 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=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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-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: 1769703692992158500 Content-Type: text/plain; charset="utf-8" This function is never used, remove it. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/devel/memory.rst | 1 - include/system/memory.h | 27 ------------ .../memory-region-housekeeping.cocci | 8 ---- system/memory.c | 41 ++++++------------- 4 files changed, 13 insertions(+), 64 deletions(-) diff --git a/docs/devel/memory.rst b/docs/devel/memory.rst index f22146e56c..8558f70a42 100644 --- a/docs/devel/memory.rst +++ b/docs/devel/memory.rst @@ -114,7 +114,6 @@ the backing memory yourself, you can call the functions: =20 - memory_region_init_ram_nomigrate() - memory_region_init_rom_nomigrate() -- memory_region_init_rom_device_nomigrate() =20 which only initialize the MemoryRegion and leave handling migration to the caller. diff --git a/include/system/memory.h b/include/system/memory.h index 8f8725ea2d..0562af3136 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1614,33 +1614,6 @@ bool memory_region_init_rom_nomigrate(MemoryRegion *= mr, uint64_t size, Error **errp); =20 -/** - * memory_region_init_rom_device_nomigrate: Initialize a ROM memory regio= n. - * Writes are handled via callbacks. - * - * Note that this function does not do anything to cause the data in the - * RAM side of the memory region to be migrated; that is the responsibility - * of the caller. - * - * @mr: the #MemoryRegion to be initialized. - * @owner: the object that tracks the region's reference count - * @ops: callbacks for write access handling (must not be NULL). - * @opaque: passed to the read and write callbacks of the @ops structure. - * @name: Region name, becomes part of RAMBlock name used in migration str= eam - * must be unique within any device - * @size: size of the region. - * @errp: pointer to Error*, to store an error if it happens. - * - * Return: true on success, else false setting @errp with error. - */ -bool memory_region_init_rom_device_nomigrate(MemoryRegion *mr, - Object *owner, - const MemoryRegionOps *ops, - void *opaque, - const char *name, - uint64_t size, - Error **errp); - /** * memory_region_init_iommu: Initialize a memory region of a custom type * that translates addresses diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/= coccinelle/memory-region-housekeeping.cocci index 29651ebde9..7f89e9712e 100644 --- a/scripts/coccinelle/memory-region-housekeeping.cocci +++ b/scripts/coccinelle/memory-region-housekeeping.cocci @@ -97,14 +97,6 @@ expression NAME; expression SIZE; expression ERRP; @@ --memory_region_init_rom_device_nomigrate(MR, NULL, OPS, OPAQUE, NAME, SIZE= , ERRP); -+memory_region_init_rom_device(MR, NULL, OPS, OPAQUE, NAME, SIZE, ERRP); - ... --vmstate_register_ram_global(MR); - - -// Device is owner -@@ typedef DeviceState; identifier device_fn, dev, obj; expression E1, E2, E3, E4, E5; diff --git a/system/memory.c b/system/memory.c index 4bf00d82bc..a9032fb2cf 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1748,32 +1748,6 @@ bool memory_region_init_rom_nomigrate(MemoryRegion *= mr, return true; } =20 -bool memory_region_init_rom_device_nomigrate(MemoryRegion *mr, - Object *owner, - const MemoryRegionOps *ops, - void *opaque, - const char *name, - uint64_t size, - Error **errp) -{ - Error *err =3D NULL; - assert(ops); - memory_region_init(mr, owner, name, size); - mr->ops =3D ops; - mr->opaque =3D opaque; - mr->terminates =3D true; - mr->rom_device =3D true; - mr->destructor =3D memory_region_destructor_ram; - mr->ram_block =3D qemu_ram_alloc(size, 0, mr, &err); - if (err) { - mr->size =3D int128_zero(); - object_unparent(OBJECT(mr)); - error_propagate(errp, err); - return false; - } - return true; -} - void memory_region_init_iommu(void *_iommu_mr, size_t instance_size, const char *mrtypename, @@ -3802,9 +3776,20 @@ bool memory_region_init_rom_device(MemoryRegion *mr, Error **errp) { DeviceState *owner_dev; + Error *err =3D NULL; =20 - if (!memory_region_init_rom_device_nomigrate(mr, owner, ops, opaque, - name, size, errp)) { + assert(ops); + memory_region_init(mr, owner, name, size); + mr->ops =3D ops; + mr->opaque =3D opaque; + mr->terminates =3D true; + mr->rom_device =3D true; + mr->destructor =3D memory_region_destructor_ram; + mr->ram_block =3D qemu_ram_alloc(size, 0, mr, &err); + if (err) { + mr->size =3D int128_zero(); + object_unparent(OBJECT(mr)); + error_propagate(errp, err); return false; } /* This will assert if owner is neither NULL nor a DeviceState. --=20 2.41.3 From nobody Sun Feb 8 17:37:03 2026 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=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769703677217183.63929473047403; Thu, 29 Jan 2026 08:21:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vlUkw-0004y3-K0; Thu, 29 Jan 2026 11:20:30 -0500 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 1vlUko-0004si-Tp for qemu-devel@nongnu.org; Thu, 29 Jan 2026 11:20:24 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vlUkk-0000eD-Rn for qemu-devel@nongnu.org; Thu, 29 Jan 2026 11:20:22 -0500 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 7932B596EC7; Thu, 29 Jan 2026 17:20:16 +0100 (CET) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id KG87sGy8sptH; Thu, 29 Jan 2026 17:20:14 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 5FF36596AC7; Thu, 29 Jan 2026 17:20:14 +0100 (CET) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org Cc: Peter Xu , Akihiko Odaki , Paolo Bonzini , Mark Cave-Ayland , Gerd Hoffmann , Max Filippov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Thu, 29 Jan 2026 17:20:14 +0100 (CET) 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=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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-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: 1769703680560154100 Content-Type: text/plain; charset="utf-8" Nothing else does this, convert to regular memory_region_init_rom(). Signed-off-by: BALATON Zoltan --- hw/display/cg3.c | 5 ++--- hw/display/tcx.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/display/cg3.c b/hw/display/cg3.c index 568d6048a6..61bdb0552e 100644 --- a/hw/display/cg3.c +++ b/hw/display/cg3.c @@ -282,8 +282,8 @@ static void cg3_initfn(Object *obj) SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); CG3State *s =3D CG3(obj); =20 - memory_region_init_rom_nomigrate(&s->rom, obj, "cg3.prom", - FCODE_MAX_ROM_SIZE, &error_fatal); + memory_region_init_rom(&s->rom, obj, "cg3.prom", FCODE_MAX_ROM_SIZE, + &error_fatal); sysbus_init_mmio(sbd, &s->rom); =20 memory_region_init_io(&s->reg, obj, &cg3_reg_ops, s, "cg3.reg", @@ -299,7 +299,6 @@ static void cg3_realizefn(DeviceState *dev, Error **err= p) char *fcode_filename; =20 /* FCode ROM */ - vmstate_register_ram_global(&s->rom); fcode_filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, CG3_ROM_FILE); if (fcode_filename) { ret =3D load_image_mr(fcode_filename, &s->rom); diff --git a/hw/display/tcx.c b/hw/display/tcx.c index 36cad82abd..16114b9bb8 100644 --- a/hw/display/tcx.c +++ b/hw/display/tcx.c @@ -756,8 +756,8 @@ static void tcx_initfn(Object *obj) SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); TCXState *s =3D TCX(obj); =20 - memory_region_init_rom_nomigrate(&s->rom, obj, "tcx.prom", - FCODE_MAX_ROM_SIZE, &error_fatal); + memory_region_init_rom(&s->rom, obj, "tcx.prom", FCODE_MAX_ROM_SIZE, + &error_fatal); sysbus_init_mmio(sbd, &s->rom); =20 /* 2/STIP : Stippler */ @@ -822,7 +822,6 @@ static void tcx_realizefn(DeviceState *dev, Error **err= p) vram_base =3D memory_region_get_ram_ptr(&s->vram_mem); =20 /* 10/ROM : FCode ROM */ - vmstate_register_ram_global(&s->rom); fcode_filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, TCX_ROM_FILE); if (fcode_filename) { ret =3D load_image_mr(fcode_filename, &s->rom); --=20 2.41.3 From nobody Sun Feb 8 17:37:03 2026 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=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769703665105582.2026094166425; Thu, 29 Jan 2026 08:21:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vlUkx-0004zh-Q3; Thu, 29 Jan 2026 11:20:32 -0500 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 1vlUkr-0004uZ-1q for qemu-devel@nongnu.org; Thu, 29 Jan 2026 11:20:25 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vlUkn-0000eQ-1y for qemu-devel@nongnu.org; Thu, 29 Jan 2026 11:20:24 -0500 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 78F13597382; Thu, 29 Jan 2026 17:20:17 +0100 (CET) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id xGT1tvwO02Ol; Thu, 29 Jan 2026 17:20:15 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 6AD55596AE0; Thu, 29 Jan 2026 17:20:15 +0100 (CET) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: <18a32ee5ba042bf56366053caf27ecd383d73468.1769703287.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 3/4] memory: Remove memory_region_init_rom_nomigrate() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org Cc: Peter Xu , Akihiko Odaki , Paolo Bonzini , Mark Cave-Ayland , Gerd Hoffmann , Max Filippov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Thu, 29 Jan 2026 17:20:15 +0100 (CET) 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=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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-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: 1769703670589154100 Content-Type: text/plain; charset="utf-8" All users were converted to memory_region_init_rom() so no longer needed. Signed-off-by: BALATON Zoltan --- docs/devel/memory.rst | 1 - include/system/memory.h | 26 ------------------- .../memory-region-housekeeping.cocci | 16 ------------ system/memory.c | 19 +++----------- 4 files changed, 3 insertions(+), 59 deletions(-) diff --git a/docs/devel/memory.rst b/docs/devel/memory.rst index 8558f70a42..0bb5acab21 100644 --- a/docs/devel/memory.rst +++ b/docs/devel/memory.rst @@ -113,7 +113,6 @@ have a special case where you need to manage the migrat= ion of the backing memory yourself, you can call the functions: =20 - memory_region_init_ram_nomigrate() -- memory_region_init_rom_nomigrate() =20 which only initialize the MemoryRegion and leave handling migration to the caller. diff --git a/include/system/memory.h b/include/system/memory.h index 0562af3136..7117699b10 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1588,32 +1588,6 @@ void memory_region_init_alias(MemoryRegion *mr, hwaddr offset, uint64_t size); =20 -/** - * memory_region_init_rom_nomigrate: Initialize a ROM memory region. - * - * This has the same effect as calling memory_region_init_ram_nomigrate() - * and then marking the resulting region read-only with - * memory_region_set_readonly(). - * - * Note that this function does not do anything to cause the data in the - * RAM side of the memory region to be migrated; that is the responsibility - * of the caller. - * - * @mr: the #MemoryRegion to be initialized. - * @owner: the object that tracks the region's reference count - * @name: Region name, becomes part of RAMBlock name used in migration str= eam - * must be unique within any device - * @size: size of the region. - * @errp: pointer to Error*, to store an error if it happens. - * - * Return: true on success, else false setting @errp with error. - */ -bool memory_region_init_rom_nomigrate(MemoryRegion *mr, - Object *owner, - const char *name, - uint64_t size, - Error **errp); - /** * memory_region_init_iommu: Initialize a memory region of a custom type * that translates addresses diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/= coccinelle/memory-region-housekeeping.cocci index 7f89e9712e..8ec9a06c18 100644 --- a/scripts/coccinelle/memory-region-housekeeping.cocci +++ b/scripts/coccinelle/memory-region-housekeeping.cocci @@ -16,17 +16,10 @@ expression E1, E2, E3, E4, E5; symbol true; @@ -( - memory_region_init_ram(E1, E2, E3, E4, E5); + memory_region_init_rom(E1, E2, E3, E4, E5); ... WHEN !=3D E1 - memory_region_set_readonly(E1, true); -| -- memory_region_init_ram_nomigrate(E1, E2, E3, E4, E5); -+ memory_region_init_rom_nomigrate(E1, E2, E3, E4, E5); - ... WHEN !=3D E1 -- memory_region_set_readonly(E1, true); -) =20 =20 @possible_memory_region_init_rom@ @@ -53,11 +46,7 @@ cocci.print_main("potential use of memory_region_init_ro= m*() in ", p) expression ROM, E1, E2, E3, E4; expression ALIAS, E5, E6, E7, E8; @@ -( memory_region_init_rom(ROM, E1, E2, E3, E4); -| - memory_region_init_rom_nomigrate(ROM, E1, E2, E3, E4); -) ... memory_region_init_alias(ALIAS, E5, E6, ROM, E7, E8); - memory_region_set_readonly(ALIAS, true); @@ -85,11 +74,6 @@ expression NAME; expression SIZE; expression ERRP; @@ --memory_region_init_rom_nomigrate(MR, NULL, NAME, SIZE, ERRP); -+memory_region_init_rom(MR, NULL, NAME, SIZE, ERRP); - ... --vmstate_register_ram_global(MR); -@@ expression MR; expression OPS; expression OPAQUE; diff --git a/system/memory.c b/system/memory.c index a9032fb2cf..b2b00ba7b4 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1733,21 +1733,6 @@ void memory_region_init_alias(MemoryRegion *mr, mr->alias_offset =3D offset; } =20 -bool memory_region_init_rom_nomigrate(MemoryRegion *mr, - Object *owner, - const char *name, - uint64_t size, - Error **errp) -{ - if (!memory_region_init_ram_flags_nomigrate(mr, owner, name, - size, 0, errp)) { - return false; - } - mr->readonly =3D true; - - return true; -} - void memory_region_init_iommu(void *_iommu_mr, size_t instance_size, const char *mrtypename, @@ -3752,9 +3737,11 @@ bool memory_region_init_rom(MemoryRegion *mr, { DeviceState *owner_dev; =20 - if (!memory_region_init_rom_nomigrate(mr, owner, name, size, errp)) { + if (!memory_region_init_ram_flags_nomigrate(mr, owner, name, + size, 0, errp)) { return false; } + mr->readonly =3D true; /* This will assert if owner is neither NULL nor a DeviceState. * We only want the owner here for the purposes of defining a * unique name for migration. TODO: Ideally we should implement --=20 2.41.3 From nobody Sun Feb 8 17:37:03 2026 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=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769703695319885.7906882051694; Thu, 29 Jan 2026 08:21:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vlUky-0004zi-Nq; Thu, 29 Jan 2026 11:20:33 -0500 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 1vlUkr-0004uc-CY for qemu-devel@nongnu.org; Thu, 29 Jan 2026 11:20:25 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vlUkm-0000ee-PD for qemu-devel@nongnu.org; Thu, 29 Jan 2026 11:20:24 -0500 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 8DC805969F0; Thu, 29 Jan 2026 17:20:18 +0100 (CET) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id dg_F6dMlAJcJ; Thu, 29 Jan 2026 17:20:16 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 775D7596EC6; Thu, 29 Jan 2026 17:20:16 +0100 (CET) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 4/4] memory: Remove memory_region_init_ram_nomigrate() MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org Cc: Peter Xu , Akihiko Odaki , Paolo Bonzini , Mark Cave-Ayland , Gerd Hoffmann , Max Filippov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Thu, 29 Jan 2026 17:20:16 +0100 (CET) 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=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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-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: 1769703699537154100 Content-Type: text/plain; charset="utf-8" This is rarely needed and those cases can use memory_region_init_ram_flags_nomigrate() instead which is now the only _nomigrate variant left. (Some of these may better be converted to use memory_region_init_ram() but I don't know so left them as they are.) Signed-off-by: BALATON Zoltan --- docs/devel/memory.rst | 8 +++---- hw/display/tcx.c | 5 ++-- hw/display/vga.c | 4 ++-- hw/sparc/sun4m.c | 15 +++++++----- hw/sparc64/sun4u.c | 9 ++++---- hw/xtensa/xtfpga.c | 4 ++-- include/system/memory.h | 23 ------------------- .../memory-region-housekeeping.cocci | 18 +-------------- system/memory.c | 13 ++--------- 9 files changed, 27 insertions(+), 72 deletions(-) diff --git a/docs/devel/memory.rst b/docs/devel/memory.rst index 0bb5acab21..9083b18f08 100644 --- a/docs/devel/memory.rst +++ b/docs/devel/memory.rst @@ -110,11 +110,9 @@ migrated: =20 For most devices and boards this is the correct thing. If you have a special case where you need to manage the migration of -the backing memory yourself, you can call the functions: - -- memory_region_init_ram_nomigrate() - -which only initialize the MemoryRegion and leave handling +the backing memory yourself, you can call the function +memory_region_init_ram_flags_nomigrate() +which only initializes the MemoryRegion and leaves handling migration to the caller. =20 The functions: diff --git a/hw/display/tcx.c b/hw/display/tcx.c index 16114b9bb8..0ff73f823a 100644 --- a/hw/display/tcx.c +++ b/hw/display/tcx.c @@ -815,8 +815,9 @@ static void tcx_realizefn(DeviceState *dev, Error **err= p) uint8_t *vram_base; char *fcode_filename; =20 - memory_region_init_ram_nomigrate(&s->vram_mem, OBJECT(s), "tcx.vram", - s->vram_size * (1 + 4 + 4), &error_fatal); + memory_region_init_ram_flags_nomigrate(&s->vram_mem, OBJECT(s), "tcx.v= ram", + s->vram_size * (1 + 4 + 4), 0, + &error_fatal); vmstate_register_ram_global(&s->vram_mem); memory_region_set_log(&s->vram_mem, true, DIRTY_MEMORY_VGA); vram_base =3D memory_region_get_ram_ptr(&s->vram_mem); diff --git a/hw/display/vga.c b/hw/display/vga.c index 59a65cbbff..ee7d97b5c2 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -2235,8 +2235,8 @@ bool vga_common_init(VGACommonState *s, Object *obj, = Error **errp) return false; } =20 - memory_region_init_ram_nomigrate(&s->vram, obj, "vga.vram", s->vram_si= ze, - &local_err); + memory_region_init_ram_flags_nomigrate(&s->vram, obj, "vga.vram", + s->vram_size, 0, &local_err); if (local_err) { error_propagate(errp, local_err); return false; diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 0c0d658d30..66a21ae86c 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -587,8 +587,10 @@ static void idreg_realize(DeviceState *ds, Error **err= p) IDRegState *s =3D MACIO_ID_REGISTER(ds); SysBusDevice *dev =3D SYS_BUS_DEVICE(ds); =20 - if (!memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.idre= g", - sizeof(idreg_data), errp)) { + if (!memory_region_init_ram_flags_nomigrate(&s->mem, OBJECT(ds), + "sun4m.idreg", + sizeof(idreg_data), + 0, errp)) { return; } =20 @@ -638,8 +640,8 @@ static void afx_realize(DeviceState *ds, Error **errp) AFXState *s =3D TCX_AFX(ds); SysBusDevice *dev =3D SYS_BUS_DEVICE(ds); =20 - if (!memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.afx", - 4, errp)) { + if (!memory_region_init_ram_flags_nomigrate(&s->mem, OBJECT(ds), + "sun4m.afx", 4, 0, errp)) { return; } =20 @@ -719,8 +721,9 @@ static void prom_realize(DeviceState *ds, Error **errp) PROMState *s =3D OPENPROM(ds); SysBusDevice *dev =3D SYS_BUS_DEVICE(ds); =20 - if (!memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4m.pro= m", - PROM_SIZE_MAX, errp)) { + if (!memory_region_init_ram_flags_nomigrate(&s->prom, OBJECT(ds), + "sun4m.prom", PROM_SIZE_MA= X, 0, + errp)) { return; } =20 diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 5d7787fc1a..0da0eef74c 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -455,8 +455,9 @@ static void prom_realize(DeviceState *ds, Error **errp) PROMState *s =3D OPENPROM(ds); SysBusDevice *dev =3D SYS_BUS_DEVICE(ds); =20 - if (!memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.pro= m", - PROM_SIZE_MAX, errp)) { + if (!memory_region_init_ram_flags_nomigrate(&s->prom, OBJECT(ds), + "sun4u.prom", PROM_SIZE_MA= X, 0, + errp)) { return; } =20 @@ -498,8 +499,8 @@ static void ram_realize(DeviceState *dev, Error **errp) RamDevice *d =3D SUN4U_RAM(dev); SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); =20 - memory_region_init_ram_nomigrate(&d->ram, OBJECT(d), "sun4u.ram", d->s= ize, - &error_fatal); + memory_region_init_ram_flags_nomigrate(&d->ram, OBJECT(d), "sun4u.ram", + d->size, 0, &error_fatal); vmstate_register_ram_global(&d->ram); sysbus_init_mmio(sbd, &d->ram); } diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index d427d68e50..b025cc53a8 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -163,8 +163,8 @@ static void xtfpga_net_init(MemoryRegion *address_space, sysbus_mmio_get_region(s, 1)); =20 ram =3D g_malloc(sizeof(*ram)); - memory_region_init_ram_nomigrate(ram, OBJECT(s), "open_eth.ram", 16 * = KiB, - &error_fatal); + memory_region_init_ram_flags_nomigrate(ram, OBJECT(s), "open_eth.ram", + 16 * KiB, 0, &error_fatal); vmstate_register_ram_global(ram); memory_region_add_subregion(address_space, buffers, ram); } diff --git a/include/system/memory.h b/include/system/memory.h index 7117699b10..d4793a08a7 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1374,29 +1374,6 @@ void memory_region_init_io(MemoryRegion *mr, const char *name, uint64_t size); =20 -/** - * memory_region_init_ram_nomigrate: Initialize RAM memory region. Acces= ses - * into the region will modify memory - * directly. - * - * @mr: the #MemoryRegion to be initialized. - * @owner: the object that tracks the region's reference count - * @name: Region name, becomes part of RAMBlock name used in migration str= eam - * must be unique within any device - * @size: size of the region. - * @errp: pointer to Error*, to store an error if it happens. - * - * Note that this function does not do anything to cause the data in the - * RAM memory region to be migrated; that is the responsibility of the cal= ler. - * - * Return: true on success, else false setting @errp with error. - */ -bool memory_region_init_ram_nomigrate(MemoryRegion *mr, - Object *owner, - const char *name, - uint64_t size, - Error **errp); - /** * memory_region_init_ram_flags_nomigrate: Initialize RAM memory region. * Accesses into the region will diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/= coccinelle/memory-region-housekeeping.cocci index 8ec9a06c18..40a8f7beb1 100644 --- a/scripts/coccinelle/memory-region-housekeeping.cocci +++ b/scripts/coccinelle/memory-region-housekeeping.cocci @@ -26,15 +26,9 @@ symbol true; expression E1, E2, E3, E4, E5; position p; @@ -( memory_region_init_ram@p(E1, E2, E3, E4, E5); ... memory_region_set_readonly(E1, true); -| - memory_region_init_ram_nomigrate@p(E1, E2, E3, E4, E5); - ... - memory_region_set_readonly(E1, true); -) @script:python@ p << possible_memory_region_init_rom.p; @@ @@ -52,7 +46,7 @@ expression ALIAS, E5, E6, E7, E8; - memory_region_set_readonly(ALIAS, true); =20 =20 -// Replace by-hand memory_region_init_ram_nomigrate/vmstate_register_ram +// Replace by-hand memory_region_init_ram/vmstate_register_ram // code sequences with use of the new memory_region_init_ram function. // Similarly for the _rom and _rom_device functions. // We don't try to replace sequences with a non-NULL owner, because @@ -64,16 +58,6 @@ expression NAME; expression SIZE; expression ERRP; @@ --memory_region_init_ram_nomigrate(MR, NULL, NAME, SIZE, ERRP); -+memory_region_init_ram(MR, NULL, NAME, SIZE, ERRP); - ... --vmstate_register_ram_global(MR); -@@ -expression MR; -expression NAME; -expression SIZE; -expression ERRP; -@@ expression MR; expression OPS; expression OPAQUE; diff --git a/system/memory.c b/system/memory.c index b2b00ba7b4..921e96554b 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1572,16 +1572,6 @@ void memory_region_init_io(MemoryRegion *mr, mr->terminates =3D true; } =20 -bool memory_region_init_ram_nomigrate(MemoryRegion *mr, - Object *owner, - const char *name, - uint64_t size, - Error **errp) -{ - return memory_region_init_ram_flags_nomigrate(mr, owner, name, - size, 0, errp); -} - bool memory_region_init_ram_flags_nomigrate(MemoryRegion *mr, Object *owner, const char *name, @@ -3690,7 +3680,8 @@ bool memory_region_init_ram(MemoryRegion *mr, { DeviceState *owner_dev; =20 - if (!memory_region_init_ram_nomigrate(mr, owner, name, size, errp)) { + if (!memory_region_init_ram_flags_nomigrate(mr, owner, name, + size, 0, errp)) { return false; } /* This will assert if owner is neither NULL nor a DeviceState. --=20 2.41.3