mirror of
https://github.com/qemu/qemu.git
synced 2026-04-05 22:00:58 +00:00
hw/sparc/sun4m_iommu: Fix crash when introspecting sun4m-iommu from the CLI
QEMU currently crashes when introspecting the sun4m-iommu device from the command line interface: $ ./qemu-system-sparc -display none -device sun4m-iommu,help qemu-system-sparc: ../../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: <20260317084450.442071-1-thuth@redhat.com>
This commit is contained in:
@@ -351,13 +351,14 @@ static void iommu_reset(DeviceState *d)
|
||||
s->regs[IOMMU_MASK_ID] = IOMMU_TS_MASK;
|
||||
}
|
||||
|
||||
static void iommu_init(Object *obj)
|
||||
static void iommu_realize(DeviceState *ds, Error **errp)
|
||||
{
|
||||
IOMMUState *s = SUN4M_IOMMU(obj);
|
||||
SysBusDevice *dev = SYS_BUS_DEVICE(obj);
|
||||
IOMMUState *s = SUN4M_IOMMU(ds);
|
||||
SysBusDevice *dev = SYS_BUS_DEVICE(ds);
|
||||
Object *obj = OBJECT(ds);
|
||||
|
||||
memory_region_init_iommu(&s->iommu, sizeof(s->iommu),
|
||||
TYPE_SUN4M_IOMMU_MEMORY_REGION, OBJECT(dev),
|
||||
TYPE_SUN4M_IOMMU_MEMORY_REGION, obj,
|
||||
"iommu-sun4m", UINT64_MAX);
|
||||
address_space_init(&s->iommu_as, MEMORY_REGION(&s->iommu), "iommu-as");
|
||||
|
||||
@@ -377,6 +378,7 @@ static void iommu_class_init(ObjectClass *klass, const void *data)
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
|
||||
device_class_set_legacy_reset(dc, iommu_reset);
|
||||
dc->realize = iommu_realize;
|
||||
dc->vmsd = &vmstate_iommu;
|
||||
device_class_set_props(dc, iommu_properties);
|
||||
}
|
||||
@@ -385,7 +387,6 @@ static const TypeInfo iommu_info = {
|
||||
.name = TYPE_SUN4M_IOMMU,
|
||||
.parent = TYPE_SYS_BUS_DEVICE,
|
||||
.instance_size = sizeof(IOMMUState),
|
||||
.instance_init = iommu_init,
|
||||
.class_init = iommu_class_init,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user