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: 54533 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 3E8C522F05 for ; Tue, 6 Oct 2015 14:39:01 +0000 (UTC) Received: by lafb9 with SMTP id b9sf37130888laf.3 for ; Tue, 06 Oct 2015 07:39:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=/SwVd7QeVvPEgh52RrXRtrCG6Gxc7ea5aikdf9oYfA4=; b=L/+ifTUWojJ1ZZFNRUCbLY6dtsytXznb429PRYcr6UgDs22XHnyFyRYolYVHY6lskJ ZWR0Xcidl6WT3ScaiIm727J5xhRL52P4hZBM/vJoJDTSoiQVhMx5yQfrrJ9KZQsvtV1t Rgn3CiJAH02cX2xln6zVWeH2O0HJyXLLR3EiCUPxhnGELM1BU67scQMO2HNFMe15Jh4D YM83LtB4KHC6OItDXNpU4gC6KachNQgZ5xuOb6ormXSY/ksJAg4+rbuCuHvDqA+fLQ/F Q/5XMPkslsBZYo8gF7teEsg0lxA2OE+PyOHmCt5HrcL0ywnVwScpPKCEgbfuIHcTjxv9 GsEg== X-Gm-Message-State: ALoCoQm5gf9lMDlpGl32Dg+rm4byw9LwpK4COsonyUTWS9F6M2H9V0qH5AeEF1V22EeGs/7tvmdf X-Received: by 10.112.12.132 with SMTP id y4mr6474676lbb.0.1444142340041; Tue, 06 Oct 2015 07:39:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.159.212 with SMTP id i203ls617682lfe.61.gmail; Tue, 06 Oct 2015 07:38:59 -0700 (PDT) X-Received: by 10.25.81.3 with SMTP id f3mr9791070lfb.44.1444142339863; Tue, 06 Oct 2015 07:38:59 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id go8si21141593lbc.147.2015.10.06.07.38.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Oct 2015 07:38:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbos8 with SMTP id s8so77557441lbo.0 for ; Tue, 06 Oct 2015 07:38:59 -0700 (PDT) X-Received: by 10.25.77.133 with SMTP id a127mr9760430lfb.19.1444142339702; Tue, 06 Oct 2015 07:38:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1889282lbq; Tue, 6 Oct 2015 07:38:58 -0700 (PDT) X-Received: by 10.55.197.147 with SMTP id k19mr21372558qkl.11.1444142338714; Tue, 06 Oct 2015 07:38:58 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f32si20572594qki.4.2015.10.06.07.38.58 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 06 Oct 2015 07:38:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:52062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjTOM-000717-93 for patch@linaro.org; Tue, 06 Oct 2015 10:38:58 -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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: drjones@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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;