hw/arm: fsl-imx8mm: Don't call qdev_get_machine in init
Calling qdev_get_machine() from fsl_imx8mm_init() can trigger
an assertion failure because the machine may not be created yet.
Reproducer:
./qemu-system-aarch64 -S -display none \
-M virt -device fsl-imx8mm,help
This hits:
../hw/core/qdev.c:844: Object *qdev_get_machine(void):
Assertion `dev' failed.
Move the CPU initialization into realize(), where accessing the
machine state is safe.
(This is the same issue we fixed in the fsl-imx8mp machine
in commit b67d0bcdd41c; we apply the same fix here.)
Signed-off-by: Vineet Agarwal <agarwal.vineet2006@gmail.com>
Message-id: 20260511115918.32765-1-agarwal.vineet2006@gmail.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
committed by
Peter Maydell
parent
4c59b490ba
commit
248e17e47a
@@ -157,16 +157,9 @@ static const struct {
|
||||
|
||||
static void fsl_imx8mm_init(Object *obj)
|
||||
{
|
||||
MachineState *ms = MACHINE(qdev_get_machine());
|
||||
FslImx8mmState *s = FSL_IMX8MM(obj);
|
||||
const char *cpu_type = ms->cpu_type ?: ARM_CPU_TYPE_NAME("cortex-a53");
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MIN(ms->smp.cpus, FSL_IMX8MM_NUM_CPUS); i++) {
|
||||
g_autofree char *name = g_strdup_printf("cpu%d", i);
|
||||
object_initialize_child(obj, name, &s->cpu[i], cpu_type);
|
||||
}
|
||||
|
||||
object_initialize_child(obj, "gic", &s->gic, gicv3_class_name());
|
||||
|
||||
object_initialize_child(obj, "ccm", &s->ccm, TYPE_IMX8MP_CCM);
|
||||
@@ -229,6 +222,8 @@ static void fsl_imx8mm_realize(DeviceState *dev, Error **errp)
|
||||
MachineState *ms = MACHINE(qdev_get_machine());
|
||||
FslImx8mmState *s = FSL_IMX8MM(dev);
|
||||
DeviceState *gicdev = DEVICE(&s->gic);
|
||||
const char *cpu_type =
|
||||
ms->cpu_type ?: ARM_CPU_TYPE_NAME("cortex-a53");
|
||||
int i;
|
||||
|
||||
if (ms->smp.cpus > FSL_IMX8MM_NUM_CPUS) {
|
||||
@@ -237,6 +232,12 @@ static void fsl_imx8mm_realize(DeviceState *dev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < ms->smp.cpus; i++) {
|
||||
g_autofree char *name = g_strdup_printf("cpu%d", i);
|
||||
object_initialize_child(OBJECT(dev), name,
|
||||
&s->cpu[i], cpu_type);
|
||||
}
|
||||
|
||||
/* CPUs */
|
||||
for (i = 0; i < ms->smp.cpus; i++) {
|
||||
/* On uniprocessor, the CBAR is set to 0 */
|
||||
|
||||
Reference in New Issue
Block a user