These are some work-arounds required temporarily until some limitations with Gunyah hypervisor are addressed.
Signed-off-by: Srivatsa Vaddagiri <quic_svadd...@quicinc.com> --- include/sysemu/gunyah_int.h | 1 + accel/gunyah/gunyah-all.c | 18 ++++++++++++++++++ hw/arm/boot.c | 17 ++++++++++++++++- hw/arm/virt.c | 3 ++- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/sysemu/gunyah_int.h b/include/sysemu/gunyah_int.h index ef82c6edd8..bdda430dbd 100644 --- a/include/sysemu/gunyah_int.h +++ b/include/sysemu/gunyah_int.h @@ -62,5 +62,6 @@ int gunyah_add_irqfd(int irqfd, int label, Error **errp); GUNYAHState *get_gunyah_state(void); int gunyah_arch_put_registers(CPUState *cs, int level); void gunyah_cpu_synchronize_post_reset(CPUState *cpu); +gunyah_slot *gunyah_find_slot_by_addr(uint64_t addr); #endif /* GUNYAH_INT_H */ diff --git a/accel/gunyah/gunyah-all.c b/accel/gunyah/gunyah-all.c index 4c56dd8c73..bc106fbad6 100644 --- a/accel/gunyah/gunyah-all.c +++ b/accel/gunyah/gunyah-all.c @@ -158,6 +158,24 @@ static gunyah_slot *gunyah_find_overlap_slot(GUNYAHState *s, return NULL; } +gunyah_slot *gunyah_find_slot_by_addr(uint64_t addr) +{ + GUNYAHState *s = GUNYAH_STATE(current_accel()); + int i; + gunyah_slot *slot = NULL; + + gunyah_slots_lock(s); + for (i = 0; i < s->nr_slots; ++i) { + slot = &s->slots[i]; + if (slot->size && + (addr >= slot->start && addr <= slot->start + slot->size)) + break; + } + gunyah_slots_unlock(s); + + return slot; +} + /* Called with s->slots_lock held */ static gunyah_slot *gunyah_get_free_slot(GUNYAHState *s) { diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 84ea6a807a..a29b2cb0f9 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -413,7 +413,8 @@ static int fdt_add_memory_node(void *fdt, uint32_t acells, hwaddr mem_base, char *nodename; int ret; - nodename = g_strdup_printf("/memory@%" PRIx64, mem_base); + /* Workaround until RM can parse memory nodes of type memory@XYZ. */ + nodename = g_strdup_printf("/memory"); qemu_fdt_add_subnode(fdt, nodename); qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); ret = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", acells, mem_base, @@ -661,6 +662,20 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, binfo->modify_dtb(binfo, fdt); } + /* + * Gunyah RM inspects and modifies device-tree (to provide additional + * information that VM may need). It depends on knowing total size reserved + * for device-tree (i.e FDT_MAX_SIZE) and current size (via @totalsize). At + * this point however, @totalsize = FDT_MAX_SIZE, making RM think that there + * is no room for modification and fail to start VM. + * + * RM should ideally pack device-tree so that @totalsize reflects the actual + * size before it attempts modification. Until RM is fixed, pack + * device-tree so that @toalsize reflects the actual size. + */ + + fdt_pack(fdt); + qemu_fdt_dumpdtb(fdt, size); /* Put the DTB into the memory map as a ROM image: this will ensure diff --git a/hw/arm/virt.c b/hw/arm/virt.c index b0132beddd..5f3075e748 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -188,7 +188,8 @@ static const MemMapEntry base_memmap[] = { [VIRT_PCIE_PIO] = { 0x3eff0000, 0x00010000 }, [VIRT_PCIE_ECAM] = { 0x3f000000, 0x01000000 }, /* Actual RAM size depends on initial RAM and device memory settings */ - [VIRT_MEM] = { GiB, LEGACY_RAMLIMIT_BYTES }, + /* Workaround until Gunyah can accept mapping that starts from GiB */ + [VIRT_MEM] = { 2 * GiB, LEGACY_RAMLIMIT_BYTES }, }; /* -- 2.25.1