summary refs log tree commit diff stats
path: root/hw/xen/xen-pvh-common.c
diff options
context:
space:
mode:
authorEdgar E. Iglesias <edgar.iglesias@amd.com>2024-08-09 15:39:04 +0200
committerEdgar E. Iglesias <edgar.iglesias@amd.com>2024-09-04 16:50:43 +0200
commit692ec9337b93729365a6c55bd1aad8da94a877ca (patch)
treeb02191d81374e13b9f9a07fc07f77e0c08125492 /hw/xen/xen-pvh-common.c
parent0e14c9eb55696a13cd0c9545fbc0a9de5f340015 (diff)
downloadfocaccia-qemu-692ec9337b93729365a6c55bd1aad8da94a877ca.tar.gz
focaccia-qemu-692ec9337b93729365a6c55bd1aad8da94a877ca.zip
hw/arm: xenpvh: Reverse virtio-mmio creation order
We've been creating the virtio-mmio devices in forwards order
but since the qbus lists prepend (rather than append) entries,
the virtio busses end up with decreasing base address order.

Xen enables virtio-mmio nodes in forwards order so there's been
a missmatch. So far, we've been working around this with an
out-of-tree patch to Xen.

This reverses the order making sure the virtio busses end up
ordered with increasing base addresses avoiding the need to
patch Xen.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Diffstat (limited to 'hw/xen/xen-pvh-common.c')
-rw-r--r--hw/xen/xen-pvh-common.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/hw/xen/xen-pvh-common.c b/hw/xen/xen-pvh-common.c
index 880e8143d7..295f920442 100644
--- a/hw/xen/xen-pvh-common.c
+++ b/hw/xen/xen-pvh-common.c
@@ -75,7 +75,18 @@ static void xen_create_virtio_mmio_devices(XenPVHMachineState *s)
 {
     int i;
 
-    for (i = 0; i < s->cfg.virtio_mmio_num; i++) {
+    /*
+     * We create the transports in reverse order. Since qbus_realize()
+     * prepends (not appends) new child buses, the decrementing loop below will
+     * create a list of virtio-mmio buses with increasing base addresses.
+     *
+     * When a -device option is processed from the command line,
+     * qbus_find_recursive() picks the next free virtio-mmio bus in forwards
+     * order.
+     *
+     * This is what the Xen tools expect.
+     */
+    for (i = s->cfg.virtio_mmio_num - 1; i >= 0; i--) {
         hwaddr base = s->cfg.virtio_mmio.base + i * s->cfg.virtio_mmio.size;
         qemu_irq irq = qemu_allocate_irq(xen_set_irq, NULL,
                                          s->cfg.virtio_mmio_irq_base + i);