From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRflF-00006Y-7s for qemu-devel@nongnu.org; Fri, 05 Feb 2016 07:45:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRflE-0001yr-0O for qemu-devel@nongnu.org; Fri, 05 Feb 2016 07:45:17 -0500 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:34890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRflD-0001yZ-Mv for qemu-devel@nongnu.org; Fri, 05 Feb 2016 07:45:15 -0500 Received: by mail-wm0-x22d.google.com with SMTP id r129so25129583wmr.0 for ; Fri, 05 Feb 2016 04:45:15 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1454511578-24863-1-git-send-email-drjones@redhat.com> References: <1454511578-24863-1-git-send-email-drjones@redhat.com> Date: Fri, 5 Feb 2016 20:45:14 +0800 Message-ID: From: Shannon Zhao Content-Type: multipart/alternative; boundary=001a11441f64ff65eb052b05380a Subject: Re: [Qemu-devel] [PATCH] hw/arm/virt: fix max-cpus check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andrew Jones Cc: "peter.maydell@linaro.org" , "qemu-arm@nongnu.org" , "qemu-devel@nongnu.org" --001a11441f64ff65eb052b05380a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2016=E5=B9=B42=E6=9C=883=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=89=EF=BC=8CAndrew= Jones =E5=86=99=E9=81=93=EF=BC=9A > mach-virt doesn't yet support hotplug, but command lines specifying > -smp ,maxcpus=3D don't fail. Of course specifying > bigger-num as something bigger than the machine supports, e.g. > 8 > on a gicv2 machine, should fail though. This fix also makes mach- > virt's max-cpus check truly consistent with the one in vl.c:main, > as the one there was already correctly checking max-cpus instead > of smp-cpus. > > Reported-by: Shannon Zhao > > Signed-off-by: Andrew Jones > Reviewed-by: Shannon Zhao > --- > hw/arm/virt.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index 15658f49c4e06..44bbbea92b1cf 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -1013,7 +1013,7 @@ static void machvirt_init(MachineState *machine) > MemoryRegion *sysmem =3D get_system_memory(); > MemoryRegion *secure_sysmem =3D NULL; > int gic_version =3D vms->gic_version; > - int n, max_cpus; > + int n, virt_max_cpus; > MemoryRegion *ram =3D g_new(MemoryRegion, 1); > const char *cpu_model =3D machine->cpu_model; > VirtBoardInfo *vbi; > @@ -1051,15 +1051,15 @@ static void machvirt_init(MachineState *machine) > * many redistributors we can fit into the memory map. > */ > if (gic_version =3D=3D 3) { > - max_cpus =3D vbi->memmap[VIRT_GIC_REDIST].size / 0x20000; > + virt_max_cpus =3D vbi->memmap[VIRT_GIC_REDIST].size / 0x20000; > } else { > - max_cpus =3D GIC_NCPU; > + virt_max_cpus =3D GIC_NCPU; > } > > - if (smp_cpus > max_cpus) { > + if (max_cpus > virt_max_cpus) { > error_report("Number of SMP CPUs requested (%d) exceeds max CPUs= " > "supported by machine 'mach-virt' (%d)", > - smp_cpus, max_cpus); > + max_cpus, virt_max_cpus); > exit(1); > } > > -- > 2.4.3 > > --001a11441f64ff65eb052b05380a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

2016=E5=B9=B42=E6=9C=883=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=89=EF=BC= =8CAndrew Jones <drjones@redhat.co= m> =E5=86=99=E9=81=93=EF=BC=9A
mac= h-virt doesn't yet support hotplug, but command lines specifying
-smp <num>,maxcpus=3D<bigger-num> don't fail. Of course spe= cifying
bigger-num as something bigger than the machine supports, e.g. > 8
on a gicv2 machine, should fail though. This fix also makes mach-
virt's max-cpus check truly consistent with the one in vl.c:main,
as the one there was already correctly checking max-cpus instead
of smp-cpus.

Reported-by: Shannon Zhao <shannon.zhao@linaro.or= g>
Signed-off-by: Andrew Jones <drjones@redhat.com>= ;
Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org>
---
=C2=A0hw/arm/virt.c | 10 +++++-----
=C2=A01 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 15658f49c4e06..44bbbea92b1cf 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1013,7 +1013,7 @@ static void machvirt_init(MachineState *machine)
=C2=A0 =C2=A0 =C2=A0MemoryRegion *sysmem =3D get_system_memory();
=C2=A0 =C2=A0 =C2=A0MemoryRegion *secure_sysmem =3D NULL;
=C2=A0 =C2=A0 =C2=A0int gic_version =3D vms->gic_version;
-=C2=A0 =C2=A0 int n, max_cpus;
+=C2=A0 =C2=A0 int n, virt_max_cpus;
=C2=A0 =C2=A0 =C2=A0MemoryRegion *ram =3D g_new(MemoryRegion, 1);
=C2=A0 =C2=A0 =C2=A0const char *cpu_model =3D machine->cpu_model;
=C2=A0 =C2=A0 =C2=A0VirtBoardInfo *vbi;
@@ -1051,15 +1051,15 @@ static void machvirt_init(MachineState *machine) =C2=A0 =C2=A0 =C2=A0 * many redistributors we can fit into the memory map.<= br> =C2=A0 =C2=A0 =C2=A0 */
=C2=A0 =C2=A0 =C2=A0if (gic_version =3D=3D 3) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 max_cpus =3D vbi->memmap[VIRT_GIC_REDIST].s= ize / 0x20000;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 virt_max_cpus =3D vbi->memmap[VIRT_GIC_REDI= ST].size / 0x20000;
=C2=A0 =C2=A0 =C2=A0} else {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 max_cpus =3D GIC_NCPU;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 virt_max_cpus =3D GIC_NCPU;
=C2=A0 =C2=A0 =C2=A0}

-=C2=A0 =C2=A0 if (smp_cpus > max_cpus) {
+=C2=A0 =C2=A0 if (max_cpus > virt_max_cpus) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0error_report("Number of SMP CPUs req= uested (%d) exceeds max CPUs "
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 "supported by machine 'mach-virt' (%d)",
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0smp_cpus, max_cpus);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0max_cpus, virt_max_cpus);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exit(1);
=C2=A0 =C2=A0 =C2=A0}

--
2.4.3

--001a11441f64ff65eb052b05380a--