From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Daniel P. Berrangé" <berrange@redhat.com>,
"Suravee Suthikulpanit" <suravee.suthikulpanit@amd.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com,
richard.henderson@linaro.org, eduardo@habkost.net,
mst@redhat.com, marcel.apfelbaum@gmail.com, imammedo@redhat.com,
jusual@redhat.com, dfaggioli@suse.com, joao.m.martins@oracle.com,
jon.grimm@amd.com, santosh.Shukla@amd.com
Subject: Re: [PATCH v5 1/3] hw/i386/pc: Refactor logic to set SMBIOS defaults
Date: Wed, 7 Jun 2023 10:15:12 +0200 [thread overview]
Message-ID: <cd5d75fb-4df9-5ef1-0abe-4dcad2babf2a@linaro.org> (raw)
In-Reply-To: <ZIA7x5cYNr99mhzd@redhat.com>
On 7/6/23 10:11, Daniel P. Berrangé wrote:
> On Tue, Jun 06, 2023 at 09:49:37PM -0500, Suravee Suthikulpanit wrote:
>> Into a helper function pc_machine_init_smbios() in preparation for
>> subsequent code to upgrade default SMBIOS entry point type.
>>
>> Then, call the helper function from the pc_machine_initfn() to eliminate
>> duplicate code in pc_q35.c and pc_pixx.c. However, this changes the
>> ordering of when the smbios_set_defaults() is called to before
>> pc_machine_set_smbios_ep() (i.e. before handling the user specified
>> QEMU option "-M ...,smbios-entry-point-type=[32|64]" to override
>> the default type.)
>>
>> Therefore, also call the helper function in pc_machine_set_smbios_ep()
>> to update the defaults.
>
> This is unsafe - smbios_set_defaults is only intended to be called
> once. Calling it twice leads to a SEGV due to double-free
>
> $ ./build/qemu-system-x86_64 -machine pc,smbios-entry-point-type=64 -smbios file=/tmp/smbios_entry_point
> Segmentation fault (core dumped)
Doh, good catch.
> IMHO we should just not do this refactoring. The existing duplicated
> code is not a significant burden, and thus is better than having to
> workaround calling pc_machine_set_smbios_ep too early in startup.
>
>>
>> There is no functional change.
I was too confident because of this line ...
>>
>> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>> ---
>> hw/i386/pc.c | 24 +++++++++++++++++++++++-
>> hw/i386/pc_piix.c | 9 ---------
>> hw/i386/pc_q35.c | 8 --------
>> 3 files changed, 23 insertions(+), 18 deletions(-)
next prev parent reply other threads:[~2023-06-07 8:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 2:49 [PATCH v5 0/3] hw/i386/pc: Update max_cpus and default to SMBIOS Suravee Suthikulpanit
2023-06-07 2:49 ` [PATCH v5 1/3] hw/i386/pc: Refactor logic to set SMBIOS defaults Suravee Suthikulpanit
2023-06-07 8:03 ` Philippe Mathieu-Daudé
2023-06-07 8:11 ` Daniel P. Berrangé
2023-06-07 8:15 ` Philippe Mathieu-Daudé [this message]
2023-06-07 20:44 ` Suthikulpanit, Suravee
2023-06-07 13:54 ` Igor Mammedov
2023-06-07 2:49 ` [PATCH v5 2/3] hw/i386/pc: Default to use SMBIOS 3.0 for newer machine models Suravee Suthikulpanit
2023-06-07 13:49 ` Igor Mammedov
2023-06-07 20:41 ` Suthikulpanit, Suravee
2023-06-07 2:49 ` [PATCH v5 3/3] pc: q35: Bump max_cpus to 1024 Suravee Suthikulpanit
2023-06-07 8:26 ` Philippe Mathieu-Daudé
2023-06-07 8:33 ` Daniel P. Berrangé
2023-06-07 13:51 ` Igor Mammedov
2023-06-07 13:52 ` Igor Mammedov
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=cd5d75fb-4df9-5ef1-0abe-4dcad2babf2a@linaro.org \
--to=philmd@linaro.org \
--cc=berrange@redhat.com \
--cc=dfaggioli@suse.com \
--cc=eduardo@habkost.net \
--cc=imammedo@redhat.com \
--cc=joao.m.martins@oracle.com \
--cc=jon.grimm@amd.com \
--cc=jusual@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=santosh.Shukla@amd.com \
--cc=suravee.suthikulpanit@amd.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).