From nobody Mon May 20 14:11:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1614699112; cv=none; d=zohomail.com; s=zohoarc; b=PFBKAdjARL88y8zTkiy8n0wERKSu5f7uIbs9L6fqGaFlxU8E1ocxk9XyatdefSI386Pioyw/77Q2CI4aUIbdg8yFvD3ldIbGaWdkRI5JXhahnZtdFaV2YSgQmNn/g9mbE5dEgOmOCno9xsvM7GYfgvTadUXHfn+3fhGYSnMNYF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614699112; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=xe4ZKwjbvsmJeqXL2h83Cep4y/modyrVkL6lODMnH/A=; b=UrPYCwfSNZb0UBIq+1QzuCbjTEzvaeiMb/J36fIMcEaVh0ZDEegoDudQ/DjQGpX6DAwnMV/G21HjQ9z+EuqJQ5ZtquMCp4e+Y23trw26RIqOD7MYS/aHBR2FAGHdvrenj03qFbfrF9Zy89gYy6fb0U4PiJfM+qZ3NhbgoNDvIsU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614699112025496.69587100728177; Tue, 2 Mar 2021 07:31:52 -0800 (PST) Received: from localhost ([::1]:38268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lH702-0001cZ-U8 for importer@patchew.org; Tue, 02 Mar 2021 10:31:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lH6yH-0000uz-S7 for qemu-devel@nongnu.org; Tue, 02 Mar 2021 10:30:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35835) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lH6yF-0000qc-SV for qemu-devel@nongnu.org; Tue, 02 Mar 2021 10:30:01 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-SyM01N2fNlag7iVVaD8jOw-1; Tue, 02 Mar 2021 10:29:55 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 11D59186DD23; Tue, 2 Mar 2021 15:29:54 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-189.ams2.redhat.com [10.36.114.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id B783F10023B1; Tue, 2 Mar 2021 15:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614698999; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xe4ZKwjbvsmJeqXL2h83Cep4y/modyrVkL6lODMnH/A=; b=Y7Xrc1MBXTmvYYbBXBuR4dHFDdXbGdeIWfvkrPjjLroghsNF3FEA+2gGx85VQePOKBzknK goifJ7jt33VQzQyGfBFypIasm8kM+8SeYYoWJbn2FfW7Wg/1payxEeM7/+uxyS1Dte75co xNOwi5Q9zVQkFeFHv0Mu3m79UGprTZY= X-MC-Unique: SyM01N2fNlag7iVVaD8jOw-1 From: David Hildenbrand To: qemu-devel@nongnu.org Subject: [PATCH v2] acpi: increase maximum size for "etc/table-loader" blob Date: Tue, 2 Mar 2021 16:29:44 +0100 Message-Id: <20210302152944.50898-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Michael S. Tsirkin" , David Hildenbrand , Richard Henderson , Alistair Francis , Shannon Zhao , qemu-arm@nongnu.org, Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The resizeable memory region that is created for the cmd blob has a maximum size of ACPI_BUILD_ALIGN_SIZE - 4k. This used to be sufficient, however, as we try fitting in additional data (e.g., vmgenid, nvdimm, intel-iommu), we require more than 4k and can crash QEMU when trying to resize the resizeable memory region beyond its maximum size: $ build/qemu-system-x86_64 --enable-kvm \ -machine q35,nvdimm=3Don \ -smp 1 \ -cpu host \ -m size=3D2G,slots=3D8,maxmem=3D4G \ -object memory-backend-file,id=3Dmem0,mem-path=3D/tmp/nvdimm,size=3D2= 56M \ -device nvdimm,label-size=3D131072,memdev=3Dmem0,id=3Dnvdimm0,slot=3D= 1 \ -nodefaults \ -device vmgenid \ -device intel-iommu Results in: Unexpected error in qemu_ram_resize() at ../softmmu/physmem.c:1850: qemu-system-x86_64: Size too large: /rom@etc/table-loader: 0x2000 > 0x1000: Invalid argument In this configuration, we consume exactly 4k (32 entries, 128 bytes each) when creating the VM. However, once the guest boots up and maps the MCFG, we also create the MCFG table and end up consuming 2 additional entries (pointer + checksum) - which is where we try resizing the memory region (-> RAMBlock), however, the maximum size does not allow for it. Let's increase the maximum size from 4k to 64k, which should be good enough for the near future. Migration is not concerned with the maximum size of a RAMBlock, only with the used size - so existing setups are not affected. Of course, we cannot migrate a VM that would have crash when started on older QEMU from new QEMU to older QEMU without failing early on the destination when synchronizing the RAM state: qemu-system-x86_64: Size too large: /rom@etc/table-loader: 0x2000 > 0x1= 000: Invalid argument qemu-system-x86_64: error while loading state for instance 0x0 of devic= e 'ram' qemu-system-x86_64: load of migration failed: Invalid argument While at it, replace "etc/table-loader" by ACPI_BUILD_LOADER_FILE in the microvm. Note: we could warn for problematic setups that migration might not always be possible - similar to how we handle the table blob; or we could disallow setups that would have crashed until now for compat machines. But I am not sure if the effort (messing compat machine properties) is worth it as we fail migration in a safe way early. Reviewed-by: Igor Mammedov Cc: Alistair Francis Cc: Paolo Bonzini Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Cc: Peter Maydell Cc: Shannon Zhao Cc: Marcel Apfelbaum Cc: Paolo Bonzini Cc: Richard Henderson Cc: qemu-arm@nongnu.org Signed-off-by: David Hildenbrand --- v1 -> v2: - Add details regarding entries to patch description - Add RB from Igor (thanks!) --- hw/arm/virt-acpi-build.c | 3 ++- hw/i386/acpi-build.c | 3 ++- hw/i386/acpi-microvm.c | 3 ++- include/hw/acpi/aml-build.h | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index f9c9df916c..a91550de6f 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -865,7 +865,8 @@ void virt_acpi_setup(VirtMachineState *vms) =20 build_state->linker_mr =3D acpi_add_rom_blob(virt_acpi_build_update, build_state, - tables.linker->cmd_blob, ACPI_BUILD_LOADER_FILE,= 0); + tables.linker->cmd_blob, ACPI_BUILD_LOADER_FILE, + ACPI_BUILD_LOADER_MAX_SIZE); =20 fw_cfg_add_file(vms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->d= ata, acpi_data_len(tables.tcpalog)); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 31a5f6f4a5..a75138ea5a 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2524,7 +2524,8 @@ void acpi_setup(void) =20 build_state->linker_mr =3D acpi_add_rom_blob(acpi_build_update, build_state, - tables.linker->cmd_blob, ACPI_BUILD_LOADER_FILE,= 0); + tables.linker->cmd_blob, ACPI_BUILD_LOADER_FILE, + ACPI_BUILD_LOADER_MAX_SIZE); =20 fw_cfg_add_file(x86ms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->data, acpi_data_len(tables.tcpalog)); diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c index 54b3af478a..fe8a965fe6 100644 --- a/hw/i386/acpi-microvm.c +++ b/hw/i386/acpi-microvm.c @@ -255,7 +255,8 @@ void acpi_setup_microvm(MicrovmMachineState *mms) ACPI_BUILD_TABLE_MAX_SIZE); acpi_add_rom_blob(acpi_build_no_update, NULL, tables.linker->cmd_blob, - "etc/table-loader", 0); + ACPI_BUILD_LOADER_FILE, + ACPI_BUILD_LOADER_MAX_SIZE); acpi_add_rom_blob(acpi_build_no_update, NULL, tables.rsdp, ACPI_BUILD_RSDP_FILE, 0); diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 380d3e3924..93cdfd4006 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -6,6 +6,7 @@ =20 /* Reserve RAM space for tables: add another order of magnitude. */ #define ACPI_BUILD_TABLE_MAX_SIZE 0x200000 +#define ACPI_BUILD_LOADER_MAX_SIZE 0x40000 =20 #define ACPI_BUILD_APPNAME6 "BOCHS " #define ACPI_BUILD_APPNAME8 "BXPC " --=20 2.29.2