From bda020e762c4c391e4bf13fd73c093e757f92b3e Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 21 Nov 2023 15:41:27 +0100 Subject: [PATCH] acpi: fix struct acpi_xsdt The size of the ACPI table header is not a multiple of 8. We have to mark struct acpi_xsdt as packed to correctly access field Entry. Add a unit test for the offsets of field Entry in the RSDT and XSDT tables. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- include/acpi/acpi_table.h | 2 +- test/dm/acpi.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h index a3b67259e6..20ac3b51ba 100644 --- a/include/acpi/acpi_table.h +++ b/include/acpi/acpi_table.h @@ -80,7 +80,7 @@ struct acpi_rsdt { }; /* XSDT (Extended System Description Table) */ -struct acpi_xsdt { +struct __packed acpi_xsdt { struct acpi_table_header header; u64 entry[MAX_ACPI_TABLES]; }; diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 5236b3994e..7e661ee116 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -747,3 +747,13 @@ static int dm_test_acpi_find_table(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_acpi_find_table, 0); + +/* Test offsets in RSDT, XSDT */ +static int dm_test_acpi_offsets(struct unit_test_state *uts) +{ + ut_asserteq(36, offsetof(struct acpi_rsdt, entry)); + ut_asserteq(36, offsetof(struct acpi_xsdt, entry)); + + return 0; +} +DM_TEST(dm_test_acpi_offsets, 0); -- 2.39.5