diff mbox series

[v2,1/2] acpi: fix struct acpi_xsdt

Message ID 20231112070316.17982-2-heinrich.schuchardt@canonical.com
State Superseded
Delegated to: Heinrich Schuchardt
Headers show
Series cmd: acpi: fix acpi list command | expand

Commit Message

Heinrich Schuchardt Nov. 12, 2023, 7:03 a.m. UTC
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 <heinrich.schuchardt@canonical.com>
---
v2:
	add unit test
---
 include/acpi/acpi_table.h |  2 +-
 test/dm/acpi.c            | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

Comments

Simon Glass Nov. 12, 2023, 8:01 p.m. UTC | #1
On Sun, 12 Nov 2023 at 00:03, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> 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 <heinrich.schuchardt@canonical.com>
> ---
> v2:
>         add unit test
> ---
>  include/acpi/acpi_table.h |  2 +-
>  test/dm/acpi.c            | 10 ++++++++++
>  2 files changed, 11 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

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 5997bda649..559cf1693b 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -651,3 +651,13 @@  static int dm_test_acpi_cmd_set(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_acpi_cmd_set, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
+/* 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);