From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>, qemu-devel@nongnu.org
Cc: deller@gmx.de, mark.cave-ayland@ilande.co.uk,
qemu-ppc@nongnu.org, hpoussin@reactos.org,
david@gibson.dropbear.id.au, atar4qemu@gmail.com,
rth@twiddle.net
Subject: Re: [PATCH 2/3] ppc: rs6000_mc: drop usage of memory_region_allocate_system_memory()
Date: Tue, 8 Oct 2019 14:24:20 +0200 [thread overview]
Message-ID: <9a6951b6-e8d6-90ff-727a-62c2a188660b@redhat.com> (raw)
In-Reply-To: <20191008113318.7012-3-imammedo@redhat.com>
On 10/8/19 1:33 PM, Igor Mammedov wrote:
> rs6000mc_realize() violates memory_region_allocate_system_memory() contract
> by calling it multiple times which could break -mem-path. Replace it with
> plain memory_region_init_ram() instead.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/ppc/rs6000_mc.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/hw/ppc/rs6000_mc.c b/hw/ppc/rs6000_mc.c
> index df7c0006fc..66b14db5fa 100644
> --- a/hw/ppc/rs6000_mc.c
> +++ b/hw/ppc/rs6000_mc.c
> @@ -144,6 +144,7 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)
> RS6000MCState *s = RS6000MC_DEVICE(dev);
> int socket = 0;
> unsigned int ram_size = s->ram_size / MiB;
> + Error *local_err = NULL;
>
> while (socket < 6) {
> if (ram_size >= 64) {
> @@ -165,19 +166,21 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)
> if (s->simm_size[socket]) {
> char name[] = "simm.?";
> name[5] = socket + '0';
> - memory_region_allocate_system_memory(&s->simm[socket], OBJECT(dev),
> - name,
> - s->simm_size[socket] * MiB);
> + memory_region_init_ram(&s->simm[socket], OBJECT(dev), name,
> + s->simm_size[socket] * MiB, &local_err);
> + if (local_err) {
> + goto out;
> + }
> memory_region_add_subregion_overlap(get_system_memory(), 0,
> &s->simm[socket], socket);
> }
> }
> if (ram_size) {
> /* unable to push all requested RAM in SIMMs */
> - error_setg(errp, "RAM size incompatible with this board. "
> + error_setg(&local_err, "RAM size incompatible with this board. "
> "Try again with something else, like %" PRId64 " MB",
> s->ram_size / MiB - ram_size);
> - return;
> + goto out;
> }
>
> if (s->autoconfigure) {
> @@ -193,6 +196,8 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp)
>
> isa_register_portio_list(ISA_DEVICE(dev), &s->portio, 0x0,
> rs6000mc_port_list, s, "rs6000mc");
> +out:
> + error_propagate(errp, local_err);
> }
>
> static const VMStateDescription vmstate_rs6000mc = {
>
next prev parent reply other threads:[~2019-10-08 12:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-08 11:33 [PATCH 0/3] eliminate remaining places that abuse memory_region_allocate_system_memory() Igor Mammedov
2019-10-08 11:33 ` [PATCH 1/3] sparc64: use memory_region_allocate_system_memory() only for '-m' specified RAM Igor Mammedov
2019-10-08 12:09 ` Philippe Mathieu-Daudé
2019-10-08 13:55 ` Igor Mammedov
2019-10-08 11:33 ` [PATCH 2/3] ppc: rs6000_mc: drop usage of memory_region_allocate_system_memory() Igor Mammedov
2019-10-08 12:24 ` Philippe Mathieu-Daudé [this message]
2019-10-09 1:21 ` David Gibson
2019-10-09 11:19 ` Igor Mammedov
2019-10-09 12:02 ` David Gibson
2019-10-08 11:33 ` [PATCH 3/3] hppa: drop usage of memory_region_allocate_system_memory() for ROM Igor Mammedov
2019-10-08 12:30 ` Philippe Mathieu-Daudé
2019-10-20 21:49 ` Philippe Mathieu-Daudé
2019-10-08 12:41 ` [PATCH 0/3] eliminate remaining places that abuse memory_region_allocate_system_memory() Philippe Mathieu-Daudé
2019-10-08 13:52 ` Igor Mammedov
2019-10-10 17:35 ` Igor Mammedov
2019-10-11 15:23 ` Igor Mammedov
2019-10-20 14:38 ` Philippe Mathieu-Daudé
2019-10-22 22:09 ` Eduardo Habkost
2019-10-21 8:59 ` Philippe Mathieu-Daudé
2019-10-21 9:18 ` 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=9a6951b6-e8d6-90ff-727a-62c2a188660b@redhat.com \
--to=philmd@redhat.com \
--cc=atar4qemu@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=deller@gmx.de \
--cc=hpoussin@reactos.org \
--cc=imammedo@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rth@twiddle.net \
/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).