Config table entries are host-endian values but are consumed by the
little-endian Hexagon guest. Serialize the ROM backing storage explicitly.
Fixes: 197870349f2b ("hw/hexagon: add hex-subsys")
Signed-off-by: Brian Cain <[email protected]>
---
include/hw/hexagon/hexagon.h | 1 +
hw/hexagon/hex-subsys.c | 10 +++++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/include/hw/hexagon/hexagon.h b/include/hw/hexagon/hexagon.h
index 548135a7dd9..c4e78216fb8 100644
--- a/include/hw/hexagon/hexagon.h
+++ b/include/hw/hexagon/hexagon.h
@@ -176,6 +176,7 @@ struct HexagonCommonMachineState {
MemoryRegion ram;
MemoryRegion cfgtable_rom;
+ uint32_t cfgtable_data[HEXAGON_CFGSPACE_ENTRIES];
MemoryRegion vtcm;
DeviceState *cluster;
DeviceState *l2vic;
diff --git a/hw/hexagon/hex-subsys.c b/hw/hexagon/hex-subsys.c
index 382f45bd09f..1e6578255eb 100644
--- a/hw/hexagon/hex-subsys.c
+++ b/hw/hexagon/hex-subsys.c
@@ -135,6 +135,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms,
{
MachineState *machine = MACHINE(hms);
MemoryRegion *sysmem = get_system_memory();
+ size_t i;
/* Main DDR. */
memory_region_init_ram(&hms->ram, NULL, "ddr.ram", machine->ram_size,
@@ -145,9 +146,12 @@ void hex_subsys_create(HexagonCommonMachineState *hms,
memory_region_init_rom(&hms->cfgtable_rom, NULL, "config_table.rom",
sizeof(m_cfg->cfgtable), &error_fatal);
memory_region_add_subregion(sysmem, m_cfg->cfgbase, &hms->cfgtable_rom);
- rom_add_blob_fixed_as("config_table.rom", &m_cfg->cfgtable,
- sizeof(m_cfg->cfgtable), m_cfg->cfgbase,
- &address_space_memory);
+ for (i = 0; i < ARRAY_SIZE(hms->cfgtable_data); i++) {
+ hms->cfgtable_data[i] = cpu_to_le32(m_cfg->cfgtable.raw[i]);
+ }
+ rom_add_blob_fixed_as("config_table.rom", hms->cfgtable_data,
+ sizeof(m_cfg->cfgtable), m_cfg->cfgbase,
+ &address_space_memory);
if (m_cfg->cfgtable.vtcm_size_kb > 0) {
memory_region_init_ram(&hms->vtcm, NULL, "vtcm.ram",
--
2.34.1