public inbox for qemu-arm@nongnu.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: andrew@aj.id.au, peter.maydell@linaro.org, qemu-arm@nongnu.org,
	qemu-devel@nongnu.org, joel@jms.id.au
Subject: Re: [PATCH v2 08/86] arm:aspeed: actually check RAM size
Date: Thu, 16 Jan 2020 18:35:38 +0100	[thread overview]
Message-ID: <20200116183538.2f84604c@redhat.com> (raw)
In-Reply-To: <83481ccb-38e4-d0a2-18b5-66fcd7248521@kaod.org>

On Thu, 16 Jan 2020 09:41:03 +0100
Cédric Le Goater <clg@kaod.org> wrote:

> On 1/15/20 4:06 PM, Igor Mammedov wrote:
> > It's supposed that SOC will check if "-m" provided
> > RAM size is valid by setting "ram-size" property and
> > then board would read back valid (possibly corrected
> > value) to map RAM MemoryReging with valid size.
> > Well it isn't doing so, since check is called only
> > indirectly from
> >   aspeed_sdmc_reset()->asc->compute_conf()
> > or much later when guest writes to configuration
> > register.
> > 
> > So depending on "-m" value QEMU end-ups with a warning
> > and an invalid MemoryRegion size allocated and mapped.
> > (examples:
> >  -M ast2500-evb -m 1M
> >     0000000080000000-000000017ffffffe (prio 0, i/o): aspeed-ram-container
> >       0000000080000000-00000000800fffff (prio 0, ram): ram
> >       0000000080100000-00000000bfffffff (prio 0, i/o): max_ram
> >  -M ast2500-evb -m 3G
> >     0000000080000000-000000017ffffffe (prio 0, i/o): aspeed-ram-container
> >       0000000080000000-000000013fffffff (prio 0, ram): ram
> >       [DETECTED OVERFLOW!] 0000000140000000-00000000bfffffff (prio 0, i/o): max_ram
> > )
> > On top of that sdmc falls back and reports to guest
> > "default" size, it thinks machine should have.>
> > I don't know how hardware is supposed to work so
> > I've kept it as is.  
> 
> The HW is hardwired and the modeling is trying to accommodate with
> the '-m' option, the machine definition and the SDRAM controller
> limits and register definitions for a given SoC. The result is not 
> that good it seems :/ 
> 
> > But as for CLI side machine should honor whatever
> > user configured or error out to make user fix CLI.
> > 
> > This patch makes ram-size check actually work and
> > changes behavior from a warning later on during
> > machine reset to error_fatal at the moment SOC is
> > realized so user will have to fix RAM size on CLI
> > to start machine.  
> 
> commit 8e00d1a97d1d ("aspeed/sdmc: Introduce an object class per SoC") 
> moved some calls from the realize handler to reset handler and it
> broke the checks on the RAM size.
> 
> I think we should introduce get/set handlers on the "ram-size" property
> that would look for a matching size in an AspeedSDMCClass array of valid
> RAM sizes. The default size of the machine would be a valid default and
> bogus user defined sizes would be fatal to QEMU.  

That's what I'm after, i.e. board either accepts user asked size or exits
with error. So as far as there aren't any fix-ups it should work for
the purpose of this series

> 
> We could get rid of the code :
> 
>     /* use a common default */
>     warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 512M",
>                 s->ram_size);
>     s->ram_size = 512 << 20;
>     return ASPEED_SDMC_AST2500_512MB;
> 
> 
> 'max_ram_size' would be the last entry of the AspeedSDMCClass array
> and, anyhow, we need to check bmc->max_ram is really needed. I am not 
> sure anymore. 

I'll rework aspeed parts taking in account feedback.

