Skip to contentSkip to conversation

tests/acpi: don't pack a structure

PATCH In review Michael S. Tsirkin 2 participants 2 messages Mar 30, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/acpi: don't pack a structure

There's no reason to pack structures where we don't care about size or padding, this applies to AcpiStdTable in tests/acpi-utils.h.

OTOH bios-tables-test happens to be passing the address of a field in this struct to a function that expects a pointer to normally aligned data which results in a SIGBUS on architectures like SPARC that have strict alignment requirements.

Fixes 9e8458c02 ("acpi unit-test: compare DSDT and SSDT tables against expected values")
---
 tests/acpi-utils.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/acpi-utils.h +1 -1
index 9f9a2d5..348e4d7 100644
@@ -26,7 +26,7 @@ typedef struct {
     gsize asl_len;
     gchar *asl_file;
     bool tmp_files_retain;   /* do not delete the temp asl/aml */
-} QEMU_PACKED AcpiSdtTable;
+} AcpiSdtTable;
 
 #define ACPI_READ_FIELD(field, addr)           \
     do {                                       \
Signature · 1 line
MST
Tested-by on v1 1/1
#1 lore raw
Quoted 20 lines · Michael S. Tsirkin

There's no reason to pack structures where we don't care about size or padding, this applies to AcpiStdTable in tests/acpi-utils.h.

OTOH bios-tables-test happens to be passing the address of a field in this struct to a function that expects a pointer to normally aligned data which results in a SIGBUS on architectures like SPARC that have strict alignment requirements.

Fixes 9e8458c02 ("acpi unit-test: compare DSDT and SSDT tables against expected values")
---
 tests/acpi-utils.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/acpi-utils.h +0 -0
index 9f9a2d5..348e4d7 100644

tests/acpi-utils.h typedef struct { · line 32

Quoted 8 lines
tests/acpi-utils.h +1 -1
@@ -26,7 +26,7 @@ typedef struct {
     gsize asl_len;
     gchar *asl_file;
     bool tmp_files_retain;   /* do not delete the temp asl/aml */
-} QEMU_PACKED AcpiSdtTable;
+} AcpiSdtTable;
 
 #define ACPI_READ_FIELD(field, addr)           \
     do {                                       \

Yes, this fixes the SPARC crashes.

thanks
-- PMM