public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PATCH] hw/sparc/sun4m_iommu: Fix crash when introspecting sun4m-iommu from the CLI
@ 2026-03-17  8:44 Thomas Huth
  2026-03-19 11:21 ` Markus Armbruster
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2026-03-17  8:44 UTC (permalink / raw)
  To: Mark Cave-Ayland, qemu-devel
  Cc: qemu-trivial, BALATON Zoltan, Markus Armbruster, Artyom Tarasenko

From: Thomas Huth <thuth@redhat.com>

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.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/sparc/sun4m_iommu.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/sparc/sun4m_iommu.c b/hw/sparc/sun4m_iommu.c
index ab5eb67072a..1534445992b 100644
--- a/hw/sparc/sun4m_iommu.c
+++ b/hw/sparc/sun4m_iommu.c
@@ -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,
 };
 
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hw/sparc/sun4m_iommu: Fix crash when introspecting sun4m-iommu from the CLI
  2026-03-17  8:44 [PATCH] hw/sparc/sun4m_iommu: Fix crash when introspecting sun4m-iommu from the CLI Thomas Huth
@ 2026-03-19 11:21 ` Markus Armbruster
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Armbruster @ 2026-03-19 11:21 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Mark Cave-Ayland, qemu-devel, qemu-trivial, BALATON Zoltan,
	Artyom Tarasenko

Thomas Huth <thuth@redhat.com> writes:

> From: Thomas Huth <thuth@redhat.com>
>
> 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.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reported-by: Markus Armbruster <armbru@redhat.com>
Tested-by: Markus Armbruster <armbru@redhat.com>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-19 11:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-17  8:44 [PATCH] hw/sparc/sun4m_iommu: Fix crash when introspecting sun4m-iommu from the CLI Thomas Huth
2026-03-19 11:21 ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox