hw/arm: xlnx-zynqmp: Don't call qdev_get_machine in soc init
Calling qdev_get_machine() in the soc_init function would result in the following assert ../hw/core/qdev.c:858: qdev_get_machine: Assertion `dev' failed. when trying to run ./qemu-system-aarch64 -S -display none -M virt -device xlnx-zynqmp,help as the machine wasn't created yet. We call qdev_get_machine() to obtain the number of CPUs in the machine. So instead of initialising the CPUs in the SoC init let's instead do it in the realise where the machine will exist. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Tested-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20260312043158.4191378-4-alistair.francis@wdc.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Alistair Francis committed
Mar 12, 2026 at 14:31 UTC
f70ee77f3c1588088396edae33a5ad047383eca8
1 file changed
+18
-24
hw/arm/xlnx-zynqmp.c
+18
-24
@@ -380,30 +380,15 @@ static void xlnx_zynqmp_create_unimp_mmio(XlnxZynqMPState *s)
380
381
static void xlnx_zynqmp_init(Object *obj)
382
{
383
- MachineState *ms = MACHINE(qdev_get_machine());
383
XlnxZynqMPState *s = XLNX_ZYNQMP(obj);
384
int i;
386
- int num_apus = MIN(ms->smp.cpus, XLNX_ZYNQMP_NUM_APU_CPUS);
387
- int num_rpus = xlnx_zynqmp_get_rpu_number(ms);
385
386
object_initialize_child(obj, "apu-cluster", &s->apu_cluster,
387
TYPE_CPU_CLUSTER);
388
qdev_prop_set_uint32(DEVICE(&s->apu_cluster), "cluster-id", 0);
389
393
- for (i = 0; i < num_apus; i++) {
394
- object_initialize_child(OBJECT(&s->apu_cluster), "apu-cpu[*]",
395
- &s->apu_cpu[i],
396
- ARM_CPU_TYPE_NAME("cortex-a53"));
397
- }
398
-
390
object_initialize_child(obj, "gic", &s->gic, gic_class_name());
391
401
- if (num_rpus) {
402
- /* Do not create the rpu_gic if we don't have rpus */
403
- object_initialize_child(obj, "rpu_gic", &s->rpu_gic,
404
- gic_class_name());
405
- }
406
-
392
for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) {
393
object_initialize_child(obj, "gem[*]", &s->gem[i], TYPE_CADENCE_GEM);
394
object_initialize_child(obj, "gem-irq-orgate[*]",
@@ -453,15 +438,6 @@ static void xlnx_zynqmp_init(Object *obj)
438
object_initialize_child(obj, "qspi-irq-orgate",
439
&s->qspi_irq_orgate, TYPE_OR_IRQ);
440
456
- if (num_rpus) {
457
- for (i = 0; i < ARRAY_SIZE(s->splitter); i++) {
458
- g_autofree char *name = g_strdup_printf("irq-splitter%d", i);
459
- object_initialize_child(obj, name, &s->splitter[i], TYPE_SPLIT_IRQ);
460
- }
461
- }
462
-
463
-
464
-
441
for (i = 0; i < XLNX_ZYNQMP_NUM_USB; i++) {
442
object_initialize_child(obj, "usb[*]", &s->usb[i], TYPE_USB_DWC3);
443
}
@@ -483,6 +459,24 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
459
460
ram_size = memory_region_size(s->ddr_ram);
461
462
+ for (i = 0; i < num_apus; i++) {
463
+ object_initialize_child(OBJECT(&s->apu_cluster), "apu-cpu[*]",
464
+ &s->apu_cpu[i],
465
+ ARM_CPU_TYPE_NAME("cortex-a53"));
466
+ }
467
+
468
+ if (num_rpus) {
469
+ /* Do not create the rpu_gic if we don't have rpus */
470
+ object_initialize_child(OBJECT(dev), "rpu_gic", &s->rpu_gic,
471
+ gic_class_name());
472
+
473
+ for (i = 0; i < ARRAY_SIZE(s->splitter); i++) {
474
+ g_autofree char *name = g_strdup_printf("irq-splitter%d", i);
475
+ object_initialize_child(OBJECT(dev), name, &s->splitter[i], TYPE_SPLIT_IRQ);
476
+ }
477
+ }
478
+
479
+
480
/*
481
* Create the DDR Memory Regions. User friendly checks should happen at
482
* the board level