From nobody Mon Nov 23 04:34:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@fujitsu.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=pass(p=reject dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1794533784; cv=none; d=zohomail.com; s=zohoarc; b=RyN0n3ql7XC5T87TBAMPCdnXEKOIEk3aEuSG7HdROYBxCd3zXBF3LaGNqO3+e4tr9xvVDvTvEiWBPl6wpn8SF/CMvp0FipN33Ma42+z/9X7q5yf+Cx6tFT/NLQiUcTh6YML/09WQqOgDg3io0j3eZQbrkSolGND83kYRUum9Eps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794533784; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=1s50tSW6SwplTfeWv2OerD8a2/XJ7duCmxTtAWJhjcI=; b=jcVP1X/nIPNPXY7kJXogD7Au1nJ8vuLHosJ1c8Eolg2M7oMADmvO+y9m/RBYJTLPzXjwE06osvoiWH96wkNyxoCbaBBhK4NhKF7nQKiPh3rhuzTwDt187O8/T+6A0QMwOLqndO8SjEyy/Cx6pOa9Tl4mfz6WbCutQRn1XcDhKQY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@fujitsu.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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794533784514309.62369659374974; Thu, 12 Nov 2026 17:36:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRgCB-0001q5-CU; Thu, 12 Nov 2026 20:35:15 -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 1xRgC9-0001pZ-Pq; Thu, 12 Nov 2026 20:35:13 -0500 Received: from esa1.hc1455-7.c3s2.iphmx.com ([207.54.90.47]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xRgC7-0003Eq-U7; Thu, 12 Nov 2026 20:35:13 -0500 Received: from gmgwnl01.global.fujitsu.com (HELO mgmgwnl01.global.fujitsu.com) ([52.143.17.124]) by esa1.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2026 10:34:58 +0900 Received: from az2nlsmgm4.fujitsu.com (unknown [10.150.26.204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mgmgwnl01.global.fujitsu.com (Postfix) with ESMTPS id 82E311443; Fri, 13 Nov 2026 01:34:58 +0000 (UTC) Received: from az2nlsmom4.fujitsu.com (unknown [10.150.26.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by az2nlsmgm4.fujitsu.com (Postfix) with ESMTPS id 37A79100046B; Fri, 13 Nov 2026 01:34:58 +0000 (UTC) Received: from [127.0.1.1] (unknown [10.124.178.20]) by az2nlsmom4.fujitsu.com (Postfix) with ESMTP id B23CE2000102; Fri, 13 Nov 2026 01:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1794533712; x=1826069712; h=from:date:subject:mime-version:content-transfer-encoding: message-id:to:cc; bh=zQ+i+BTPG4rogOOKQ86sjLDzrXBckQVkjEriQzYWGhM=; b=G8ciQFcuOnsW9P+2ZhT8BcN/KYGF0ognUnVnsa84NRF+1K5EbKi3r2Rs oXsrTjpLmGS1dGqg5wvsMisu1cTS20PFfq3siDlEVFEzahP7cFBztI4mJ Vc2YdLB1fwKPbm7Vd5lXKS/qbJtKNHHFRumNPsAjiYmDhGi/gGVEPIuMk 5RiHfuc8x961OSd90TZikgPMWTVal73r88HOvKPeA6tpfM0KvLf44guOo ct/rKjT75b7TWvR7BW4guy2Eu8qARjPlV0IJTX0Cu5fIOhVMV4GedP54z Zn/6//oJGgg0BglbxmTWfHAjVO9inyE8+TXQuXcIEYtEHNBu8qhwAjkuf w==; X-CSE-ConnectionGUID: RhkR+4FWQDeq9Y5EweC1aA== X-CSE-MsgGUID: 6tz7e144TbuUXi1cM45uVw== X-IronPort-AV: E=McAfee;i="6800,10657,11964"; a="261622019" X-IronPort-AV: E=Sophos;i="6.27,210,1786978800"; d="scan'208";a="261622019" Date: Fri, 13 Nov 2026 10:34:47 +0900 Subject: [PATCH] vl: complete memory size from memdev before creating memmap MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261113-fix-complete-memdev-size-v1-1-58e8a16bdc61@fujitsu.com> X-B4-Tracking: v=1; b=H4sIADZp9moC/yXMUQrCQAyE4auUPBvYtKLiVcSHmh014rZl0xax9 O6u+vjBzL+QIxucjtVCGbO59V2BbCrSe9vdwBaLqQ71TkQavtqLtU/DEyM4IUXM7PYGb6MGPYR 9Gxuhch8yyvaXPp3/9unygI7fHq3rB5A686x8AAAA X-Change-ID: 20261113-fix-complete-memdev-size-4dc0c807ad31 To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: Paolo Bonzini , Peter Maydell , Kohei Enju X-Mailer: b4 0.16.0 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=207.54.90.47; envelope-from=enju.kohei@fujitsu.com; helo=esa1.hc1455-7.c3s2.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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: , Reply-to: Kohei Enju From: Kohei Enju via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1794533787050158500 When -machine memory-backend=3Dram0 is used and '-m' option is omitted with a KVM virt machine as follows: qemu-system-aarch64 \ -enable-kvm \ -machine virt,memory-backend=3Dram0 \ -object memory-backend-memfd,id=3Dram0,size=3D256G,share=3Don \ ... virt_set_memmap() creates memmap based on the default memory size ignoring the specified size property of the memory-backend-* object. This is because at this stage memory.size is not initialized by the size property specified by the memory-backend-* object. Since the memory size is not taken into account, when the memory size is larger than about 255 GiB, this unexpectedly hides PCI ECAM space with system RAM. Consequently guests could fail to find PCI devices, failing to boot when they are dependent on those PCI devices. When '-m' option is omitted, fix this by getting the size of the backend identified by ram_memdev_id, and completing memory.size with this value before creating the memmap. Afterwards, machine_set_mem() decides ram_size and maxram_size based on the completed memory.size. Fixes: d349f92f78d2 ("vl: allow not specifying size in -m when using -M mem= ory-backend") Signed-off-by: Kohei Enju --- system/vl.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/system/vl.c b/system/vl.c index e7b759d54428..d2670b85f23b 100644 --- a/system/vl.c +++ b/system/vl.c @@ -34,6 +34,7 @@ #include "hw/core/qdev-properties.h" #include "qapi/compat-policy.h" #include "qapi/error.h" +#include "qapi/qobject-output-visitor.h" #include "qobject/qdict.h" #include "qobject/qstring.h" #include "qobject/qjson.h" @@ -1810,6 +1811,47 @@ static void qemu_apply_legacy_machine_options(QDict = *qdict) } } =20 +static void qemu_complete_machine_memdev_size(void) +{ + QDict *backend_prop, *memory_prop; + g_autofree char *size_str =3D NULL; + QObject *qobj =3D NULL; + ObjectOption *opt; + uint64_t size; + Visitor *v; + + if (have_custom_ram_size || !ram_memdev_id) { + return; + } + + QTAILQ_FOREACH(opt, &object_opts, next) { + ObjectOptions *options =3D opt->opts; + const char *type =3D ObjectType_str(options->qom_type); + + if (g_str_equal(options->id, ram_memdev_id) && + g_str_has_prefix(type, "memory-backend-")) { + v =3D qobject_output_visitor_new(&qobj); + visit_type_ObjectOptions(v, NULL, &options, &error_abort); + visit_complete(v, &qobj); + visit_free(v); + + backend_prop =3D qobject_to(QDict, qobj); + size =3D qdict_get_uint(backend_prop, "size"); + size_str =3D g_strdup_printf("%" PRIu64, size); + + memory_prop =3D qdict_get_qdict(machine_opts_dict, "memory"); + assert(memory_prop); + qdict_put_str(memory_prop, "size", size_str); + + qobject_unref(qobj); + return; + } + } + + error_report("Memory backend '%s' not found", ram_memdev_id); + exit(EXIT_FAILURE); +} + static void object_option_foreach_add(bool (*type_opt_predicate)(const cha= r *)) { ObjectOption *opt, *next; @@ -3821,6 +3863,7 @@ void qemu_init(int argc, char **argv) qemu_create_early_backends(); =20 qemu_apply_legacy_machine_options(machine_opts_dict); + qemu_complete_machine_memdev_size(); qemu_apply_machine_options(machine_opts_dict); qobject_unref(machine_opts_dict); phase_advance(PHASE_MACHINE_CREATED); --- base-commit: 29760efaf96bbe5928f8111881eddbf5ac06439e change-id: 20261113-fix-complete-memdev-size-4dc0c807ad31 Best regards, -- =20 Kohei Enju