From patchwork Tue Oct 6 14:37:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 526789 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 357A1140D72 for ; Wed, 7 Oct 2015 01:38:43 +1100 (AEDT) Received: from localhost ([::1]:52062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjTO5-000717-4r for incoming@patchwork.ozlabs.org; Tue, 06 Oct 2015 10:38:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjTMl-0006AS-1h for qemu-devel@nongnu.org; Tue, 06 Oct 2015 10:37:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjTMj-0000gR-E0 for qemu-devel@nongnu.org; Tue, 06 Oct 2015 10:37:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55620) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjTMj-0000gL-6x for qemu-devel@nongnu.org; Tue, 06 Oct 2015 10:37:17 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id D14D1344F67; Tue, 6 Oct 2015 14:37:16 +0000 (UTC) Received: from hawk.localdomain.com (dhcp-1-123.brq.redhat.com [10.34.1.123]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t96EbBsV004599; Tue, 6 Oct 2015 10:37:15 -0400 From: Andrew Jones To: qemu-devel@nongnu.org Date: Tue, 6 Oct 2015 16:37:08 +0200 Message-Id: <1444142228-6696-3-git-send-email-drjones@redhat.com> In-Reply-To: <1444142228-6696-1-git-send-email-drjones@redhat.com> References: <1444142228-6696-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, p.fedin@samsung.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 2/2] hw/arm/virt: don't use a15memmap directly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Signed-off-by: Andrew Jones --- 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), " + "exceeds max cpus supported %d", smp_cpus, max_cpus); + 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; mc->has_dynamic_sysbus = true; mc->block_default_type = IF_VIRTIO; mc->no_cdrom = 1;