From nobody Mon Feb 9 03:16:00 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=1768413090; cv=none; d=zohomail.com; s=zohoarc; b=ip7gWNBVWSwZUL7Ae6YN0Rb91U9DzoCzU62bfXca/XULS8Z64z1CLneFTjjbcfojEUqYi6YFUmoOQRemKWroaR/Y6F6wnXOxtOmcjcNF8GS19HUMx4zCX/Zjti6es2RErH4cQbbL29F5mQvdBbx/3UAuSr38jDqhtdBCyGZ6qvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768413090; 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=vGtwJX7VVQYuFr2VBiDG+YxC+0YSGXZVi3YOZ3uxtvY=; b=J38lCnsZPxmsXLhhCDeAYM5RQT7QQ46Xj91mlim81KONC7Dnc/6/jMVfX/nyUJ5HdYkxWO5/r+uh1K7Gpbr4tBJvWcPoCFASe8zXl4v7viuTsa4U2u9lzIvsB87nROTIVNvORaQY1IQeupROQdjVRMQhz9IiO0Atr/sqIzwxZOA= 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 1768413090635723.9121878810937; Wed, 14 Jan 2026 09:51:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vg50o-0001mi-DL; Wed, 14 Jan 2026 12:50:30 -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 1vg50m-0001m6-LO for qemu-devel@nongnu.org; Wed, 14 Jan 2026 12:50:28 -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 1vg50l-0008TC-9K for qemu-devel@nongnu.org; Wed, 14 Jan 2026 12:50:28 -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-56-0YMH1tWsNWS6jU4iXZJNig-1; Wed, 14 Jan 2026 12:50:23 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 0476618005AF; Wed, 14 Jan 2026 17:50:22 +0000 (UTC) Received: from osteffen-laptop.redhat.com (unknown [10.45.224.90]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 60FF718007D2; Wed, 14 Jan 2026 17:50:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768413026; 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=vGtwJX7VVQYuFr2VBiDG+YxC+0YSGXZVi3YOZ3uxtvY=; b=UhfjdKwwnHvAY6/IMM3fqEeno4ZkV43EzOnO67ahq+qMXSgtX6jy7fJunV8K1UcUNB3LDK zLDzUtVgZTjcbo474YI9DM6rJlTzuNLw/95Moz54eVdnFsdaV9UTPYx1yGJlopiNIN1W92 jY2S4U6Z9QIjBOFrmTNqw4+aVeMVGVo= X-MC-Unique: 0YMH1tWsNWS6jU4iXZJNig-1 X-Mimecast-MFC-AGG-ID: 0YMH1tWsNWS6jU4iXZJNig_1768413022 From: Oliver Steffen To: qemu-devel@nongnu.org Cc: Marcelo Tosatti , Ani Sinha , Zhao Liu , Joerg Roedel , Richard Henderson , kvm@vger.kernel.org, Paolo Bonzini , Eduardo Habkost , Gerd Hoffmann , "Michael S. Tsirkin" , Igor Mammedov , Stefano Garzarella , Marcel Apfelbaum , Luigi Leonardi , Oliver Steffen Subject: [PATCH v4 1/5] hw/acpi: Make BIOS linker optional Date: Wed, 14 Jan 2026 18:50:03 +0100 Message-ID: <20260114175007.90845-2-osteffen@redhat.com> In-Reply-To: <20260114175007.90845-1-osteffen@redhat.com> References: <20260114175007.90845-1-osteffen@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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 (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: 1768413092730158500 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 2d5826a8f1..0b0baa67f7 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 03:16:00 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=1768413080; cv=none; d=zohomail.com; s=zohoarc; b=mWzD9MfTIky0rAq40AJLH0Q/Eq59cPDGeMXk61++DqnrbQWvLtGXsq1uZdaeD2W4Helqv7lXp/4yTQoLF69Jfyipcxs/MKQzlS5YkXxs3zl19uH/YLVTuHdP/z516oWQur5V32Cw1JKD2KIGWg0YRQgL35dh9kuv7Wroi6/PDgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768413080; 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=kSixgQn8GNVsCRQ0yvhrGPX5c3r8659HCjla8uiavnqua8oxw8KwPVGRVCx3eIsulD1Xhkm43kcoVP3EXgggMdgfsPDNAw3q36FbhN1NsfQ+BXESF85Fqoa7ZrepR6oLijqxLnXguM9nmkrGCRcPNJUZmtU+zWYM+FDdqgE8SN8= 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 1768413080507715.8643184083363; Wed, 14 Jan 2026 09:51:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vg50s-0001nW-Rl; Wed, 14 Jan 2026 12:50:34 -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 1vg50r-0001n5-9Y for qemu-devel@nongnu.org; Wed, 14 Jan 2026 12:50:33 -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 1vg50p-0008TY-Ud for qemu-devel@nongnu.org; Wed, 14 Jan 2026 12:50:33 -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-456-L3KsthLzNiiRluxTJVe7tQ-1; Wed, 14 Jan 2026 12:50:29 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 4270B18005A7; Wed, 14 Jan 2026 17:50:28 +0000 (UTC) Received: from osteffen-laptop.redhat.com (unknown [10.45.224.90]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 95A5F1800665; Wed, 14 Jan 2026 17:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768413031; 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=R5EOo0Xa9vOhoheSvKlg0362rAGisCbt3lUYCdx3yEhNJjYwdC5FmZKUXVy0vel+EcGENv 2pFCh/a6ZlgfhyPobvd+EABMSBVA9R9Rf1fjGiejf8piIE22pN7WqZEHom5YbR3edjCNj9 Xi5he8XDXJ+GjA3ARKdGfpVk1MNU0+Q= X-MC-Unique: L3KsthLzNiiRluxTJVe7tQ-1 X-Mimecast-MFC-AGG-ID: L3KsthLzNiiRluxTJVe7tQ_1768413028 From: Oliver Steffen To: qemu-devel@nongnu.org Cc: Marcelo Tosatti , Ani Sinha , Zhao Liu , Joerg Roedel , Richard Henderson , kvm@vger.kernel.org, Paolo Bonzini , Eduardo Habkost , Gerd Hoffmann , "Michael S. Tsirkin" , Igor Mammedov , Stefano Garzarella , Marcel Apfelbaum , Luigi Leonardi , Oliver Steffen Subject: [PATCH v4 2/5] hw/acpi: Add standalone function to build MADT Date: Wed, 14 Jan 2026 18:50:04 +0100 Message-ID: <20260114175007.90845-3-osteffen@redhat.com> In-Reply-To: <20260114175007.90845-1-osteffen@redhat.com> References: <20260114175007.90845-1-osteffen@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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 (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: 1768413082848158500 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 03:16:00 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=1768413089; cv=none; d=zohomail.com; s=zohoarc; b=gXx11TuAbc/35R78AW5Xnn7JTZs5grXl1bfL/rx84yFGpPJpyKIosiE2NtL8xr0IIndAON9Kj7E7Rx3gxtoikqmK1AOtlRxIYQmNzNwPnNnwubd6f6lsjDTa/xPqoY0VkiiVkFu4yObP1WholPpHDg+dzxsHuEfIrqZ1iQpnXsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768413089; 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=EdTCBkoADw6wT+61kjN+PmuT37K+aJSkJUAlrrepYtE=; b=GidFSrTNrP4wu4j7hKiRk11JOIz0aaGJnAKYiGi0JAbR+QeHs4MF6yW04YqGi9Jn9tdOdVnLOB/aW+yCbzKMCK/XJVIogmRimeDtzsiQfxTjWliDFh4iC82I1JKOQJY//8GiCPqhRVJtVvsZw8ngF6ZONAKwg3nrvOUWpwKPRNg= 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 1768413089680573.3458145066993; Wed, 14 Jan 2026 09:51:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vg513-0001oe-8v; Wed, 14 Jan 2026 12:50:45 -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 1vg510-0001oR-VE for qemu-devel@nongnu.org; Wed, 14 Jan 2026 12:50:42 -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 1vg50z-0008VQ-Ba for qemu-devel@nongnu.org; Wed, 14 Jan 2026 12:50:42 -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-460-3FN-1HY1PDORB1V75az_Qw-1; Wed, 14 Jan 2026 12:50:37 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 8457819560B2; Wed, 14 Jan 2026 17:50:35 +0000 (UTC) Received: from osteffen-laptop.redhat.com (unknown [10.45.224.90]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D1FEB180009E; Wed, 14 Jan 2026 17:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768413040; 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=EdTCBkoADw6wT+61kjN+PmuT37K+aJSkJUAlrrepYtE=; b=MarnSlB3A+704i++ZHiV/6v8TGxSJ7ZYC+YdFNZkDmm9jx3NYWV1gZItj6fTztnOg+r4Xp lcAbHyvKl3yYjJKEHOsYRjF0fgFMgPczvSdvA8fHM3PI6VrPSJj6W9ILRuXoagdvypURDC NMSBSad2g8ReInkLuPP3U30IFo7+pcI= X-MC-Unique: 3FN-1HY1PDORB1V75az_Qw-1 X-Mimecast-MFC-AGG-ID: 3FN-1HY1PDORB1V75az_Qw_1768413035 From: Oliver Steffen To: qemu-devel@nongnu.org Cc: Marcelo Tosatti , Ani Sinha , Zhao Liu , Joerg Roedel , Richard Henderson , kvm@vger.kernel.org, Paolo Bonzini , Eduardo Habkost , Gerd Hoffmann , "Michael S. Tsirkin" , Igor Mammedov , Stefano Garzarella , Marcel Apfelbaum , Luigi Leonardi , Oliver Steffen Subject: [PATCH v4 3/5] igvm: Add common function for finding parameter entries Date: Wed, 14 Jan 2026 18:50:05 +0100 Message-ID: <20260114175007.90845-4-osteffen@redhat.com> In-Reply-To: <20260114175007.90845-1-osteffen@redhat.com> References: <20260114175007.90845-1-osteffen@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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 (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: 1768413090802158500 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. Signed-off-by: Oliver Steffen --- backends/igvm.c | 117 +++++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 56 deletions(-) diff --git a/backends/igvm.c b/backends/igvm.c index a350c890cc..ccb2f51cd9 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -95,6 +95,19 @@ typedef struct QIgvm { unsigned region_page_count; } QIgvm; =20 +static QIgvmParameterData* +qigvm_find_param_entry(QIgvm *igvm, const IGVM_VHS_PARAMETER *param) +{ + QIgvmParameterData *param_entry; + QTAILQ_FOREACH(param_entry, &igvm->parameter_data, next) + { + if (param_entry->index =3D=3D param->parameter_area_index) { + return param_entry; + } + } + 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, @@ -569,58 +582,53 @@ 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); + 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; =20 + 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; + + 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 @@ -655,14 +663,11 @@ 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); + if (param_entry !=3D NULL) { + environmental_state =3D + (IgvmEnvironmentInfo *)(param_entry->data + param->byte_offset= ); + environmental_state->memory_is_shared =3D 1; } return 0; } --=20 2.52.0 From nobody Mon Feb 9 03:16:00 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=1768413081; cv=none; d=zohomail.com; s=zohoarc; b=P5IVC9STeOMO+9uAZdnOAtvoJ/lePcoeQwBvtyaPb2cqt9yiZvopWwbYMG4484rXMllFn59J61zyl6YO7SlSpV2x2U0CMxs66rXR3LPcaKrpvmGqDBdCFLHdFPIyg3rFa+oirNJf9uNV/65JBPgE2ZoyGWLBcYJh6wtJ7yYmrVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768413081; 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=HvCtcU3X4zMESaba3Y3b7w8sMF9sxZxPO6xg8lxyFYQ=; b=fn+9Mtq6aofY+oKqK91dSjPK+waxuWKKeKAFK7FPcfaw0QyOV24WMEUudG/6TjkZ1yt1d2hnrQtDiEObedRCwGmUpSfOKA8sV7PxHDoHMYF+nF7geK6T59bsL5qEgG2Fl/GzUSnuuR1FHztAkbj38iE5UO/w1ze83zDQ+8wLG4c= 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 1768413081383887.9573820779123; Wed, 14 Jan 2026 09:51:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vg51C-0001qJ-Bb; Wed, 14 Jan 2026 12:50:56 -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 1vg517-0001pE-0d for qemu-devel@nongnu.org; Wed, 14 Jan 2026 12:50:50 -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 1vg515-0008W4-09 for qemu-devel@nongnu.org; Wed, 14 Jan 2026 12:50:48 -0500 Received: from mx-prod-mc-08.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-564-tc7883kNPQ2uBFRJqFbSRA-1; Wed, 14 Jan 2026 12:50:42 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 429621800342; Wed, 14 Jan 2026 17:50:41 +0000 (UTC) Received: from osteffen-laptop.redhat.com (unknown [10.45.224.90]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1FB4C1800665; Wed, 14 Jan 2026 17:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768413046; 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=HvCtcU3X4zMESaba3Y3b7w8sMF9sxZxPO6xg8lxyFYQ=; b=QxqBsTRmxADS1SV85dlLzYk/RbI5O+KnLol9uhcPAn7nYqxSuoFcjl+B0Y+C0wFEi476bv fz822JqgXv9Qe3CC6+4Zjli2P5QfyW47GsFkV7oMbrnX3QgJmS0dJ0Mi1B7EHx2KxWIkjl bzzALfM1D+BeTDrEduIZ6cZNko8zRBw= X-MC-Unique: tc7883kNPQ2uBFRJqFbSRA-1 X-Mimecast-MFC-AGG-ID: tc7883kNPQ2uBFRJqFbSRA_1768413041 From: Oliver Steffen To: qemu-devel@nongnu.org Cc: Marcelo Tosatti , Ani Sinha , Zhao Liu , Joerg Roedel , Richard Henderson , kvm@vger.kernel.org, Paolo Bonzini , Eduardo Habkost , Gerd Hoffmann , "Michael S. Tsirkin" , Igor Mammedov , Stefano Garzarella , Marcel Apfelbaum , Luigi Leonardi , Oliver Steffen Subject: [PATCH v4 4/5] igvm: Pass machine state to IGVM file processing Date: Wed, 14 Jan 2026 18:50:06 +0100 Message-ID: <20260114175007.90845-5-osteffen@redhat.com> In-Reply-To: <20260114175007.90845-1-osteffen@redhat.com> References: <20260114175007.90845-1-osteffen@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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 (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: 1768413084806158500 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. Signed-off-by: Oliver Steffen Reviewed-by: Luigi Leonardi --- backends/igvm-cfg.c | 2 +- backends/igvm.c | 30 +++++++++++++++++------------- include/system/igvm-cfg.h | 3 ++- include/system/igvm.h | 5 +++-- target/i386/sev.c | 3 +-- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/backends/igvm-cfg.c b/backends/igvm-cfg.c index c1b45401f4..1b35dc0a49 100644 --- a/backends/igvm-cfg.c +++ b/backends/igvm-cfg.c @@ -51,7 +51,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 ccb2f51cd9..cb2f997c87 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -11,6 +11,7 @@ =20 #include "qemu/osdep.h" =20 +#include "hw/boards.h" #include "qapi/error.h" #include "qemu/target-info-qapi.h" #include "system/igvm.h" @@ -70,7 +71,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; @@ -235,7 +236,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; @@ -355,7 +357,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) { @@ -457,7 +459,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); @@ -525,7 +527,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_UNMEASUR= ED, 0, @@ -568,7 +570,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) { @@ -690,7 +692,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); @@ -808,14 +810,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)) { @@ -823,7 +825,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)) { @@ -896,7 +898,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; @@ -917,8 +919,10 @@ int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuest= Support *cgs, * 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.machine_state =3D machine_state; + 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 7dc48677fd..51bf8d9844 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/boards.h" #include "qom/object.h" #include "hw/resettable.h" =20 @@ -42,7 +43,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 ec2538daa0..ce023fbc9e 100644 --- a/include/system/igvm.h +++ b/include/system/igvm.h @@ -14,11 +14,12 @@ =20 #include "system/confidential-guest-support.h" #include "system/igvm-cfg.h" +#include "hw/boards.h" #include "qapi/error.h" =20 IgvmHandle qigvm_file_init(char *filename, Error **errp); -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 fd2dada013..91a55ebd81 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -1892,8 +1892,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 03:16:00 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=1768413095; cv=none; d=zohomail.com; s=zohoarc; b=HIA0KCq6pWhu6O5X3aa0s00lHodZCopUrNYMNf0uuYdnua673f1VooGm5/B8BaGOyo1VNuJCCbrZc+yP8A3s6UIA3bFJGFnxFNdftBnI1XnB904WDcoq8ZslRplMT8cEWX6voQTQn6GY7qrw5m5PEKH6Ys3Bzcd51bywT4Q281E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768413095; 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=Z97WeNJlMmycR+z4WcgaMcn3WWTu94HVQEJdZml9px0=; b=Ey09YXIdwGCBGYFELWKE4kxVsp7XMeP6yE+AVVosKKJ2eiRVuNzsROYTo9iOEoz6evoGPHKhwuEV7PcutpK8aItgU4cvpqRjedVcGAXvDCJU9jicEvfCCIqJkyeo69vvZwFQe9UOXBzN95CXrt7WDxNqfD0Z4GDG9V22qJAHMDc= 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 1768413095328244.5073523177058; Wed, 14 Jan 2026 09:51:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vg51I-0001ry-Bp; Wed, 14 Jan 2026 12:51:00 -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 1vg51E-0001r8-Br for qemu-devel@nongnu.org; Wed, 14 Jan 2026 12:50:56 -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 1vg51C-000057-1N for qemu-devel@nongnu.org; Wed, 14 Jan 2026 12:50:55 -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-613-8Z-IX3osPFKhDOfCdHM3tQ-1; Wed, 14 Jan 2026 12:50:48 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 0FDE41955DC7; Wed, 14 Jan 2026 17:50:47 +0000 (UTC) Received: from osteffen-laptop.redhat.com (unknown [10.45.224.90]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D30B11800665; Wed, 14 Jan 2026 17:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768413052; 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=Z97WeNJlMmycR+z4WcgaMcn3WWTu94HVQEJdZml9px0=; b=eOmxNGnu3D7Ve773XV+rV4NDG65F7KSfHY0O2cDtwWHJzyw3nnLXYSeJ2F/YpS88a/Irx6 sRjRCoyIuEo6K428q2aTKWrcIYo8G0UWXTnDTto4zyHrDwGyBkzfjyuivp4hc4L5Fg/Tz0 /dhlZMv26pMj4k0llDDhX+1xzj3AUKQ= X-MC-Unique: 8Z-IX3osPFKhDOfCdHM3tQ-1 X-Mimecast-MFC-AGG-ID: 8Z-IX3osPFKhDOfCdHM3tQ_1768413047 From: Oliver Steffen To: qemu-devel@nongnu.org Cc: Marcelo Tosatti , Ani Sinha , Zhao Liu , Joerg Roedel , Richard Henderson , kvm@vger.kernel.org, Paolo Bonzini , Eduardo Habkost , Gerd Hoffmann , "Michael S. Tsirkin" , Igor Mammedov , Stefano Garzarella , Marcel Apfelbaum , Luigi Leonardi , Oliver Steffen Subject: [PATCH v4 5/5] igvm: Fill MADT IGVM parameter field Date: Wed, 14 Jan 2026 18:50:07 +0100 Message-ID: <20260114175007.90845-6-osteffen@redhat.com> In-Reply-To: <20260114175007.90845-1-osteffen@redhat.com> References: <20260114175007.90845-1-osteffen@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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 (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: 1768413096811158500 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 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/backends/igvm.c b/backends/igvm.c index cb2f997c87..980068fb58 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -18,6 +18,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 @@ -134,6 +135,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; @@ -162,6 +165,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) @@ -771,6 +776,33 @@ 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); + if (param_entry !=3D NULL) { + + 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 fi= le"); + 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