From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: [PULL 2/6] hw/display/cg3: Fix crash when introspecting cgthree from the CLI
Date: Mon, 23 Mar 2026 11:29:16 +0100 [thread overview]
Message-ID: <20260323102920.25170-3-thuth@redhat.com> (raw)
In-Reply-To: <20260323102920.25170-1-thuth@redhat.com>
From: Thomas Huth <thuth@redhat.com>
QEMU currently crashes when introspecting the cgthree device from the
command line interface:
$ ./qemu-system-sparc -device cgthree,help
Segmentation fault (core dumped)
This happens because the memory_region_init_rom() function internally
calls qemu_ram_alloc_internal() that needs the current_machine pointer
to be set up - which is not the case here since the machine has not
been created yet.
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 the realize() function instead to fix this issue.
Tested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260317080623.438230-1-thuth@redhat.com>
---
hw/display/cg3.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index 61bdb0552e9..0a413fbb7ec 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -277,10 +277,13 @@ static const GraphicHwOps cg3_ops = {
.gfx_update = cg3_update_display,
};
-static void cg3_initfn(Object *obj)
+static void cg3_realizefn(DeviceState *dev, Error **errp)
{
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
- CG3State *s = CG3(obj);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+ Object *obj = OBJECT(dev);
+ CG3State *s = CG3(dev);
+ int ret;
+ char *fcode_filename;
memory_region_init_rom(&s->rom, obj, "cg3.prom", FCODE_MAX_ROM_SIZE,
&error_fatal);
@@ -289,14 +292,6 @@ static void cg3_initfn(Object *obj)
memory_region_init_io(&s->reg, obj, &cg3_reg_ops, s, "cg3.reg",
CG3_REG_SIZE);
sysbus_init_mmio(sbd, &s->reg);
-}
-
-static void cg3_realizefn(DeviceState *dev, Error **errp)
-{
- SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
- CG3State *s = CG3(dev);
- int ret;
- char *fcode_filename;
/* FCode ROM */
fcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, CG3_ROM_FILE);
@@ -381,7 +376,6 @@ static const TypeInfo cg3_info = {
.name = TYPE_CG3,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(CG3State),
- .instance_init = cg3_initfn,
.class_init = cg3_class_init,
};
--
2.53.0
next prev parent reply other threads:[~2026-03-23 10:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 10:29 [PULL 0/6] Various fixes for QEMU v11.0-rc1 Thomas Huth
2026-03-23 10:29 ` [PULL 1/6] hw/pci-host/raven: Fix crash when introspecting raven-pcihost from the CLI Thomas Huth
2026-03-23 10:29 ` Thomas Huth [this message]
2026-03-23 10:29 ` [PULL 3/6] hw/sparc/sun4m_iommu: Fix crash when introspecting sun4m-iommu " Thomas Huth
2026-03-23 10:29 ` [PULL 4/6] hw/sparc64/sun4u_iommu: Fix crash when introspecting sun4u-iommu " Thomas Huth
2026-03-23 10:29 ` [PULL 5/6] tests/functional: fix log placement when run directly Thomas Huth
2026-03-23 10:29 ` [PULL 6/6] tests/functional: remove heuristics for finding build dir Thomas Huth
2026-03-23 12:42 ` [PULL 0/6] Various fixes for QEMU v11.0-rc1 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260323102920.25170-3-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=armbru@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.