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/vmgenid-test.c | |
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/vmgenid-test.c')
-rw-r--r-- | tests/vmgenid-test.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index b6e7b3b086..5a86b40775 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -38,7 +38,7 @@ static uint32_t acpi_find_vgia(void) uint32_t rsdp_offset; uint32_t guid_offset = 0; AcpiRsdpDescriptor rsdp_table; - uint32_t rsdt; + uint32_t rsdt, rsdt_table_length; AcpiRsdtDescriptorRev1 rsdt_table; size_t tables_nr; uint32_t *tables; @@ -56,14 +56,15 @@ static uint32_t acpi_find_vgia(void) acpi_parse_rsdp_table(rsdp_offset, &rsdp_table); - rsdt = rsdp_table.rsdt_physical_address; + rsdt = le32_to_cpu(rsdp_table.rsdt_physical_address); /* read the header */ ACPI_READ_TABLE_HEADER(&rsdt_table, rsdt); ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT"); + rsdt_table_length = le32_to_cpu(rsdt_table.length); /* compute the table entries in rsdt */ - g_assert_cmpint(rsdt_table.length, >, sizeof(AcpiRsdtDescriptorRev1)); - tables_nr = (rsdt_table.length - sizeof(AcpiRsdtDescriptorRev1)) / + g_assert_cmpint(rsdt_table_length, >, sizeof(AcpiRsdtDescriptorRev1)); + tables_nr = (rsdt_table_length - sizeof(AcpiRsdtDescriptorRev1)) / sizeof(uint32_t); /* get the addresses of the tables pointed by rsdt */ @@ -71,23 +72,24 @@ static uint32_t acpi_find_vgia(void) ACPI_READ_ARRAY_PTR(tables, tables_nr, rsdt); for (i = 0; i < tables_nr; i++) { - ACPI_READ_TABLE_HEADER(&ssdt_table, tables[i]); + uint32_t addr = le32_to_cpu(tables[i]); + ACPI_READ_TABLE_HEADER(&ssdt_table, addr); if (!strncmp((char *)ssdt_table.oem_table_id, "VMGENID", 7)) { /* the first entry in the table should be VGIA * That's all we need */ - ACPI_READ_FIELD(vgid_table.name_op, tables[i]); + ACPI_READ_FIELD(vgid_table.name_op, addr); g_assert(vgid_table.name_op == 0x08); /* name */ - ACPI_READ_ARRAY(vgid_table.vgia, tables[i]); + ACPI_READ_ARRAY(vgid_table.vgia, addr); g_assert(memcmp(vgid_table.vgia, "VGIA", 4) == 0); - ACPI_READ_FIELD(vgid_table.val_op, tables[i]); + ACPI_READ_FIELD(vgid_table.val_op, addr); g_assert(vgid_table.val_op == 0x0C); /* dword */ - ACPI_READ_FIELD(vgid_table.vgia_val, tables[i]); + ACPI_READ_FIELD(vgid_table.vgia_val, addr); /* The GUID is written at a fixed offset into the fw_cfg file * in order to implement the "OVMF SDT Header probe suppressor" * see docs/specs/vmgenid.txt for more details */ - guid_offset = vgid_table.vgia_val + VMGENID_GUID_OFFSET; + guid_offset = le32_to_cpu(vgid_table.vgia_val) + VMGENID_GUID_OFFSET; break; } } |