[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC/PATCH v1 10/11] gunyah: Workarounds (NOT FOR MERGE)
From: |
Srivatsa Vaddagiri |
Subject: |
[RFC/PATCH v1 10/11] gunyah: Workarounds (NOT FOR MERGE) |
Date: |
Tue, 9 Jan 2024 09:00:38 +0000 |
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(-)
diff --git a/accel/gunyah/gunyah-all.c b/accel/gunyah/gunyah-all.c
index 3eeecfd286..7d300a16bd 100644
--- a/accel/gunyah/gunyah-all.c
+++ b/accel/gunyah/gunyah-all.c
@@ -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)
{
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 84ea6a807a..77aa16ee8c 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,
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 1aaadc1e1d..798eb70af2 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -165,7 +165,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 },
};
/*
diff --git a/include/sysemu/gunyah_int.h b/include/sysemu/gunyah_int.h
index 72b3027e4e..2534c8883f 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/target/arm/gunyah.c b/target/arm/gunyah.c
index 06600dbdb7..55d5ccc2a4 100644
--- a/target/arm/gunyah.c
+++ b/target/arm/gunyah.c
@@ -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;
--
2.25.1