> 
> Thanks,
> 
> C. 
> 
> > It also gets out of the way mutable ram-size logic,
> > so we could consolidate RAM allocation logic around
> > pre-allocated hostmem backend (supplied by user or
> > auto created by generic machine code depending on
> > supplied -m/mem-path/mem-prealloc options.
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> > CC: clg@kaod.org
> > CC: peter.maydell@linaro.org
> > CC: andrew@aj.id.au
> > CC: joel@jms.id.au
> > CC: qemu-arm@nongnu.org
> > ---
> >  hw/arm/aspeed.c       | 9 +--------
> >  hw/misc/aspeed_sdmc.c | 5 +++++
> >  2 files changed, 6 insertions(+), 8 deletions(-)
> > 
> > diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> > index cc06af4..525c547 100644
> > --- a/hw/arm/aspeed.c
> > +++ b/hw/arm/aspeed.c
> > @@ -213,14 +213,7 @@ static void aspeed_machine_init(MachineState *machine)
> >                                  "hw-prot-key", &error_abort);
> >      }
> >      object_property_set_bool(OBJECT(&bmc->soc), true, "realized",
> > -                             &error_abort);
> > -
> > -    /*
> > -     * Allocate RAM after the memory controller has checked the size
> > -     * was valid. If not, a default value is used.
> > -     */
> > -    ram_size = object_property_get_uint(OBJECT(&bmc->soc), "ram-size",
> > -                                        &error_abort);
> > +                             &error_fatal);
> >  
> >      memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size);
> >      memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram);
> > diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c
> > index 3fc80f0..b398e36 100644
> > --- a/hw/misc/aspeed_sdmc.c
> > +++ b/hw/misc/aspeed_sdmc.c
> > @@ -165,6 +165,11 @@ static void aspeed_sdmc_realize(DeviceState *dev, Error **errp)
> >      AspeedSDMCState *s = ASPEED_SDMC(dev);
> >      AspeedSDMCClass *asc = ASPEED_SDMC_GET_CLASS(s);
> >  
> > +    if (!g_hash_table_contains(asc->ram2feat,
> > +                               GINT_TO_POINTER(s->ram_size >> 20))) {
> > +        error_setg(errp, "Invalid RAM size 0x%" PRIx64, s->ram_size);
> > +        return;
> > +    }
> >      s->max_ram_size = asc->max_ram_size;
> >  
> >      memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_sdmc_ops, s,
> >   
> 
> 


  reply	other threads:[~2020-01-16 17:35 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1579100861-73692-1-git-send-email-imammedo@redhat.com>
2020-01-15 15:06 ` [PATCH v2 07/86] arm:aspeed: convert valid RAM sizes to data Igor Mammedov
2020-01-16  1:45   ` Joel Stanley
2020-01-15 15:06 ` [PATCH v2 08/86] arm:aspeed: actually check RAM size Igor Mammedov
2020-01-16  8:41   ` Cédric Le Goater
2020-01-16 17:35     ` Igor Mammedov [this message]
2020-01-17  7:56       ` Cédric Le Goater
2020-01-20 14:21     ` [PATCH v3 07/84] hw/arm/aspeed: " Igor Mammedov
2020-01-20 15:33       ` Cédric Le Goater
2020-01-15 15:06 ` [PATCH v2 09/86] hw:aspeed: drop warning and bogus ram_size fixup Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 10/86] arm:aspeed: use memdev for RAM Igor Mammedov
2020-01-15 19:19   ` Philippe Mathieu-Daudé
2020-01-16  9:24   ` Cédric Le Goater
2020-01-16 18:17     ` Philippe Mathieu-Daudé
2020-01-15 15:06 ` [PATCH v2 11/86] arm:collie: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 12/86] arm:cubieboard: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 13/86] arm:digic_boards: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 14/86] arm:highbank: " Igor Mammedov
2020-01-15 19:18   ` Philippe Mathieu-Daudé
2020-01-15 15:06 ` [PATCH v2 15/86] arm:imx25_pdk: drop RAM size fixup Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 16/86] arm:imx25_pdk: use memdev for RAM Igor Mammedov
2020-01-15 19:18   ` Philippe Mathieu-Daudé
2020-01-15 15:06 ` [PATCH v2 17/86] arm:integratorcp: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 18/86] arm:kzm: drop RAM size fixup Igor Mammedov
2020-01-15 19:58   ` Chubb, Peter (Data61, Kensington NSW)
2020-01-16 17:26     ` [PATCH v3 " Igor Mammedov
2020-01-16 18:22       ` Philippe Mathieu-Daudé
2020-01-17  9:50         ` Igor Mammedov
2020-01-17 13:07           ` Philippe Mathieu-Daudé
2020-01-15 15:06 ` [PATCH v2 19/86] arm:kzm: use memdev for RAM Igor Mammedov
2020-01-15 20:09   ` Chubb, Peter (Data61, Kensington NSW)
2020-01-15 15:06 ` [PATCH v2 20/86] arm:mcimx6ul-evk: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 21/86] arm:mcimx7d-sabre: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 22/86] arm:mps2-tz: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 23/86] arm:mps2: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 24/86] arm:musicpal: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 25/86] arm:nseries: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 26/86] arm:omap_sx1: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 27/86] arm:palm: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 28/86] arm:raspi: " Igor Mammedov
2020-01-15 19:07   ` Philippe Mathieu-Daudé
2020-01-16 16:55     ` Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 29/86] arm:sabrelite: " Igor Mammedov
2020-01-15 15:06 ` [PATCH v2 30/86] arm:sbsa-ref: " Igor Mammedov
2020-01-15 19:09   ` Philippe Mathieu-Daudé
2020-01-15 15:06 ` [PATCH v2 31/86] arm:versatilepb: " Igor Mammedov
2020-01-15 19:20   ` Philippe Mathieu-Daudé
2020-01-15 15:06 ` [PATCH v2 32/86] arm:vexpress: " Igor Mammedov
2020-01-15 19:21   ` Philippe Mathieu-Daudé
2020-01-15 15:06 ` [PATCH v2 33/86] arm:virt: " Igor Mammedov
2020-01-15 18:57   ` Philippe Mathieu-Daudé
2020-01-15 15:06 ` [PATCH v2 34/86] arm:xilinx_zynq: drop RAM size fixup Igor Mammedov
2020-01-15 22:59   ` Alistair Francis
2020-01-15 15:06 ` [PATCH v2 35/86] arm:xilinx_zynq: use memdev for RAM Igor Mammedov
2020-01-15 19:01   ` Philippe Mathieu-Daudé
2020-01-16  0:20   ` Alistair Francis
2020-01-15 15:06 ` [PATCH v2 37/86] arm:xlnx-zcu102: " Igor Mammedov
2020-01-15 19:21   ` Philippe Mathieu-Daudé
2020-01-16  0:19   ` Alistair Francis
2020-01-15 15:07 ` [PATCH v2 82/86] numa: forbid '-numa node, mem' for 5.0 and newer machine types Igor Mammedov
2020-01-15 15:34   ` [libvirt] " Peter Krempa
2020-01-15 16:52     ` Igor Mammedov
2020-01-16 10:42       ` Michal Privoznik
2020-01-16 12:37         ` Igor Mammedov
2020-01-16 13:03           ` Michal Privoznik
2020-01-16 13:49             ` Igor Mammedov
2020-01-16 13:06           ` Daniel P. Berrangé
2020-01-16 13:58             ` Igor Mammedov
2020-01-16  4:36   ` David Gibson

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=20200116183538.2f84604c@redhat.com \
    --to=imammedo@redhat.com \
    --cc=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --cc=joel@jms.id.au \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox