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 7095B606A31C for ; Mon, 30 Nov 2026 04:59:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=nongnu.org header.i=@nongnu.org header.a=rsa-sha256 header.s=lists1p-gnu-org header.b=csWo5ohj; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=nW/YIJVM DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nongnu.org; s=lists1p-gnu-org; h=From:In-Reply-To:MIME-Version:References:Subject:To: Date; bh=foskQa1SpJnkb4V2/VKcgyhksuM8PKZgkZp+uqjTaeE=; b=csWo5ohjSrpB9Qx6/DJf XoPKW/7aOa2UZT8X0F8j646emBySGre+z09JM5eyM1k+HP0olGq4DMA8L654mOMue+tHF20dd5k1v 1yyZh78jlFpAv5BhVg9w1RXqO4ECNEJw85qn4p4qb8Y8TFGnD/N9GS4lq+gBbkuy1w30SU81S0K25 78Pdr8RQGkkMSliwdcVrG6te5FOTE28gN5gmjPJq7pEZjgWX3PriNxYbZdviB8hkPB1CBb9Xx/PZA 3VriSWmGV7tUE5zEtY8u68SrzPFDwJyQuq0pdGI3O5iKHZviTVPb9xgCFPD3tF+3UyLETe7f0fAXB 3enppAjh1wNq6w==; Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xXtTx-0004Uy-Jx; Sun, 29 Nov 2026 23:59:18 -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 1xXtTv-0004Ue-E1; Sun, 29 Nov 2026 23:59:15 -0500 Received: from esa10.hc1455-7.c3s2.iphmx.com ([139.138.36.225]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xXtTt-0007LB-D6; Sun, 29 Nov 2026 23:59:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1796014753; x=1827550753; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=0dW5LgF5yN9WjTCTfFYbrR3OhF4Qx3hL6O/47dhWfX8=; b=nW/YIJVMBaFuoKi960PWcQdtYeWAhAFZfr0t2ONG7qLxQAZ0CgDjov3P zUWaXyXqD4ESo5J/vEPeIRFClG/e1HlxwF8VTMawOhbUkSEHQIMQFLeWQ VhVWhBndjYVdUZEzXPH9CPx7voagLrAd5JKqdeUUdI5YyVm7hOGF4Ciyc xdPLO6hbmS6DEtpH9Yo0MeDWZujd1EhZPRLUXa0bIyqnNiMNqLPmc07+b JxjXHs2HpzLI+VU4fPQvyslR8t9lVko282PlcREeOQhypRMzL4h8/yTdM kPseuDGYfOOi1uFm/0aU8TRzsqDCxCkP19wsNP3B6N6QjCpSslYnUS2QZ w==; X-CSE-ConnectionGUID: FTlUtlCeTPiL0LGBjrDNLA== X-CSE-MsgGUID: B5Nuf5xfQvOVaJS5G9UywA== X-IronPort-AV: E=McAfee;i="6800,10657,11981"; a="249782091" X-IronPort-AV: E=Sophos;i="6.27,242,1786978800"; d="scan'208";a="249782091" Received: from gmgwuk01.global.fujitsu.com ([172.187.114.235]) by esa10.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 13:59:03 +0900 Received: from az2uksmgm1.o.css.fujitsu.com (unknown [10.151.22.198]) (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 gmgwuk01.global.fujitsu.com (Postfix) with ESMTPS id 6863AC0055C; Mon, 30 Nov 2026 04:59:03 +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 az2uksmgm1.o.css.fujitsu.com (Postfix) with ESMTPS id 150BA8D65DC; Mon, 30 Nov 2026 04:59:03 +0000 (UTC) Received: from FCCLS0092175.localdomain (unknown [10.8.5.68]) by az2nlsmom4.fujitsu.com (Postfix) with SMTP id 1B8DC20000C7; Mon, 30 Nov 2026 04:58:59 +0000 (UTC) Date: Mon, 30 Nov 2026 13:58:58 +0900 To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell Cc: Kohei Enju Subject: Re: [PATCH] vl: complete memory size from memdev before creating memmap Message-ID: References: <20261113-fix-complete-memdev-size-v1-1-58e8a16bdc61@fujitsu.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20261113-fix-complete-memdev-size-v1-1-58e8a16bdc61@fujitsu.com> Received-SPF: pass client-ip=139.138.36.225; envelope-from=enju.kohei@fujitsu.com; helo=esa10.hc1455-7.c3s2.iphmx.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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Kohei Enju From: Kohei Enju via Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS 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 Gentle ping. Any comments on this patch would be appreciated. Thanks, Kohei On 11/13 10:34, Kohei Enju via wrote: > When -machine memory-backend=ram0 is used and '-m' option is omitted > with a KVM virt machine as follows: > > qemu-system-aarch64 \ > -enable-kvm \ > -machine virt,memory-backend=ram0 \ > -object memory-backend-memfd,id=ram0,size=256G,share=on \ > ... > > 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 memory-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) > } > } > > +static void qemu_complete_machine_memdev_size(void) > +{ > + QDict *backend_prop, *memory_prop; > + g_autofree char *size_str = NULL; > + QObject *qobj = 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 = opt->opts; > + const char *type = ObjectType_str(options->qom_type); > + > + if (g_str_equal(options->id, ram_memdev_id) && > + g_str_has_prefix(type, "memory-backend-")) { > + v = qobject_output_visitor_new(&qobj); > + visit_type_ObjectOptions(v, NULL, &options, &error_abort); > + visit_complete(v, &qobj); > + visit_free(v); > + > + backend_prop = qobject_to(QDict, qobj); > + size = qdict_get_uint(backend_prop, "size"); > + size_str = g_strdup_printf("%" PRIu64, size); > + > + memory_prop = 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 char *)) > { > ObjectOption *opt, *next; > @@ -3821,6 +3863,7 @@ void qemu_init(int argc, char **argv) > qemu_create_early_backends(); > > 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, > -- > Kohei Enju > >