qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ‏ Crash in memory_region_init_ram call chain, when --bios command li


From: Peter Maydell
Subject: Re: ‏ Crash in memory_region_init_ram call chain, when --bios command line parameter is presented.
Date: Tue, 14 Feb 2023 14:17:37 +0000

On Tue, 14 Feb 2023 at 11:54, Alyosha Shevandin
<shevandin_al@hotmail.com> wrote:
>
> Thank you for your answer. I belive that 'owner' parameter is initialized: 1) 
> without --bios parameter the code does not crash; 2) I check the the owner 
> parameter before;
> Here is the fragment of my code:
>
> static void  my_soc_init(MachineState *machine)
> {
>
>       MySocState* state = OBJECT_CHECK(MySocState, machine, TYPE_MY_SOC);

This looks very confused. Generally in QEMU the 'board'
(inherits from MachineState) is a different object from
the SoC (inherits from DeviceState). This code seems to
think they are the same thing.

>       if (!state) {
>             error_report("failed to convert from the parent MachineState to 
> derived MySocState");
>             exit(1);
>       }
>
>       /*
>        * Setup the memories.
>        */
>       memory_region_init_ram(&state->ram,
>                   OBJECT(state),
>                   "mysoc.ram",
>                   mysoc_memmap[MYSOCK_DEV_RAM].size,
>                   &error_abort);

The 'owner' argument to memory_region_init_ram() must be
either NULL or something that inherits from DeviceState.
We use the former for memory regions created by boards, and
the latter for memory regions created by SoC models.
The (cast) MachineState object you are passing is neither,
so you end up with an assertion when the code tries to do
something to it that only works with a DeviceState.

(I'm not sure why this didn't assert in memory_region_init_ram()
when it does the DEVICE() cast on the owner pointer.)

thanks
-- PMM

reply via email to

[Prev in Thread] Current Thread [Next in Thread]