From nobody Mon Feb 9 01:51:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1769508214; cv=none; d=zohomail.com; s=zohoarc; b=MwLO4LPdmpYH/pmkW34hgV1izD68XUe1WGYygUKIurPXtqP9rO9SciyeJb1NpUDs6GC9S0uVHFOFQHBMS8Opv3pskd+ZCiVmC/XauJYTgKBRNdtwXNi/JxsggwW2Ll949n5T+w6TjjHbT+sZi7YdTPX7dn6Op9CWrM12f2ZYNXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769508214; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WBzv/EEHOLl1lvpY0Tolfh3wVeN8GBPJIxvAOWVtvEE=; b=P9b1bTumH3/T9PnEquZkgHdR7UU9y7lT17GKbYoRZCLgnasz1V2YOuNYPrK8IQVRNEmSiEAEDLoY3CWaLMOSoVwqCq+VnFrC26flTpXJZ7Q8Hbw4SEt1A2KL3WS15SoZI7LUiZprDWHjM9UG6YKOKYXDHDfnQpPCa+8FWilOGcM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176950821473379.99811622805578; Tue, 27 Jan 2026 02:03:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vkfuw-0003mO-95; Tue, 27 Jan 2026 05:03:26 -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 1vkfup-0003YO-Ld for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vkful-0005Ay-7S for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:18 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-416-tnIzJSu7MLS8Vs75LPlsJQ-1; Tue, 27 Jan 2026 05:03:11 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1C8CF19775E0; Tue, 27 Jan 2026 10:03:10 +0000 (UTC) Received: from osteffen-thinkpadx1carbongen12.rmtde.csb (unknown [10.44.34.174]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2B84A180066A; Tue, 27 Jan 2026 10:03:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769508194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WBzv/EEHOLl1lvpY0Tolfh3wVeN8GBPJIxvAOWVtvEE=; b=OdzPWYf6Emrf64EitnP0GjTmxppkjA56hfhXkDBxvROUrfhTNKm1f1/x7HmOi3O3ODD+sv AHJ8lvTQsrxMopBJVy410kyC0OZonJRDgNLLKvyRW72doLazG8+Z6laMK/XCvGK3JjEljo GiDRZMKlCalgiwm+hyolkCAQycmumEE= X-MC-Unique: tnIzJSu7MLS8Vs75LPlsJQ-1 X-Mimecast-MFC-AGG-ID: tnIzJSu7MLS8Vs75LPlsJQ_1769508190 From: Oliver Steffen To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Eduardo Habkost , Gerd Hoffmann , Stefano Garzarella , Zhao Liu , Marcel Apfelbaum , Igor Mammedov , Marcelo Tosatti , Richard Henderson , Ani Sinha , kvm@vger.kernel.org, "Michael S. Tsirkin" , Luigi Leonardi , Joerg Roedel , Oliver Steffen Subject: [PATCH v5 1/6] hw/acpi: Make BIOS linker optional Date: Tue, 27 Jan 2026 11:02:52 +0100 Message-ID: <20260127100257.1074104-2-osteffen@redhat.com> In-Reply-To: <20260127100257.1074104-1-osteffen@redhat.com> References: <20260127100257.1074104-1-osteffen@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.133.124; envelope-from=osteffen@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1769508216191154100 Content-Type: text/plain; charset="utf-8" Make the BIOS linker optional in acpi_table_end() and calculate the ACPI table checksum directly if no linker is provided. This makes it possible to call for example acpi_build_madt() from outside the ACPI table builder context. Signed-off-by: Oliver Steffen --- hw/acpi/aml-build.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index dad4cfcc7d..6a3650076f 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1730,6 +1730,25 @@ void acpi_table_begin(AcpiTable *desc, GArray *array) build_append_int_noprefix(array, 1, 4); /* Creator Revision */ } =20 +static uint8_t calculate_acpi_checksum(const gchar *data, size_t len) +{ + size_t i; + uint8_t sum =3D 0; + + for (i =3D 0; i < len; ++i) { + sum +=3D (uint8_t)data[i]; + } + + return sum; +} + +static void update_acpi_checksum(gchar *data, size_t start_offset, + size_t table_len, size_t checksum_offset) +{ + uint8_t sum =3D calculate_acpi_checksum(&data[start_offset], table_len= ); + data[checksum_offset] =3D 0xff - sum + 1; +} + void acpi_table_end(BIOSLinker *linker, AcpiTable *desc) { /* @@ -1748,8 +1767,14 @@ void acpi_table_end(BIOSLinker *linker, AcpiTable *d= esc) */ memcpy(len_ptr, &table_len_le, sizeof table_len_le); =20 - bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, - desc->table_offset, table_len, desc->table_offset + checksum_offse= t); + if (linker !=3D NULL) { + bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, + desc->table_offset, table_len, + desc->table_offset + checksum_offs= et); + } else { + update_acpi_checksum(desc->array->data, desc->table_offset, + table_len, desc->table_offset + checksum_offs= et); + } } =20 void *acpi_data_push(GArray *table_data, unsigned size) --=20 2.52.0 From nobody Mon Feb 9 01:51:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1769508228; cv=none; d=zohomail.com; s=zohoarc; b=O1sxeJhZNYIa5N0j9/84zs0kDMr0ja2tLLXvdDEMW8VVf7a1chx42JCkFjFzJIv1u28AKrRH548H77GH88Ixxa9IEN5xIHRsTR4DSXF/Pw9FQuqLASsk4dJfXhOItFPmrJEp6uFck72AHX7egABFhQ26fuzm/cjzU0jplOWAzcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769508228; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QpEw8yEkNdxIl1el1j22OB3dfzc6fkynrGThqY7HmlA=; b=A6WIUrGlEkUd1TCsjMtYB/LO+pAzPGN/CHI/lG7tMyX5Wb1oLArPAQ4nmY6GDNEcsFE/gjCYl7KPyQKF8isW214v3I2mD1mMrRzC3Du/9evBeGZi8XpO/w4hzhHY6dTqCvRUd2hX1duEn2HFsEIsgV6vTesIWb/n6xWK17VHxRE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769508228878137.11137670743233; Tue, 27 Jan 2026 02:03:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vkfuy-0003sU-1I; Tue, 27 Jan 2026 05:03: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 1vkfuv-0003iu-7N for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vkfus-0005C7-Uw for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:24 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-83-6FSK86biPKW35eFGNcRUFg-1; Tue, 27 Jan 2026 05:03:18 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3D0661944F12; Tue, 27 Jan 2026 10:03:17 +0000 (UTC) Received: from osteffen-thinkpadx1carbongen12.rmtde.csb (unknown [10.44.34.174]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AD0F4180049F; Tue, 27 Jan 2026 10:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769508202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QpEw8yEkNdxIl1el1j22OB3dfzc6fkynrGThqY7HmlA=; b=OzI2rgjw2L4i0qmLmfnlgvaKB94OHgRmRtUpPaM3vnYsf7ZsVSl8n+bY0Y9ZQwNW+WaVG0 gwdK+sojU/Wf3T3kf2NwE5xX/+R3t28x45tFvikvqhj/NC0NWm9Rk+Yb3byoPUw5h6HY50 5i+NnevFpEQI2ZQf+rkjkj/uOkHqk7A= X-MC-Unique: 6FSK86biPKW35eFGNcRUFg-1 X-Mimecast-MFC-AGG-ID: 6FSK86biPKW35eFGNcRUFg_1769508197 From: Oliver Steffen To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Eduardo Habkost , Gerd Hoffmann , Stefano Garzarella , Zhao Liu , Marcel Apfelbaum , Igor Mammedov , Marcelo Tosatti , Richard Henderson , Ani Sinha , kvm@vger.kernel.org, "Michael S. Tsirkin" , Luigi Leonardi , Joerg Roedel , Oliver Steffen Subject: [PATCH v5 2/6] hw/acpi: Add standalone function to build MADT Date: Tue, 27 Jan 2026 11:02:53 +0100 Message-ID: <20260127100257.1074104-3-osteffen@redhat.com> In-Reply-To: <20260127100257.1074104-1-osteffen@redhat.com> References: <20260127100257.1074104-1-osteffen@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=osteffen@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1769508230294154100 Content-Type: text/plain; charset="utf-8" Add a fuction called `acpi_build_madt_standalone()` that builds a MADT without the rest of the ACPI table structure. Signed-off-by: Oliver Steffen --- hw/i386/acpi-build.c | 9 +++++++++ hw/i386/acpi-build.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9446a9f862..19c62362e3 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2249,3 +2249,12 @@ void acpi_setup(void) */ acpi_build_tables_cleanup(&tables, false); } + +GArray *acpi_build_madt_standalone(MachineState *machine) +{ + X86MachineState *x86ms =3D X86_MACHINE(machine); + GArray *table =3D g_array_new(false, true, 1); + acpi_build_madt(table, NULL, x86ms, x86ms->oem_id, + x86ms->oem_table_id); + return table; +} diff --git a/hw/i386/acpi-build.h b/hw/i386/acpi-build.h index 8ba3c33e48..00e19bbe5e 100644 --- a/hw/i386/acpi-build.h +++ b/hw/i386/acpi-build.h @@ -8,4 +8,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmi= o; void acpi_setup(void); Object *acpi_get_i386_pci_host(void); =20 +GArray *acpi_build_madt_standalone(MachineState *machine); + #endif --=20 2.52.0 From nobody Mon Feb 9 01:51:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1769508221; cv=none; d=zohomail.com; s=zohoarc; b=NMo/lAUAiS4Zv3QM5JaIIdktBBXTu8m/8FE//KkH6cnDCEYIwrAAZAfwrVQnyVtTFxlchHLLTM8e1DOKouAAstn+Icv22IFvsd20a0rDGKcLZe6pzmB3jlRoJuVeUykaV0jzGXUUCBFeLA26fyHP4KpUrL6jEvQyQpgV8Em8O0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769508221; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vJK70mYmfTu4Vb3wBxCU3kc4SeIhw8zwF2RBpz/uZU4=; b=P/5FerBiSlPRr9eQt6EV6CJudzv28VedQUFumCAtHa/bAJDjyYRNYgCAqXYfeL6cO5FVQ3P7CCDI19PR8EddPUaNPF+NadUUtw1E8rz6epAZiO8hj8N8SGUxgWS1Rpdt5XMO90uooyl6Nqg8mA0LHgPtd+/j/Nk08cEZjXRliCE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769508221557162.76046520421687; Tue, 27 Jan 2026 02:03:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vkfv2-0004OA-Rn; Tue, 27 Jan 2026 05:03: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 1vkfv1-0004KY-Jg for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vkfv0-0005Cm-0D for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:31 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-359-nRC6KdMoNiGhaHGupXgGog-1; Tue, 27 Jan 2026 05:03:24 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 84EFD19775DE; Tue, 27 Jan 2026 10:03:23 +0000 (UTC) Received: from osteffen-thinkpadx1carbongen12.rmtde.csb (unknown [10.44.34.174]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BCDAD180066A; Tue, 27 Jan 2026 10:03:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769508209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vJK70mYmfTu4Vb3wBxCU3kc4SeIhw8zwF2RBpz/uZU4=; b=OboVeXo6I/ZsablNJAfqRYOljgz2k3fcL+HGUB4edYkQSHqvHnPiZMa4b9T2ErIw10d04n Xm1iIVqd8rAm1L6fsZpCq/Xi4K3G+o1eRWeu1/2rM+hcIRXfxDGxRePmHS6g2KbA4IZ9BJ LS4i1aUhLzxrN1cDB/NKzcPCVOofTjQ= X-MC-Unique: nRC6KdMoNiGhaHGupXgGog-1 X-Mimecast-MFC-AGG-ID: nRC6KdMoNiGhaHGupXgGog_1769508203 From: Oliver Steffen To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Eduardo Habkost , Gerd Hoffmann , Stefano Garzarella , Zhao Liu , Marcel Apfelbaum , Igor Mammedov , Marcelo Tosatti , Richard Henderson , Ani Sinha , kvm@vger.kernel.org, "Michael S. Tsirkin" , Luigi Leonardi , Joerg Roedel , Oliver Steffen Subject: [PATCH v5 3/6] igvm: Add common function for finding parameter entries Date: Tue, 27 Jan 2026 11:02:54 +0100 Message-ID: <20260127100257.1074104-4-osteffen@redhat.com> In-Reply-To: <20260127100257.1074104-1-osteffen@redhat.com> References: <20260127100257.1074104-1-osteffen@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=osteffen@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1769508222825154100 Content-Type: text/plain; charset="utf-8" Move repeating code for finding the parameter entries in the IGVM backend out of the parameter handlers into a common function. A warning message is emitted in case a no parameter entry can be found for a given index. Signed-off-by: Oliver Steffen Reviewed-by: Luigi Leonardi --- backends/igvm.c | 143 ++++++++++++++++++++++++++---------------------- 1 file changed, 77 insertions(+), 66 deletions(-) diff --git a/backends/igvm.c b/backends/igvm.c index 4cf7b57234..213c9d337e 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -12,6 +12,7 @@ #include "qemu/osdep.h" =20 #include "qapi/error.h" +#include "qemu/error-report.h" #include "qemu/target-info-qapi.h" #include "system/igvm.h" #include "system/igvm-cfg.h" @@ -97,6 +98,20 @@ typedef struct QIgvm { unsigned region_page_count; } QIgvm; =20 +static QIgvmParameterData* +qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index) +{ + QIgvmParameterData *param_entry; + QTAILQ_FOREACH(param_entry, &igvm->parameter_data, next) + { + if (param_entry->index =3D=3D parameter_area_index) { + return param_entry; + } + } + warn_report("IGVM: No parameter area for index %u", parameter_area_ind= ex); + return NULL; +} + static int qigvm_directive_page_data(QIgvm *ctx, const uint8_t *header_dat= a, Error **errp); static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_da= ta, @@ -571,58 +586,54 @@ static int qigvm_directive_memory_map(QIgvm *ctx, con= st uint8_t *header_data, } =20 /* Find the parameter area that should hold the memory map */ - QTAILQ_FOREACH(param_entry, &ctx->parameter_data, next) - { - if (param_entry->index =3D=3D param->parameter_area_index) { - max_entry_count =3D - param_entry->size / sizeof(IGVM_VHS_MEMORY_MAP_ENTRY); - mm_entry =3D (IGVM_VHS_MEMORY_MAP_ENTRY *)param_entry->data; - - retval =3D get_mem_map_entry(entry, &cgmm_entry, errp); - while (retval =3D=3D 0) { - if (entry >=3D max_entry_count) { - error_setg( - errp, - "IGVM: guest memory map size exceeds parameter are= a defined in IGVM file"); - return -1; - } - mm_entry[entry].starting_gpa_page_number =3D cgmm_entry.gp= a >> 12; - mm_entry[entry].number_of_pages =3D cgmm_entry.size >> 12; - - switch (cgmm_entry.type) { - case CGS_MEM_RAM: - mm_entry[entry].entry_type =3D - IGVM_MEMORY_MAP_ENTRY_TYPE_MEMORY; - break; - case CGS_MEM_RESERVED: - mm_entry[entry].entry_type =3D - IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED; - break; - case CGS_MEM_ACPI: - mm_entry[entry].entry_type =3D - IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED; - break; - case CGS_MEM_NVS: - mm_entry[entry].entry_type =3D - IGVM_MEMORY_MAP_ENTRY_TYPE_PERSISTENT; - break; - case CGS_MEM_UNUSABLE: - mm_entry[entry].entry_type =3D - IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED; - break; - } - retval =3D get_mem_map_entry(++entry, &cgmm_entry, errp); - } - if (retval < 0) { - return retval; - } - /* The entries need to be sorted */ - qsort(mm_entry, entry, sizeof(IGVM_VHS_MEMORY_MAP_ENTRY), - qigvm_cmp_mm_entry); + param_entry =3D qigvm_find_param_entry(ctx, param->parameter_area_inde= x); + if (param_entry =3D=3D NULL) { + return 0; + } + + max_entry_count =3D param_entry->size / sizeof(IGVM_VHS_MEMORY_MAP_ENT= RY); + mm_entry =3D (IGVM_VHS_MEMORY_MAP_ENTRY *)param_entry->data; + + retval =3D get_mem_map_entry(entry, &cgmm_entry, errp); + while (retval =3D=3D 0) { + if (entry >=3D max_entry_count) { + error_setg( + errp, + "IGVM: guest memory map size exceeds parameter area define= d " + "in IGVM file"); + return -1; + } + mm_entry[entry].starting_gpa_page_number =3D cgmm_entry.gpa >> 12; + mm_entry[entry].number_of_pages =3D cgmm_entry.size >> 12; =20 + switch (cgmm_entry.type) { + case CGS_MEM_RAM: + mm_entry[entry].entry_type =3D IGVM_MEMORY_MAP_ENTRY_TYPE_MEMO= RY; + break; + case CGS_MEM_RESERVED: + mm_entry[entry].entry_type =3D + IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED; + break; + case CGS_MEM_ACPI: + mm_entry[entry].entry_type =3D + IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED; + break; + case CGS_MEM_NVS: + mm_entry[entry].entry_type =3D IGVM_MEMORY_MAP_ENTRY_TYPE_PERS= ISTENT; + break; + case CGS_MEM_UNUSABLE: + mm_entry[entry].entry_type =3D + IGVM_MEMORY_MAP_ENTRY_TYPE_PLATFORM_RESERVED; break; } + retval =3D get_mem_map_entry(++entry, &cgmm_entry, errp); + } + if (retval < 0) { + return retval; } + /* The entries need to be sorted */ + qsort(mm_entry, entry, sizeof(IGVM_VHS_MEMORY_MAP_ENTRY), + qigvm_cmp_mm_entry); return 0; } =20 @@ -634,18 +645,18 @@ static int qigvm_directive_vp_count(QIgvm *ctx, const= uint8_t *header_data, uint32_t *vp_count; CPUState *cpu; =20 - QTAILQ_FOREACH(param_entry, &ctx->parameter_data, next) + param_entry =3D qigvm_find_param_entry(ctx, param->parameter_area_inde= x); + if (param_entry =3D=3D NULL) { + return 0; + } + + vp_count =3D (uint32_t *)(param_entry->data + param->byte_offset); + *vp_count =3D 0; + CPU_FOREACH(cpu) { - if (param_entry->index =3D=3D param->parameter_area_index) { - vp_count =3D (uint32_t *)(param_entry->data + param->byte_offs= et); - *vp_count =3D 0; - CPU_FOREACH(cpu) - { - (*vp_count)++; - } - break; - } + (*vp_count)++; } + return 0; } =20 @@ -657,15 +668,15 @@ static int qigvm_directive_environment_info(QIgvm *ct= x, QIgvmParameterData *param_entry; IgvmEnvironmentInfo *environmental_state; =20 - QTAILQ_FOREACH(param_entry, &ctx->parameter_data, next) - { - if (param_entry->index =3D=3D param->parameter_area_index) { - environmental_state =3D - (IgvmEnvironmentInfo *)(param_entry->data + param->byte_of= fset); - environmental_state->memory_is_shared =3D 1; - break; - } + param_entry =3D qigvm_find_param_entry(ctx, param->parameter_area_inde= x); + if (param_entry =3D=3D NULL) { + return 0; } + + environmental_state =3D + (IgvmEnvironmentInfo *)(param_entry->data + param->byte_offset); + environmental_state->memory_is_shared =3D 1; + return 0; } =20 --=20 2.52.0 From nobody Mon Feb 9 01:51:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1769508226; cv=none; d=zohomail.com; s=zohoarc; b=XtZ7mTISQG0G2MlpHLJcN7O3ueGOQyPQ8Ehbn0qfr/plko3pMsWqhDQIM7vYuE3WLX6c70/nZ9jJ1PDc28XmHTcXWy4uEg++fVlPWq88zS+vML3+1QkDiEiqVz5oLbPbIMv2MrDWufdL1lNss6UjppdKcGwyv3w8m/c2gtkkmiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769508226; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lU8cfl9gCDqNxnMilRoV/PVgA412LlMd5AfMzj0nBzw=; b=iwAFygxt9cKeYMJb5I1BRKVcuNSTKitGb7BTFhJ9JGgVUfw8EzTjcJN0Ua0m+4BRPqqRGhnxEZfAaFs/WKTnoKybKAPd8DSwhosBcRWEvPvSoEysTOLTEmFE3siUfujm2ZqT5KHlTyaeJuNwFUmco7OVXSitNWNOPGvsSwLol6I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769508226452528.8414900534403; Tue, 27 Jan 2026 02:03:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vkfv6-0004gb-Cu; Tue, 27 Jan 2026 05:03:36 -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 1vkfv4-0004WP-IX for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vkfv3-0005D7-1V for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:34 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-tdPfesTPMxOheGj8B1vzHg-1; Tue, 27 Jan 2026 05:03:30 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 145F11800614; Tue, 27 Jan 2026 10:03:29 +0000 (UTC) Received: from osteffen-thinkpadx1carbongen12.rmtde.csb (unknown [10.44.34.174]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0D67C180066A; Tue, 27 Jan 2026 10:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769508212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lU8cfl9gCDqNxnMilRoV/PVgA412LlMd5AfMzj0nBzw=; b=WL4RTxYdhpYbe4ltkamwmldY9YOUtb5yyT3PcGXKrtl0sP6EfZ3tcpCqX4UMOixp+ln0rO 95wBpl73kNU3dbuVeLJbCE8i7URxORDR2moYYIGizVR89AXGG3isoQvzOjfHpScnd13pg6 UZVeykWEHVwplvyNNXRK6QWFaG8pB+I= X-MC-Unique: tdPfesTPMxOheGj8B1vzHg-1 X-Mimecast-MFC-AGG-ID: tdPfesTPMxOheGj8B1vzHg_1769508209 From: Oliver Steffen To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Eduardo Habkost , Gerd Hoffmann , Stefano Garzarella , Zhao Liu , Marcel Apfelbaum , Igor Mammedov , Marcelo Tosatti , Richard Henderson , Ani Sinha , kvm@vger.kernel.org, "Michael S. Tsirkin" , Luigi Leonardi , Joerg Roedel , Oliver Steffen Subject: [PATCH v5 4/6] igvm: Refactor qigvm_parameter_insert Date: Tue, 27 Jan 2026 11:02:55 +0100 Message-ID: <20260127100257.1074104-5-osteffen@redhat.com> In-Reply-To: <20260127100257.1074104-1-osteffen@redhat.com> References: <20260127100257.1074104-1-osteffen@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=osteffen@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1769508229102158500 Content-Type: text/plain; charset="utf-8" Use qigvm_find_param_entry() also in qigvm_parameter_insert(). This changes behavior: Processing now stops after the first parameter entry found. That is OK, because we expect only one matching entry anyway. Signed-off-by: Oliver Steffen Reviewed-by: Luigi Leonardi --- backends/igvm.c | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/backends/igvm.c b/backends/igvm.c index 213c9d337e..0a0092fb55 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -513,31 +513,31 @@ static int qigvm_directive_parameter_insert(QIgvm *ct= x, return 0; } =20 - QTAILQ_FOREACH(param_entry, &ctx->parameter_data, next) - { - if (param_entry->index =3D=3D param->parameter_area_index) { - region =3D qigvm_prepare_memory(ctx, param->gpa, param_entry->= size, - ctx->current_header_index, errp); - if (!region) { - return -1; - } - memcpy(region, param_entry->data, param_entry->size); - g_free(param_entry->data); - param_entry->data =3D NULL; - - /* - * If a confidential guest support object is provided then use= it to - * set the guest state. - */ - if (ctx->cgs) { - result =3D ctx->cgsc->set_guest_state(param->gpa, region, - param_entry->size, - CGS_PAGE_TYPE_UNMEASUR= ED, 0, - errp); - if (result < 0) { - return -1; - } - } + param_entry =3D qigvm_find_param_entry(ctx, param->parameter_area_inde= x); + if (param_entry =3D=3D NULL) { + return 0; + } + + region =3D qigvm_prepare_memory(ctx, param->gpa, param_entry->size, + ctx->current_header_index, errp); + if (!region) { + return -1; + } + memcpy(region, param_entry->data, param_entry->size); + g_free(param_entry->data); + param_entry->data =3D NULL; + + /* + * If a confidential guest support object is provided then use it to + * set the guest state. + */ + if (ctx->cgs) { + result =3D ctx->cgsc->set_guest_state(param->gpa, region, + param_entry->size, + CGS_PAGE_TYPE_UNMEASURED, 0, + errp); + if (result < 0) { + return -1; } } return 0; --=20 2.52.0 From nobody Mon Feb 9 01:51:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1769508230; cv=none; d=zohomail.com; s=zohoarc; b=YR2afRUB0ZGW/fKufAqy4EnjEXfxdEA6A0Gasr8eBQN+2iek9rs+bugCucFNGn5pmuTl3Xp8Q0zzAIWHJ3VYl974QVn5JWVdiLLE7MwQXY3DJmJUZTDHaJ2Zcgmee1ARThlznsJnH/7uLIIsAxigRDhCgf3dlVEWI0NSfVK0qfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769508230; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QIN8rvBpewCUVKXyhBPq2fE6uRIvtT3wSywvie+gvME=; b=Re/+T0rpFWW0XoQsp+jEO99kRRF4h7NOtdvvEvURW4Xm9DvNMzbGPE54ULIZajfLIHdQWs+JVwDMnVPheu6jPcV8ufVuZ6T5Q3mb0zbbdNXcmOtl77Wmn4sX9QuT3HYShjggJY5LTJc8VeqTntOFm1PEDNuA4iBbYqY5q3//aw0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769508230865981.8114179946382; Tue, 27 Jan 2026 02:03:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vkfvE-0004yf-6b; Tue, 27 Jan 2026 05:03:44 -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 1vkfvB-0004tq-Uk for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vkfvA-0005DV-3p for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:41 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-E2h6qf6SOcqj7atksG45Rg-1; Tue, 27 Jan 2026 05:03:35 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 76CC21955D84; Tue, 27 Jan 2026 10:03:34 +0000 (UTC) Received: from osteffen-thinkpadx1carbongen12.rmtde.csb (unknown [10.44.34.174]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8C3B1180066A; Tue, 27 Jan 2026 10:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769508219; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QIN8rvBpewCUVKXyhBPq2fE6uRIvtT3wSywvie+gvME=; b=TaZir3niBjtjIgRNHB4TarVMUrOZ2p4BOApBZpD+2qV6t8SfNhngt4ZUyCq/io1OXt9mXP 47dbgx+vHE6tLEPu85IWSobv9xDS1U3STzmVPKjMwgGa6FVg993GxHih6A3gYYBl+kjE1+ JP+D66pKWSVHNZ1ekpBg7ZR8tPAMKnw= X-MC-Unique: E2h6qf6SOcqj7atksG45Rg-1 X-Mimecast-MFC-AGG-ID: E2h6qf6SOcqj7atksG45Rg_1769508214 From: Oliver Steffen To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Eduardo Habkost , Gerd Hoffmann , Stefano Garzarella , Zhao Liu , Marcel Apfelbaum , Igor Mammedov , Marcelo Tosatti , Richard Henderson , Ani Sinha , kvm@vger.kernel.org, "Michael S. Tsirkin" , Luigi Leonardi , Joerg Roedel , Oliver Steffen Subject: [PATCH v5 5/6] igvm: Pass machine state to IGVM file processing Date: Tue, 27 Jan 2026 11:02:56 +0100 Message-ID: <20260127100257.1074104-6-osteffen@redhat.com> In-Reply-To: <20260127100257.1074104-1-osteffen@redhat.com> References: <20260127100257.1074104-1-osteffen@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=osteffen@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1769508231199158500 Content-Type: text/plain; charset="utf-8" Pass the full MachineState to the IGVM backend during file processing, instead of just the ConfidentialGuestSupport struct (which is a member of the MachineState). This replaces the cgs parameter of qigvm_process_file() with the machine state to make it available in the IGVM processing context. We will use it later to generate MADT data there to pass to the guest as IGVM parameter. Reviewed-by: Luigi Leonardi Signed-off-by: Oliver Steffen --- backends/igvm-cfg.c | 2 +- backends/igvm.c | 31 ++++++++++++++++++------------- include/system/igvm-cfg.h | 3 ++- include/system/igvm.h | 5 +++-- target/i386/sev.c | 3 +-- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/backends/igvm-cfg.c b/backends/igvm-cfg.c index f236b523df..64589ca34f 100644 --- a/backends/igvm-cfg.c +++ b/backends/igvm-cfg.c @@ -52,7 +52,7 @@ static void igvm_reset_hold(Object *obj, ResetType type) =20 trace_igvm_reset_hold(type); =20 - qigvm_process_file(igvm, ms->cgs, false, &error_fatal); + qigvm_process_file(igvm, ms, false, &error_fatal); } =20 static void igvm_reset_exit(Object *obj, ResetType type) diff --git a/backends/igvm.c b/backends/igvm.c index 0a0092fb55..f26eb633f8 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -11,6 +11,7 @@ =20 #include "qemu/osdep.h" =20 +#include "hw/core/boards.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/target-info-qapi.h" @@ -73,7 +74,7 @@ struct QEMU_PACKED sev_id_authentication { */ typedef struct QIgvm { IgvmHandle file; - ConfidentialGuestSupport *cgs; + MachineState *machine_state; ConfidentialGuestSupportClass *cgsc; uint32_t compatibility_mask; unsigned current_header_index; @@ -239,7 +240,8 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t = addr, uint64_t size, g_autofree char *region_name =3D g_strdup_printf("igvm.%X", region_identifier); igvm_pages =3D g_new0(MemoryRegion, 1); - if (ctx->cgs && ctx->cgs->require_guest_memfd) { + if (ctx->machine_state->cgs && + ctx->machine_state->cgs->require_guest_memfd) { if (!memory_region_init_ram_guest_memfd(igvm_pages, NULL, region_name, size, err= p)) { return NULL; @@ -359,7 +361,7 @@ static int qigvm_process_mem_region(QIgvm *ctx, unsigne= d start_index, * If a confidential guest support object is provided then use it to s= et the * guest state. */ - if (ctx->cgs) { + if (ctx->machine_state->cgs) { cgs_page_type =3D qigvm_type_to_cgs_type(page_type, flags->unmeasured, zero); if (cgs_page_type < 0) { @@ -461,7 +463,7 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const= uint8_t *header_data, =20 data =3D (uint8_t *)igvm_get_buffer(ctx->file, data_handle); =20 - if (ctx->cgs) { + if (ctx->machine_state->cgs) { result =3D ctx->cgsc->set_guest_state( vp_context->gpa, data, igvm_get_buffer_size(ctx->file, data_ha= ndle), CGS_PAGE_TYPE_VMSA, vp_context->vp_index, errp); @@ -531,7 +533,7 @@ static int qigvm_directive_parameter_insert(QIgvm *ctx, * If a confidential guest support object is provided then use it to * set the guest state. */ - if (ctx->cgs) { + if (ctx->machine_state->cgs) { result =3D ctx->cgsc->set_guest_state(param->gpa, region, param_entry->size, CGS_PAGE_TYPE_UNMEASURED, 0, @@ -572,7 +574,7 @@ static int qigvm_directive_memory_map(QIgvm *ctx, const= uint8_t *header_data, ConfidentialGuestMemoryMapEntry cgmm_entry; int retval =3D 0; =20 - if (ctx->cgs && ctx->cgsc->get_mem_map_entry) { + if (ctx->machine_state->cgs && ctx->cgsc->get_mem_map_entry) { get_mem_map_entry =3D ctx->cgsc->get_mem_map_entry; =20 } else if (target_arch() =3D=3D SYS_EMU_TARGET_X86_64) { @@ -698,7 +700,7 @@ static int qigvm_directive_required_memory(QIgvm *ctx, if (!region) { return -1; } - if (ctx->cgs) { + if (ctx->machine_state->cgs) { result =3D ctx->cgsc->set_guest_state(mem->gpa, region, mem->number_of_by= tes, CGS_PAGE_TYPE_REQUIRED_MEMORY, 0, e= rrp); @@ -816,14 +818,14 @@ static int qigvm_supported_platform_compat_mask(QIgvm= *ctx, Error **errp) sizeof( IGVM_VHS_VARIABLE_HEAD= ER)); if ((platform->platform_type =3D=3D IGVM_PLATFORM_TYPE_SEV_ES)= && - ctx->cgs) { + ctx->machine_state->cgs) { if (ctx->cgsc->check_support( CGS_PLATFORM_SEV_ES, platform->platform_version, platform->highest_vtl, platform->shared_gpa_bounda= ry)) { compatibility_mask_sev_es =3D platform->compatibility_= mask; } } else if ((platform->platform_type =3D=3D IGVM_PLATFORM_TYPE_= SEV) && - ctx->cgs) { + ctx->machine_state->cgs) { if (ctx->cgsc->check_support( CGS_PLATFORM_SEV, platform->platform_version, platform->highest_vtl, platform->shared_gpa_bounda= ry)) { @@ -831,7 +833,7 @@ static int qigvm_supported_platform_compat_mask(QIgvm *= ctx, Error **errp) } } else if ((platform->platform_type =3D=3D IGVM_PLATFORM_TYPE_SEV_SNP) && - ctx->cgs) { + ctx->machine_state->cgs) { if (ctx->cgsc->check_support( CGS_PLATFORM_SEV_SNP, platform->platform_version, platform->highest_vtl, platform->shared_gpa_bounda= ry)) { @@ -904,7 +906,7 @@ IgvmHandle qigvm_file_init(char *filename, Error **errp) return igvm; } =20 -int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuestSupport *cgs, +int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state, bool onlyVpContext, Error **errp) { int32_t header_count; @@ -920,13 +922,16 @@ int qigvm_process_file(IgvmCfg *cfg, ConfidentialGues= tSupport *cgs, ctx.file =3D cfg->file; trace_igvm_process_file(cfg->file, onlyVpContext); =20 + ctx.machine_state =3D machine_state; + /* * The ConfidentialGuestSupport object is optional and allows a confid= ential * guest platform to perform extra processing, such as page measuremen= t, on * IGVM directives. */ - ctx.cgs =3D cgs; - ctx.cgsc =3D cgs ? CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(cgs) : NULL; + ctx.cgsc =3D machine_state->cgs ? + CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(machine_state->cgs= ) : + NULL; =20 /* * Check that the IGVM file provides configuration for the current diff --git a/include/system/igvm-cfg.h b/include/system/igvm-cfg.h index 6c07f30840..e06d611f74 100644 --- a/include/system/igvm-cfg.h +++ b/include/system/igvm-cfg.h @@ -12,6 +12,7 @@ #ifndef QEMU_IGVM_CFG_H #define QEMU_IGVM_CFG_H =20 +#include "hw/core/boards.h" #include "qemu/typedefs.h" #include "qom/object.h" =20 @@ -27,7 +28,7 @@ typedef struct IgvmCfgClass { * * Returns 0 for ok and -1 on error. */ - int (*process)(IgvmCfg *cfg, ConfidentialGuestSupport *cgs, + int (*process)(IgvmCfg *cfg, MachineState *machine_state, bool onlyVpContext, Error **errp); =20 } IgvmCfgClass; diff --git a/include/system/igvm.h b/include/system/igvm.h index 8355e54e95..5573a6111a 100644 --- a/include/system/igvm.h +++ b/include/system/igvm.h @@ -12,12 +12,13 @@ #ifndef BACKENDS_IGVM_H #define BACKENDS_IGVM_H =20 +#include "hw/core/boards.h" #include "qemu/typedefs.h" #include "system/confidential-guest-support.h" #include "qapi/error.h" =20 -int qigvm_process_file(IgvmCfg *igvm, ConfidentialGuestSupport *cgs, - bool onlyVpContext, Error **errp); +int qigvm_process_file(IgvmCfg *igvm, MachineState *machine_state, + bool onlyVpContext, Error **errp); =20 /* x86 native */ int qigvm_x86_get_mem_map_entry(int index, diff --git a/target/i386/sev.c b/target/i386/sev.c index 1d70f96ec1..6f86dd710b 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -1891,8 +1891,7 @@ static int sev_common_kvm_init(ConfidentialGuestSuppo= rt *cgs, Error **errp) */ if (x86machine->igvm) { if (IGVM_CFG_GET_CLASS(x86machine->igvm) - ->process(x86machine->igvm, machine->cgs, true, errp) = =3D=3D - -1) { + ->process(x86machine->igvm, machine, true, errp) =3D= =3D -1) { return -1; } /* --=20 2.52.0 From nobody Mon Feb 9 01:51:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1769508251; cv=none; d=zohomail.com; s=zohoarc; b=S0trvSRQG2VbEfemGLRpi7EDC5WCbXk+GPeC7njpSgjIRlgRrpBMIROHqo2ewJkjdgeucRFkzmr4NPOcG+QQyoyhRFL2eOWQDRgPXdM0UPlLG3dEOjmkV+jAqmnT4cjCZNp1QNHrLAeVI+QfyUolyHUz/UJnxM3W8DHQCFA9UGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769508251; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=78qEYGxPGWEZJXeutuZiOnK8kpP41OBXgXR3DQZ5n0c=; b=AWatZs0zT1UQyozujESTe/ntff3Wjcc7LZitQ8VrAfxGheT2rEQZk3P9d5z0nx38Myr5vNVMckcg+FFCbeY10n4USoMaDFCAA4+9i8iRU/oPj0UaTneOHiVTjkwxza3tRSGrdNkRIsBZdnKd6uh0dYB0IuQW1Zzoe876Di2LZSM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769508251639261.4406617435253; Tue, 27 Jan 2026 02:04:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vkfvW-0005za-DF; Tue, 27 Jan 2026 05:04:02 -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 1vkfvS-0005mY-1x for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vkfvQ-0005EF-Ei for qemu-devel@nongnu.org; Tue, 27 Jan 2026 05:03:57 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-iPqbXcF-PBmbKc4lB7fTYg-1; Tue, 27 Jan 2026 05:03:42 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 14D521800365; Tue, 27 Jan 2026 10:03:41 +0000 (UTC) Received: from osteffen-thinkpadx1carbongen12.rmtde.csb (unknown [10.44.34.174]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2BB4A180049F; Tue, 27 Jan 2026 10:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769508235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=78qEYGxPGWEZJXeutuZiOnK8kpP41OBXgXR3DQZ5n0c=; b=QzoxMRkoQvzxy1zBJFWIJ44v1NGDzr11AuGK2iAu8hwXSQkaN3LF3bLKoGHUElbIUUFreA 7A9JkhbOMNc9P7iA+aI4DM6fRNR7Yp0OnCKDz1c0jYooSFQYHrWtif17RcxsC64hG2du54 SGILGauZfA5QIkUE5tYLPp+v5MrIeMk= X-MC-Unique: iPqbXcF-PBmbKc4lB7fTYg-1 X-Mimecast-MFC-AGG-ID: iPqbXcF-PBmbKc4lB7fTYg_1769508221 From: Oliver Steffen To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Eduardo Habkost , Gerd Hoffmann , Stefano Garzarella , Zhao Liu , Marcel Apfelbaum , Igor Mammedov , Marcelo Tosatti , Richard Henderson , Ani Sinha , kvm@vger.kernel.org, "Michael S. Tsirkin" , Luigi Leonardi , Joerg Roedel , Oliver Steffen Subject: [PATCH v5 6/6] igvm: Fill MADT IGVM parameter field Date: Tue, 27 Jan 2026 11:02:57 +0100 Message-ID: <20260127100257.1074104-7-osteffen@redhat.com> In-Reply-To: <20260127100257.1074104-1-osteffen@redhat.com> References: <20260127100257.1074104-1-osteffen@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=osteffen@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1769508253114158500 Content-Type: text/plain; charset="utf-8" Use the new acpi_build_madt_standalone() function to fill the MADT parameter field. The IGVM parameter can be consumed by Coconut SVSM [1], instead of relying on the fw_cfg interface, which has caused problems before due to unexpected access [2,3]. Using IGVM parameters is the default way for Coconut SVSM across hypervisors; switching over would allow removing specialized code paths for QEMU in Coconut. Coconut SVSM needs to know the SMP configuration, but does not look at any other ACPI data, nor does it interact with the PCI bus settings. Since the MADT is static and not linked with other ACPI tables, it can be supplied stand-alone like this. Generating the MADT twice (during ACPI table building and IGVM processing) seems acceptable, since there is no infrastructure to obtain the MADT out of the ACPI table memory area. In any case OVMF, which runs after SVSM has already been initialized, will continue reading all ACPI tables via fw_cfg and provide fixed up ACPI data to the OS as before without any changes. [1] https://github.com/coconut-svsm/svsm/pull/858 [2] https://gitlab.com/qemu-project/qemu/-/issues/2882 [3] https://github.com/coconut-svsm/svsm/issues/646 Signed-off-by: Oliver Steffen --- backends/igvm.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/backends/igvm.c b/backends/igvm.c index f26eb633f8..1d8f807cf6 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -21,6 +21,7 @@ #include "system/memory.h" #include "system/address-spaces.h" #include "hw/core/cpu.h" +#include "hw/i386/acpi-build.h" =20 #include "trace.h" =20 @@ -138,6 +139,8 @@ static int qigvm_directive_snp_id_block(QIgvm *ctx, con= st uint8_t *header_data, static int qigvm_initialization_guest_policy(QIgvm *ctx, const uint8_t *header_data, Error **errp); +static int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, + Error **errp); =20 struct QIGVMHandler { uint32_t type; @@ -166,6 +169,8 @@ static struct QIGVMHandler handlers[] =3D { qigvm_directive_snp_id_block }, { IGVM_VHT_GUEST_POLICY, IGVM_HEADER_SECTION_INITIALIZATION, qigvm_initialization_guest_policy }, + { IGVM_VHT_MADT, IGVM_HEADER_SECTION_DIRECTIVE, + qigvm_directive_madt }, }; =20 static int qigvm_handler(QIgvm *ctx, uint32_t type, Error **errp) @@ -779,6 +784,34 @@ static int qigvm_initialization_guest_policy(QIgvm *ct= x, return 0; } =20 +static int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, + Error **errp) +{ + const IGVM_VHS_PARAMETER *param =3D (const IGVM_VHS_PARAMETER *)header= _data; + QIgvmParameterData *param_entry; + int result =3D 0; + + /* Find the parameter area that should hold the MADT data */ + param_entry =3D qigvm_find_param_entry(ctx, param->parameter_area_inde= x); + if (param_entry =3D=3D NULL) { + return 0; + } + + GArray *madt =3D acpi_build_madt_standalone(ctx->machine_state); + + if (madt->len <=3D param_entry->size) { + memcpy(param_entry->data, madt->data, madt->len); + } else { + error_setg( + errp, + "IGVM: MADT size exceeds parameter area defined in IGVM file"); + result =3D -1; + } + + g_array_free(madt, true); + return result; +} + static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp) { int32_t header_count; --=20 2.52.0