All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Daniel Henrique Barboza <danielhb413@gmail.com>
Cc: qemu-devel@nongnu.org,  Peter Maydell <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org
Subject: Re: [PATCH v2 1/1] hw/arm: do not free machine->fdt in arm_load_dtb()
Date: Tue, 28 Mar 2023 18:58:42 +0200	[thread overview]
Message-ID: <87a5zwx16l.fsf@pond.sub.org> (raw)
In-Reply-To: <f00b7e27-4c9f-226d-d727-241430be1d4c@gmail.com> (Daniel Henrique Barboza's message of "Tue, 28 Mar 2023 09:54:13 -0300")

Daniel Henrique Barboza <danielhb413@gmail.com> writes:

> On 3/28/23 06:53, Markus Armbruster wrote:
>> Daniel Henrique Barboza <danielhb413@gmail.com> writes:

[...]

>>> I believe we can improve the ARM boot code to not create ms->fdt at init(),
>>> leaving it unassigned, and make get_dtb() return the machine FDT on a common
>>> "void *" pointer. That would spare us from having go g_free(ms->fdt) to avoid
>>> leaks and we would assign ms->fdt at the end of arm_load_dtb() normally. I made
>>> a quick attempt at that but the ARM init() code is a little tricker than I've
>>> anticipated. I might have a crack at it later.
>>
>> Do we want a quick interim fix for 8.0?
>> Have a careful look at the untested patch below.
>> 
>>> Thanks,
>>>
>>> Daniel
>>>
>>>
>>>>
>>>>          }
>>>>
>>>>> @@ -689,7 +696,8 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
>>>>>        qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
>>>>>                                           rom_ptr_for_as(as, addr, size));
>>>>>    -    g_free(fdt);
>>>>> +    /* Set ms->fdt for 'dumpdtb' QMP/HMP command */
>>>>> +    ms->fdt = fdt;
>>>>>           return size;
>>>>
>> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
>> index 50e5141116..54f6a3e0b3 100644
>> --- a/hw/arm/boot.c
>> +++ b/hw/arm/boot.c
>> @@ -689,7 +689,10 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
>>       qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
>>                                          rom_ptr_for_as(as, addr, size));
>>   -    g_free(fdt);
>> +    if (fdt != ms->fdt) {
>> +        g_free(ms->fdt);
>> +        ms->fdt = fdt;
>> +    }
>>         return size;
>
> This looks better than what I've been proposing here because it centers everything in
> the same spot. It'll also make it easier to change/remove it when we have the chance
> to take a look at the ARM boot code.
>
> Just tested it here and it works fine. Feel free to format it into a patch and send
> it. I'll give my r-b.

I'm going to send it as v3 with your S-o-B, because I'm stealing most of
your commit message.


      reply	other threads:[~2023-03-28 16:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 20:44 [PATCH v2 0/1] fix dumpdtb crash with ARM machines Daniel Henrique Barboza
2023-03-23 20:44 ` [PATCH v2 1/1] hw/arm: do not free machine->fdt in arm_load_dtb() Daniel Henrique Barboza
2023-03-28  7:01   ` Markus Armbruster
2023-03-28  9:34     ` Daniel Henrique Barboza
2023-03-28  9:53       ` Markus Armbruster
2023-03-28 12:54         ` Daniel Henrique Barboza
2023-03-28 16:58           ` Markus Armbruster [this message]

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=87a5zwx16l.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=danielhb413@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.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.