]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
acpi: fix initial RSDT and XSDT size
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 20 Apr 2026 16:47:25 +0000 (18:47 +0200)
committerSimon Glass <sjg@chromium.org>
Mon, 11 May 2026 18:04:43 +0000 (12:04 -0600)
When creating the RSDT and the XSDT table they contain no entries.
The table size therefore must equal the header size.

Without this change a NULL deference has been observed in
acpi_find_table() when running `ut dm` on sandbox64_defconfig
executed via `sudo ./u-boot -D`.

Fixes: 94ba15a3f13f ("x86: Move base tables to a writer function")
Fixes: 7e586f69070d ("acpi: Put table-setup code in its own function")
Fixes: ab5efd576c4e ("x86: acpi: Adjust order in acpi_table.c")
Fixes: 867bcb63e79f ("x86: Generate a valid ACPI table")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Update dm_test_acpi_ctx_and_base_tables() in test/dm/acpi.c to expect
sizeof(struct acpi_table_header) for the initial table length (instead
of sizeof(*rsdt) / sizeof(*xsdt)), and to compute the checksum over
header->length bytes rather than the full struct size:
Signed-off-by: Simon Glass <sjg@chromium.org>
lib/acpi/base.c
test/dm/acpi.c

index 5c755b14c161cf25077aaff596b29e169b590e91..01ebad8994ae6452ae69e79887e764cc307d62e7 100644 (file)
@@ -44,7 +44,7 @@ static void acpi_write_rsdt(struct acpi_rsdt *rsdt)
 
        /* Fill out header fields */
        acpi_fill_header(header, "RSDT");
-       header->length = sizeof(struct acpi_rsdt);
+       header->length = sizeof(struct acpi_table_header);
        header->revision = 1;
 
        /* Entries are filled in later, we come with an empty set */
@@ -59,7 +59,7 @@ static void acpi_write_xsdt(struct acpi_xsdt *xsdt)
 
        /* Fill out header fields */
        acpi_fill_header(header, "XSDT");
-       header->length = sizeof(struct acpi_xsdt);
+       header->length = sizeof(struct acpi_table_header);
        header->revision = 1;
 
        /* Entries are filled in later, we come with an empty set */
index 559ea269de202caa32d0a18f5dfbf90a9cc62430..2de7983f9ae995dc3b806d9baef468f68be1959c 100644 (file)
@@ -374,14 +374,14 @@ static int dm_test_acpi_ctx_and_base_tables(struct unit_test_state *uts)
        rsdt = PTR_ALIGN((void *)rsdp + sizeof(*rsdp), 16);
        ut_asserteq_ptr(rsdt, ctx.rsdt);
        ut_asserteq_mem("RSDT", rsdt->header.signature, ACPI_NAME_LEN);
-       ut_asserteq(sizeof(*rsdt), rsdt->header.length);
-       ut_assertok(table_compute_checksum(rsdt, sizeof(*rsdt)));
+       ut_asserteq(sizeof(struct acpi_table_header), rsdt->header.length);
+       ut_assertok(table_compute_checksum(rsdt, rsdt->header.length));
 
        xsdt = PTR_ALIGN((void *)rsdt + sizeof(*rsdt), 16);
        ut_asserteq_ptr(xsdt, ctx.xsdt);
        ut_asserteq_mem("XSDT", xsdt->header.signature, ACPI_NAME_LEN);
-       ut_asserteq(sizeof(*xsdt), xsdt->header.length);
-       ut_assertok(table_compute_checksum(xsdt, sizeof(*xsdt)));
+       ut_asserteq(sizeof(struct acpi_table_header), xsdt->header.length);
+       ut_assertok(table_compute_checksum(xsdt, xsdt->header.length));
 
        end = PTR_ALIGN((void *)xsdt + sizeof(*xsdt), 64);
        ut_asserteq_ptr(end, ctx.current);