@@ -145,6 +145,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)
{
@@ -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,
@@ -164,7 +164,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 },
};
/*
@@ -56,5 +56,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 */
@@ -34,6 +34,13 @@ int gunyah_arm_set_dtb(__u64 dtb_start, __u64 dtb_size)
{
int ret;
struct gh_vm_dtb_config dtb;
+ gunyah_slot *slot = gunyah_find_slot_by_addr(dtb_start);
+
+ /*
+ * RM should consider 'totalsize' field to be inclusive of free space. Use
+ * this workaround until RM is fixed.
+ */
+ dtb_size = slot->start + slot->size - dtb_start;
dtb.guest_phys_addr = dtb_start;
dtb.size = dtb_size;
These are some work-arounds required temporarily until some limitations with Gunyah hypervisor are addressed. Signed-off-by: Srivatsa Vaddagiri <quic_svaddagi@quicinc.com> --- accel/gunyah/gunyah-all.c | 18 ++++++++++++++++++ hw/arm/boot.c | 3 ++- hw/arm/virt.c | 3 ++- include/sysemu/gunyah_int.h | 1 + target/arm/gunyah.c | 7 +++++++ 5 files changed, 30 insertions(+), 2 deletions(-)