From nobody Wed Aug 26 14:17:39 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=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178305631822460.99805617629636; Thu, 2 Jul 2026 22:25:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wfWMg-0005aq-Kd; Fri, 03 Jul 2026 01:23:02 -0400 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 1wfWMZ-0005WO-VZ; Fri, 03 Jul 2026 01:22:56 -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 1wfWMW-0005vx-Kz; Fri, 03 Jul 2026 01:22:55 -0400 Received: from h183.csg.ci.i.u-tokyo.ac.jp (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6635LT8P018373 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Jul 2026 14:21:43 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=yI7z983L2jKLplCj01xQZlmdHreHtJMxOkjcK5D3Uhg=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1783056104; v=1; b=eA+u+b5Pn/F6Fsu4XPL2Fil+YxYg1ZkQ4++IfHV0CZAegdmINv/jec+3gJCku6sS 1Kgpnin6bB3a3dKwGxXYGzMFW0yn2kSvLDRJhbYW6gNMl45KzgJUA5tKmCHwgCSk f+IEKE214HwMehUnBmsvSTUaJXjU9iJmVJ3UYsaxlKNbAnQckH5wIPNhsyk7jwuH ufv2SYJDdz1XC7HnPTzFKX/oKmtFL9DMPxfozld5JtnfqYEh5V3JK6epFJQYzkIY 2Oj/IWFYlmHYiy5KblnCVeIwkAuOfStcpVUtczbk42Y87GNMCuDCMkNBm1h34uA6 fqVOF77PetcRnkg4/nn5fw== From: Akihiko Odaki Date: Fri, 03 Jul 2026 14:19:18 +0900 Subject: [PATCH v2 2/7] hw/nvram/fw_cfg: Avoid resizing RAM at runtime MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260703-ram-v2-2-7f07fc06fba9@rsg.ci.i.u-tokyo.ac.jp> References: <20260703-ram-v2-0-7f07fc06fba9@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20260703-ram-v2-0-7f07fc06fba9@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Kevin Wolf , Hanna Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Zhao Liu , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , Peter Xu , Fabiano Rosas , Paolo Bonzini , Reinoud Zandijk , Marcelo Tosatti , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, Gerd Hoffmann , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Igor Mammedov , Ani Sinha , Peter Maydell , Richard Henderson , Song Gao , Bibo Mao , Jiaxun Yang , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Sunil V L , Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , linux-edac@vger.kernel.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org, Akihiko Odaki X-Mailer: b4 0.16-dev-925f5 X-Developer-Signature: v=1; a=openpgp-sha256; l=19046; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=ccy6opZLwUXKw1fFsJIq/3ZXHcSwmcArvoTXP9WAi+0=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ5a72z3zK461+97OmDpTvi9l0bklb0+z3bYv1f54sjWfX WrvcfHojlIWBjEuBlkxRZaUot3cGtG1nwoT4ltg5rAygQxh4OIUgInEKzD89zaprCy8/LN69qYr CxdKmMr9Pi0Xv04h877g7W097KrC0xl+s0tJXjefVnx68x7j59pp5zKvXOdS57/pdO30fYu5vIE nGAE= X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C 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=lists1p.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, 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: 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: 1783056319509158500 There is a chance that migration is aborted when the following conditions are met: 1. The machine has not booted yet, or devices have been hotplugged since the last boot. 2. The machine is (re)booting. 3. Migration is running concurrently. This is because the size of ACPI data is determined after the firmware configures the machine at boot time, and that may change the size of backing RAM. This aborts migration if the RAM is concurrently being copied. It is rare that all three conditions are met at the same time, but migrating after device hotplug and migrating during reboot are supported, so ideally their combination should be supported. To support this scenario, allocate RAM for the maximum ACPI data size up front, while exposing only the current ACPI data size through fw_cfg. This avoids runtime RAMBlock resize during ACPI rebuilds and lets the memory and migration code handle the RAMBlock like any other fixed-size RAMBlock. The ACPI data still uses resizable RAM for migration compatibility. The destination may resize it while loading migration streams from older QEMU versions, but it immediately grows the RAM back to the maximum size. This destination-side resize does not cause migration to abort. Signed-off-by: Akihiko Odaki --- include/hw/core/loader.h | 1 + include/hw/nvram/fw_cfg.h | 4 ++- hw/acpi/ghes.c | 6 ++-- hw/acpi/vmgenid.c | 1 + hw/arm/virt-acpi-build.c | 3 +- hw/core/loader.c | 14 +++++--- hw/display/ramfb.c | 2 +- hw/i386/acpi-build.c | 3 +- hw/isa/lpc_ich9.c | 2 ++ hw/loongarch/virt-acpi-build.c | 3 +- hw/misc/vmcoreinfo.c | 3 +- hw/nvram/fw_cfg.c | 74 ++++++++++++++++++++++++++------------= ---- hw/riscv/virt-acpi-build.c | 3 +- 13 files changed, 77 insertions(+), 42 deletions(-) diff --git a/include/hw/core/loader.h b/include/hw/core/loader.h index d9431e8a8d12..d563acc1f1dd 100644 --- a/include/hw/core/loader.h +++ b/include/hw/core/loader.h @@ -259,6 +259,7 @@ void pstrcpy_targphys(const char *name, hwaddr dest, int buf_size, const char *source); =20 +void rom_resize(const MemoryRegion *mr, size_t len); ssize_t rom_add_file(const char *file, const char *fw_dir, hwaddr addr, int32_t bootindex, bool has_option_rom, MemoryRegion *mr, AddressSpace *= as); diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 6aad9aad7694..201b33434a3c 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -240,6 +240,7 @@ void fw_cfg_add_file(FWCfgState *s, const char *filenam= e, void *data, * @callback_opaque: argument to be passed into callback function * @data: pointer to start of item data * @len: size of item data + * @max_len: maximum size of item data * @read_only: is file read only * * Add a new NAMED fw_cfg item as a raw "blob" of the given size. The data @@ -258,7 +259,8 @@ void fw_cfg_add_file_callback(FWCfgState *s, const char= *filename, FWCfgCallback select_cb, FWCfgWriteCallback write_cb, void *callback_opaque, - void *data, size_t len, bool read_only); + void *data, size_t len, size_t max_len, + bool read_only); =20 /** * fw_cfg_modify_file: diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index b2d5e3499320..9679059100e5 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -415,11 +415,13 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgSt= ate *s, =20 if (ags->use_hest_addr) { fw_cfg_add_file_callback(s, ACPI_HEST_ADDR_FW_CFG_FILE, NULL, NULL, - NULL, &(ags->hest_addr_le), sizeof(ags->hest_addr_le), false); + NULL, &(ags->hest_addr_le), + sizeof(ags->hest_addr_le), sizeof(ags->hest_addr_le), false); } else { /* Create a read-write fw_cfg file for Address */ fw_cfg_add_file_callback(s, ACPI_HW_ERROR_ADDR_FW_CFG_FILE, NULL, = NULL, - NULL, &(ags->hw_error_le), sizeof(ags->hw_error_le), false); + NULL, &(ags->hw_error_le), + sizeof(ags->hw_error_le), sizeof(ags->hw_error_le), false); } } =20 diff --git a/hw/acpi/vmgenid.c b/hw/acpi/vmgenid.c index 27cc0128d117..c2a4eb7ac394 100644 --- a/hw/acpi/vmgenid.c +++ b/hw/acpi/vmgenid.c @@ -130,6 +130,7 @@ void vmgenid_add_fw_cfg(VmGenIdState *vms, FWCfgState *= s, GArray *guid) /* Create a read-write fw_cfg file for Address */ fw_cfg_add_file_callback(s, VMGENID_ADDR_FW_CFG_FILE, NULL, NULL, NULL, vms->vmgenid_addr_le, + ARRAY_SIZE(vms->vmgenid_addr_le), ARRAY_SIZE(vms->vmgenid_addr_le), false); } =20 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 99490aa7b1fb..9e3ae08f1f8e 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -32,6 +32,7 @@ #include "qemu/error-report.h" #include "trace.h" #include "hw/core/cpu.h" +#include "hw/core/loader.h" #include "hw/acpi/acpi-defs.h" #include "hw/acpi/acpi.h" #include "hw/acpi/pcihp.h" @@ -1469,7 +1470,7 @@ static void acpi_ram_update(MemoryRegion *mr, GArray = *data) =20 /* Make sure RAM size is correct - in case it got changed * e.g. by migration */ - memory_region_ram_resize(mr, size, &error_abort); + rom_resize(mr, size); =20 memcpy(memory_region_get_ram_ptr(mr), data->data, size); memory_region_set_dirty(mr, 0, size); diff --git a/hw/core/loader.c b/hw/core/loader.c index 5cbfba0a86d2..14d56f52e4ec 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -1051,10 +1051,14 @@ static void rom_insert(Rom *rom) QTAILQ_INSERT_TAIL(&roms, rom, next); } =20 -static void fw_cfg_resized(const char *id, uint64_t length, void *host) +void rom_resize(const MemoryRegion *mr, size_t len) { if (fw_cfg) { - fw_cfg_modify_file(fw_cfg, id + strlen("/rom@"), host, length); + const char *name =3D memory_region_name(mr); + void *host =3D memory_region_get_ram_ptr(mr); + + assert(len <=3D memory_region_size(mr)); + fw_cfg_modify_file(fw_cfg, name + strlen("/rom@"), host, len); } } =20 @@ -1064,8 +1068,8 @@ static void *rom_set_mr(Rom *rom, Object *owner, cons= t char *name, bool ro) =20 rom->mr =3D g_malloc(sizeof(*rom->mr)); memory_region_init_resizeable_ram(rom->mr, owner, name, - rom->datasize, rom->romsize, - fw_cfg_resized, + rom->romsize, rom->romsize, + NULL, &error_fatal); memory_region_set_readonly(rom->mr, ro); vmstate_register_ram_global(rom->mr); @@ -1196,7 +1200,7 @@ MemoryRegion *rom_add_blob(const char *name, const vo= id *blob, size_t len, =20 fw_cfg_add_file_callback(fw_cfg, fw_file_name, fw_callback, NULL, callback_opaque, - data, rom->datasize, read_only); + data, rom->datasize, rom->romsize, read_o= nly); } return mr; } diff --git a/hw/display/ramfb.c b/hw/display/ramfb.c index f477bdcc2186..3c4be28072fb 100644 --- a/hw/display/ramfb.c +++ b/hw/display/ramfb.c @@ -154,6 +154,6 @@ RAMFBState *ramfb_setup(bool romfile, Error **errp) } fw_cfg_add_file_callback(fw_cfg, "etc/ramfb", NULL, ramfb_fw_cfg_write, s, - &s->cfg, sizeof(s->cfg), false); + &s->cfg, sizeof(s->cfg), sizeof(s->cfg), fals= e); return s; } diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 2ee061558c08..a83a9893a827 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -30,6 +30,7 @@ #include "hw/pci/pci_bridge.h" #include "hw/cxl/cxl.h" #include "hw/core/cpu.h" +#include "hw/core/loader.h" #include "target/i386/cpu.h" #include "hw/timer/hpet.h" #include "hw/acpi/acpi-defs.h" @@ -2138,7 +2139,7 @@ static void acpi_ram_update(MemoryRegion *mr, GArray = *data) uint32_t size =3D acpi_data_len(data); =20 /* Make sure RAM size is correct - in case it got changed e.g. by migr= ation */ - memory_region_ram_resize(mr, size, &error_abort); + rom_resize(mr, size); =20 memcpy(memory_region_get_ram_ptr(mr), data->data, size); memory_region_set_dirty(mr, 0, size); diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index 9cec18a378c2..fe5c8d6f44f4 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -449,11 +449,13 @@ static void ich9_lpc_pm_init(ICH9LPCState *lpc) NULL, NULL, NULL, lpc->smi_guest_features_le, sizeof lpc->smi_guest_features_le, + sizeof lpc->smi_guest_features_le, false); fw_cfg_add_file_callback(fw_cfg, "etc/smi/features-ok", smi_features_ok_callback, NULL, lpc, &lpc->smi_features_ok, sizeof lpc->smi_features_ok, + sizeof lpc->smi_features_ok, true); } } diff --git a/hw/loongarch/virt-acpi-build.c b/hw/loongarch/virt-acpi-build.c index a0b445f297b4..4be390189637 100644 --- a/hw/loongarch/virt-acpi-build.c +++ b/hw/loongarch/virt-acpi-build.c @@ -11,6 +11,7 @@ #include "qemu/bitmap.h" #include "hw/pci/pci.h" #include "hw/core/cpu.h" +#include "hw/core/loader.h" #include "target/loongarch/cpu.h" #include "hw/acpi/acpi-defs.h" #include "hw/acpi/acpi.h" @@ -630,7 +631,7 @@ static void acpi_ram_update(MemoryRegion *mr, GArray *d= ata) * Make sure RAM size is correct - in case it got changed * e.g. by migration */ - memory_region_ram_resize(mr, size, &error_abort); + rom_resize(mr, size); =20 memcpy(memory_region_get_ram_ptr(mr), data->data, size); memory_region_set_dirty(mr, 0, size); diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c index 9c2e9005ad32..8cb1763c1a44 100644 --- a/hw/misc/vmcoreinfo.c +++ b/hw/misc/vmcoreinfo.c @@ -59,7 +59,8 @@ static void vmcoreinfo_realize(DeviceState *dev, Error **= errp) =20 fw_cfg_add_file_callback(fw_cfg, FW_CFG_VMCOREINFO_FILENAME, NULL, fw_cfg_vmci_write, s, - &s->vmcoreinfo, sizeof(s->vmcoreinfo), false); + &s->vmcoreinfo, sizeof(s->vmcoreinfo), + sizeof(s->vmcoreinfo), false); =20 /* * This device requires to register a global reset because it is diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index f4e3e50224ca..03fb4b569fe7 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -60,6 +60,7 @@ =20 struct FWCfgEntry { uint32_t len; + uint32_t max_len; bool allow_write; uint8_t *data; void *callback_opaque; @@ -604,20 +605,8 @@ bool fw_cfg_dma_enabled(void *opaque) return s->dma_enabled; } =20 -static bool fw_cfg_acpi_mr_restore(void *opaque) +static MemoryRegion *fw_cfg_get_mr(FWCfgState *s, uint16_t key) { - FWCfgState *s =3D opaque; - bool mr_aligned; - - mr_aligned =3D QEMU_IS_ALIGNED(s->table_mr_size, qemu_real_host_page_s= ize()) && - QEMU_IS_ALIGNED(s->linker_mr_size, qemu_real_host_page_si= ze()) && - QEMU_IS_ALIGNED(s->rsdp_mr_size, qemu_real_host_page_size= ()); - return !mr_aligned; -} - -static void fw_cfg_update_mr(FWCfgState *s, uint16_t key, size_t size) -{ - MemoryRegion *mr; ram_addr_t offset; int arch =3D !!(key & FW_CFG_ARCH_LOCAL); void *ptr; @@ -626,31 +615,57 @@ static void fw_cfg_update_mr(FWCfgState *s, uint16_t = key, size_t size) assert(key < fw_cfg_max_entry(s)); =20 ptr =3D s->entries[arch][key].data; - mr =3D memory_region_from_host(ptr, &offset); + return memory_region_from_host(ptr, &offset); +} + +static bool fw_cfg_pre_load_errp(void *opaque, Error **errp) +{ + FWCfgState *s =3D opaque; + + s->table_mr_size =3D UINT64_MAX; + s->linker_mr_size =3D UINT64_MAX; + s->rsdp_mr_size =3D UINT64_MAX; =20 - memory_region_ram_resize(mr, size, &error_abort); + return true; } =20 -static int fw_cfg_acpi_mr_restore_post_load(void *opaque, int version_id) +static bool fw_cfg_post_load_errp(void *opaque, int version_id, Error **er= rp) { FWCfgState *s =3D opaque; int i, index; + uint64_t *size; =20 assert(s->files); =20 index =3D be32_to_cpu(s->files->count); =20 for (i =3D 0; i < index; i++) { + uint16_t key =3D FW_CFG_FILE_FIRST + i; + MemoryRegion *mr; + int arch =3D !!(key & FW_CFG_ARCH_LOCAL); + if (!strcmp(s->files->f[i].name, ACPI_BUILD_TABLE_FILE)) { - fw_cfg_update_mr(s, FW_CFG_FILE_FIRST + i, s->table_mr_size); + size =3D &s->table_mr_size; } else if (!strcmp(s->files->f[i].name, ACPI_BUILD_LOADER_FILE)) { - fw_cfg_update_mr(s, FW_CFG_FILE_FIRST + i, s->linker_mr_size); + size =3D &s->linker_mr_size; } else if (!strcmp(s->files->f[i].name, ACPI_BUILD_RSDP_FILE)) { - fw_cfg_update_mr(s, FW_CFG_FILE_FIRST + i, s->rsdp_mr_size); + size =3D &s->rsdp_mr_size; + } else { + continue; } + + mr =3D fw_cfg_get_mr(s, key); + + if (*size =3D=3D UINT64_MAX) { + *size =3D memory_region_size(mr); + } + + rom_resize(mr, *size); + memory_region_ram_resize(mr, s->entries[arch][key].max_len, + &error_abort); } =20 - return 0; + return true; } =20 static const VMStateDescription vmstate_fw_cfg_dma =3D { @@ -666,8 +681,6 @@ static const VMStateDescription vmstate_fw_cfg_acpi_mr = =3D { .name =3D "fw_cfg/acpi_mr", .version_id =3D 1, .minimum_version_id =3D 1, - .needed =3D fw_cfg_acpi_mr_restore, - .post_load =3D fw_cfg_acpi_mr_restore_post_load, .fields =3D (const VMStateField[]) { VMSTATE_UINT64(table_mr_size, FWCfgState), VMSTATE_UINT64(linker_mr_size, FWCfgState), @@ -680,6 +693,8 @@ static const VMStateDescription vmstate_fw_cfg =3D { .name =3D "fw_cfg", .version_id =3D 2, .minimum_version_id =3D 1, + .pre_load_errp =3D fw_cfg_pre_load_errp, + .post_load_errp =3D fw_cfg_post_load_errp, .fields =3D (const VMStateField[]) { VMSTATE_UINT16(cur_entry, FWCfgState), VMSTATE_UINT16_HACK(cur_offset, FWCfgState, is_version_1), @@ -697,7 +712,7 @@ static void fw_cfg_add_bytes_callback(FWCfgState *s, ui= nt16_t key, FWCfgCallback select_cb, FWCfgWriteCallback write_cb, void *callback_opaque, - void *data, size_t len, + void *data, size_t len, size_t max_l= en, bool read_only) { int arch =3D !!(key & FW_CFG_ARCH_LOCAL); @@ -709,6 +724,7 @@ static void fw_cfg_add_bytes_callback(FWCfgState *s, ui= nt16_t key, =20 s->entries[arch][key].data =3D data; s->entries[arch][key].len =3D (uint32_t)len; + s->entries[arch][key].max_len =3D (uint32_t)max_len; s->entries[arch][key].select_cb =3D select_cb; s->entries[arch][key].write_cb =3D write_cb; s->entries[arch][key].callback_opaque =3D callback_opaque; @@ -737,7 +753,7 @@ static void *fw_cfg_modify_bytes_read(FWCfgState *s, ui= nt16_t key, void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len) { trace_fw_cfg_add_bytes(key, trace_key_name(key), len); - fw_cfg_add_bytes_callback(s, key, NULL, NULL, NULL, data, len, true); + fw_cfg_add_bytes_callback(s, key, NULL, NULL, NULL, data, len, len, tr= ue); } =20 void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value) @@ -838,7 +854,8 @@ void fw_cfg_add_file_callback(FWCfgState *s, const cha= r *filename, FWCfgCallback select_cb, FWCfgWriteCallback write_cb, void *callback_opaque, - void *data, size_t len, bool read_only) + void *data, size_t len, size_t max_len, + bool read_only) { int i, index, count; size_t dsize; @@ -889,7 +906,7 @@ void fw_cfg_add_file_callback(FWCfgState *s, const cha= r *filename, =20 fw_cfg_add_bytes_callback(s, FW_CFG_FILE_FIRST + index, select_cb, write_cb, - callback_opaque, data, len, + callback_opaque, data, len, max_len, read_only); =20 s->files->f[index].size =3D cpu_to_be32(len); @@ -904,7 +921,8 @@ void fw_cfg_add_file_callback(FWCfgState *s, const cha= r *filename, void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data, size_t len) { - fw_cfg_add_file_callback(s, filename, NULL, NULL, NULL, data, len, tru= e); + fw_cfg_add_file_callback(s, filename, NULL, NULL, NULL, + data, len, len, true); } =20 void *fw_cfg_modify_file(FWCfgState *s, const char *filename, @@ -930,7 +948,7 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *fil= ename, assert(index < fw_cfg_file_slots(s)); =20 /* add new one */ - fw_cfg_add_file_callback(s, filename, NULL, NULL, NULL, data, len, tru= e); + fw_cfg_add_file(s, filename, data, len); return NULL; } =20 diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 413d47d70ef1..10825fa37769 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -29,6 +29,7 @@ #include "hw/acpi/aml-build.h" #include "hw/acpi/pci.h" #include "hw/acpi/utils.h" +#include "hw/core/loader.h" #include "hw/intc/riscv_aclint.h" #include "hw/nvram/fw_cfg_acpi.h" #include "hw/pci-host/gpex.h" @@ -961,7 +962,7 @@ static void acpi_ram_update(MemoryRegion *mr, GArray *d= ata) * Make sure RAM size is correct - in case it got changed * e.g. by migration */ - memory_region_ram_resize(mr, size, &error_abort); + rom_resize(mr, size); =20 memcpy(memory_region_get_ram_ptr(mr), data->data, size); memory_region_set_dirty(mr, 0, size); --=20 2.54.0