diff options
author | Thomas Huth <thuth@redhat.com> | 2017-11-16 13:17:02 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2017-11-16 18:36:54 +0200 |
commit | 3831c07b89ab1f7aa1427bc56e9cdf70f5367933 (patch) | |
tree | 8c3b2b8a0956bf8d8d1f4fa17fc469183eac6202 /tests/acpi-utils.h | |
parent | f865da7c369fa00b2ccaf6bce158ad2701b2a27c (diff) |
tests/bios-tables-test: Fix endianess problems when passing data to iasl
The bios-tables-test was writing out files that we pass to iasl in
with the wrong endianness in the header when running on a big endian
host. So instead of storing mixed endian information in our structures,
let's keep everything in little endian and byte-swap it only when we
need a value in the code.
Reported-by: Daniel P. Berrange <berrange@redhat.com>
Buglink: https://bugs.launchpad.net/qemu/+bug/1724570
Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Tested-by: "Daniel P. Berrange" <berrange@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'tests/acpi-utils.h')
-rw-r--r-- | tests/acpi-utils.h | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h index f8d87236c6..d5ca5b6238 100644 --- a/tests/acpi-utils.h +++ b/tests/acpi-utils.h @@ -28,24 +28,9 @@ typedef struct { bool tmp_files_retain; /* do not delete the temp asl/aml */ } AcpiSdtTable; -#define ACPI_READ_FIELD(field, addr) \ - do { \ - switch (sizeof(field)) { \ - case 1: \ - field = readb(addr); \ - break; \ - case 2: \ - field = readw(addr); \ - break; \ - case 4: \ - field = readl(addr); \ - break; \ - case 8: \ - field = readq(addr); \ - break; \ - default: \ - g_assert(false); \ - } \ +#define ACPI_READ_FIELD(field, addr) \ + do { \ + memread(addr, &field, sizeof(field)); \ addr += sizeof(field); \ } while (0); @@ -74,16 +59,14 @@ typedef struct { } while (0); #define ACPI_ASSERT_CMP(actual, expected) do { \ - uint32_t ACPI_ASSERT_CMP_le = cpu_to_le32(actual); \ char ACPI_ASSERT_CMP_str[5] = {}; \ - memcpy(ACPI_ASSERT_CMP_str, &ACPI_ASSERT_CMP_le, 4); \ + memcpy(ACPI_ASSERT_CMP_str, &actual, 4); \ g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \ } while (0) #define ACPI_ASSERT_CMP64(actual, expected) do { \ - uint64_t ACPI_ASSERT_CMP_le = cpu_to_le64(actual); \ char ACPI_ASSERT_CMP_str[9] = {}; \ - memcpy(ACPI_ASSERT_CMP_str, &ACPI_ASSERT_CMP_le, 8); \ + memcpy(ACPI_ASSERT_CMP_str, &actual, 8); \ g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \ } while (0) |