qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Pavel Fedin" <p.fedin@samsung.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH 2/2] hw/arm/virt: don't use a15memmap directly
Date: Fri, 9 Oct 2015 19:05:05 +0200	[thread overview]
Message-ID: <20151009170505.GA3284@hawk.localdomain> (raw)
In-Reply-To: <CAFEAcA9_H9HuFDtT56+Ga+GxP=99Eh+ReSTBZ+QXFmXQHv6Tdw@mail.gmail.com>

On Fri, Oct 09, 2015 at 05:45:24PM +0100, Peter Maydell wrote:
> On 6 October 2015 at 15:37, Andrew Jones <drjones@redhat.com> wrote:
> > We should always go through VirtBoardInfo when we need the memmap.
> > To avoid using a15memmap directly, in this case, we need to defer
> > the max-cpus check from class init time to instance init time. In
> > class init we now use MAX_CPUMASK_BITS for max_cpus initialization,
> > which is the maximum QEMU supports, and also, incidentally, the
> > maximum KVM/gicv3 currently supports. Also, a nice side-effect of
> > delaying the max-cpus check is that we now get more appropriate
> > error messages for gicv2 machines that try to configure more than
> > 123 cpus. Before this patch it would complain that the requested
> > number of cpus was greater than 123, but for gicv2 configs, it
> > should complain that the number is greater than 8.
> 
> Yes, this seems like a good plan.
> 
> > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > ---
> >  hw/arm/virt.c | 22 +++++++++++++++++-----
> >  1 file changed, 17 insertions(+), 5 deletions(-)
> >
> > diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> > index d25d6cfce74cd..a9901983731ae 100644
> > --- a/hw/arm/virt.c
> > +++ b/hw/arm/virt.c
> > @@ -918,7 +918,7 @@ static void machvirt_init(MachineState *machine)
> >      qemu_irq pic[NUM_IRQS];
> >      MemoryRegion *sysmem = get_system_memory();
> >      int gic_version = vms->gic_version;
> > -    int n;
> > +    int n, max_cpus;
> >      MemoryRegion *ram = g_new(MemoryRegion, 1);
> >      const char *cpu_model = machine->cpu_model;
> >      VirtBoardInfo *vbi;
> > @@ -952,6 +952,21 @@ static void machvirt_init(MachineState *machine)
> >          exit(1);
> >      }
> >
> > +    /* The maximum number of CPUs depends on the GIC version, or on how
> > +     * many redistributors we can fit into the memory map.
> > +     */
> > +    if (gic_version == 3) {
> > +        max_cpus = vbi->memmap[VIRT_GIC_REDIST].size / 0x20000;
> > +    } else {
> > +        max_cpus = GICV2_NCPU;
> > +    }
> > +
> > +    if (smp_cpus > max_cpus) {
> > +        error_report("mach-virt: Number of SMP cpus requested (%d), "
> 
> The comma here in the error message is unnecessary.
> 
> > +                     "exceeds max cpus supported %d", smp_cpus, max_cpus);
> 
> ...and there should be parens around the %d here for consistency.
> 
> Since this is a user-facing error message, "CPUs" is nicer than
> "cpus".

Sounds good to me, but I actually took that message from vl.c, where
there's already a message for the same purpose, so I was trying to be
consistent with that. Maybe we should clean that one up too.

> 
> > +        exit(1);
> > +    }
> > +
> >      vbi->smp_cpus = smp_cpus;
> >
> >      if (machine->ram_size > vbi->memmap[VIRT_MEM].size) {
> > @@ -1150,10 +1165,7 @@ static void virt_class_init(ObjectClass *oc, void *data)
> >
> >      mc->desc = "ARM Virtual Machine",
> >      mc->init = machvirt_init;
> > -    /* Our maximum number of CPUs depends on how many redistributors
> > -     * we can fit into memory map
> > -     */
> > -    mc->max_cpus = a15memmap[VIRT_GIC_REDIST].size / 0x20000;
> > +    mc->max_cpus = MAX_CPUMASK_BITS;
> 
> A brief comment that we do a more restrictive check later at init
> time would be a good idea I think.

OK

> 
> >      mc->has_dynamic_sysbus = true;
> >      mc->block_default_type = IF_VIRTIO;
> >      mc->no_cdrom = 1;
> > --
> 
> thanks
> -- PMM

Thanks for the review. I'll send out a v2 soon.

drew

  reply	other threads:[~2015-10-09 17:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-06 14:37 [Qemu-devel] [PATCH 0/2] hw/arm/virt: max-cpus init/check fixup Andrew Jones
2015-10-06 14:37 ` [Qemu-devel] [PATCH 1/2] [RFC] arm_gic_common.h: add gicv2 aliases for defines Andrew Jones
2015-10-09 16:41   ` Peter Maydell
2015-10-12  6:58     ` Pavel Fedin
2015-10-06 14:37 ` [Qemu-devel] [PATCH 2/2] hw/arm/virt: don't use a15memmap directly Andrew Jones
2015-10-09 16:45   ` Peter Maydell
2015-10-09 17:05     ` Andrew Jones [this message]
2015-10-12  7:00   ` Pavel Fedin
2015-10-12 12:07     ` Andrew Jones

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=20151009170505.GA3284@hawk.localdomain \
    --to=drjones@redhat.com \
    --cc=afaerber@suse.de \
    --cc=p.fedin@samsung.com \
    --cc=peter.maydell@linaro.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;
as well as URLs for NNTP newsgroup(s).