From: Oliver Steffen <osteffen@redhat.com>
To: qemu-devel@nongnu.org
Cc: Ani Sinha <anisinha@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Eduardo Habkost <eduardo@habkost.net>,
Zhao Liu <zhao1.liu@intel.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Luigi Leonardi <leonardi@redhat.com>,
Joerg Roedel <joerg.roedel@amd.com>,
kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Oliver Steffen <osteffen@redhat.com>
Subject: [PATCH v5 1/6] hw/acpi: Make BIOS linker optional
Date: Tue, 27 Jan 2026 11:02:10 +0100 [thread overview]
Message-ID: <20260127100215.1073575-2-osteffen@redhat.com> (raw)
In-Reply-To: <20260127100215.1073575-1-osteffen@redhat.com>
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 <osteffen@redhat.com>
---
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 */
}
+static uint8_t calculate_acpi_checksum(const gchar *data, size_t len)
+{
+ size_t i;
+ uint8_t sum = 0;
+
+ for (i = 0; i < len; ++i) {
+ sum += (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 = calculate_acpi_checksum(&data[start_offset], table_len);
+ data[checksum_offset] = 0xff - sum + 1;
+}
+
void acpi_table_end(BIOSLinker *linker, AcpiTable *desc)
{
/*
@@ -1748,8 +1767,14 @@ void acpi_table_end(BIOSLinker *linker, AcpiTable *desc)
*/
memcpy(len_ptr, &table_len_le, sizeof table_len_le);
- bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
- desc->table_offset, table_len, desc->table_offset + checksum_offset);
+ if (linker != NULL) {
+ bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
+ desc->table_offset, table_len,
+ desc->table_offset + checksum_offset);
+ } else {
+ update_acpi_checksum(desc->array->data, desc->table_offset,
+ table_len, desc->table_offset + checksum_offset);
+ }
}
void *acpi_data_push(GArray *table_data, unsigned size)
--
2.52.0
next prev parent reply other threads:[~2026-01-27 10:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 10:02 [PATCH v5 0/6] igvm: Supply MADT via IGVM parameter Oliver Steffen
2026-01-27 10:02 ` Oliver Steffen [this message]
2026-01-27 10:02 ` [PATCH v5 2/6] hw/acpi: Add standalone function to build MADT Oliver Steffen
-- strict thread matches above, loose matches on Subject: below --
2026-01-27 10:02 [PATCH v5 0/6] igvm: Supply MADT via IGVM parameter Oliver Steffen
2026-01-27 10:02 ` [PATCH v5 1/6] hw/acpi: Make BIOS linker optional Oliver Steffen
2026-01-29 10:51 ` Luigi Leonardi
2026-01-27 9:59 [PATCH v5 0/6] igvm: Supply MADT via IGVM parameter Oliver Steffen
2026-01-27 9:59 ` [PATCH v5 1/6] hw/acpi: Make BIOS linker optional Oliver Steffen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260127100215.1073575-2-osteffen@redhat.com \
--to=osteffen@redhat.com \
--cc=anisinha@redhat.com \
--cc=eduardo@habkost.net \
--cc=imammedo@redhat.com \
--cc=joerg.roedel@amd.com \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=leonardi@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sgarzare@redhat.com \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox