hw/sparc64/sun4u_iommu: Fix crash when introspecting sun4u-iommu from the CLI
QEMU currently crashes when introspecting the sun4u-iommu device from the command line interface: $ ./qemu-system-sparc64 -display none -device sun4u-iommu,help qemu-system-sparc64: ../../devel/qemu/system/physmem.c:1401: register_multipage: Assertion `num_pages' failed. Aborted (core dumped) There does not seem to be a compelling reason for initializing the memory regions from the instance_init function, so let's simply move the code into a realize() function instead to fix this issue. Reported-by: Markus Armbruster <armbru@redhat.com> Tested-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Message-ID: <20260317085839.445178-1-thuth@redhat.com>
Thomas Huth committed
Mar 17, 2026 at 09:58 UTC
d319a3a899ec901aa6f913b8b4cc06cf13528082
1 file changed
+6
-5
hw/sparc64/sun4u_iommu.c
+6
-5
@@ -290,13 +290,14 @@ static void iommu_reset(DeviceState *d)
290
memset(s->regs, 0, IOMMU_NREGS * sizeof(uint64_t));
291
}
292
293
-static void iommu_init(Object *obj)
293
+static void iommu_realize(DeviceState *ds, Error **errp)
294
{
295
- IOMMUState *s = SUN4U_IOMMU(obj);
296
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
295
+ IOMMUState *s = SUN4U_IOMMU(ds);
296
+ SysBusDevice *sbd = SYS_BUS_DEVICE(ds);
297
+ Object *obj = OBJECT(ds);
298
299
memory_region_init_iommu(&s->iommu, sizeof(s->iommu),
299
- TYPE_SUN4U_IOMMU_MEMORY_REGION, OBJECT(s),
300
+ TYPE_SUN4U_IOMMU_MEMORY_REGION, obj,
301
"iommu-sun4u", UINT64_MAX);
302
address_space_init(&s->iommu_as, MEMORY_REGION(&s->iommu), "iommu-as");
303
@@ -310,13 +311,13 @@ static void iommu_class_init(ObjectClass *klass, const void *data)
311
DeviceClass *dc = DEVICE_CLASS(klass);
312
313
device_class_set_legacy_reset(dc, iommu_reset);
314
+ dc->realize = iommu_realize;
315
}
316
317
static const TypeInfo iommu_info = {
318
.name = TYPE_SUN4U_IOMMU,
319
.parent = TYPE_SYS_BUS_DEVICE,
320
.instance_size = sizeof(IOMMUState),
319
- .instance_init = iommu_init,
321
.class_init = iommu_class_init,
322
};
323