From patchwork Sun Oct 18 17:35:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 55182 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 0EA9E22FFA for ; Sun, 18 Oct 2015 17:37:58 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf37513700lbc.1 for ; Sun, 18 Oct 2015 10:37:56 -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=A3bznZxnB5FNKa+AoFwPMEt2hzGTbZnW6WRzlAvBPGE=; b=VRuPm0+BPBVtmuoNA2WSIeJ4QT6++TK5P9dWqC+6cS/pVo/dECr8rzs6qrbIjkO2uQ b59O6q61C55to8mTmJhhcYT4ikn2VFD8Gu1M1yuqUEOHiDBDzcixlebxxWJKyt7Howrw uM5xariJoCO/5mHarYB7Q8FVxEOyshFE0vB368dOnS955K2X3xAtMQFOxbDUxiHjG90H 8RA0N8pk/ekSFi1GXqyFKCNn5a0QPeY1nCeigNt7OQg6BxCQ8sAdXMj23gx7HEGzDsUr zEOm9NhLviC6cVeuG/hXlm07uZyio0PC1ckO2bwDyo7X6EeEdpFnOn8zy9F1ACkvwmL8 M11Q== X-Gm-Message-State: ALoCoQnKKfNKNtUiKLJsv0lhA0mWiE4M2lwCemBv6b+pN9XyDJLTTQuEI0QrtuigGm4Guat0wZHQ X-Received: by 10.112.63.165 with SMTP id h5mr6075785lbs.18.1445189876727; Sun, 18 Oct 2015 10:37:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.33.196 with SMTP id h187ls511406lfh.4.gmail; Sun, 18 Oct 2015 10:37:56 -0700 (PDT) X-Received: by 10.112.148.38 with SMTP id tp6mr12559773lbb.110.1445189876401; Sun, 18 Oct 2015 10:37:56 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id ty1si9205484lbb.121.2015.10.18.10.37.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 10:37:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbcao8 with SMTP id ao8so127091312lbc.3 for ; Sun, 18 Oct 2015 10:37:56 -0700 (PDT) X-Received: by 10.112.163.131 with SMTP id yi3mr12526837lbb.36.1445189876249; Sun, 18 Oct 2015 10:37:56 -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 w3csp1064091lbq; Sun, 18 Oct 2015 10:37:55 -0700 (PDT) X-Received: by 10.55.209.205 with SMTP id o74mr31262688qkl.66.1445189875127; Sun, 18 Oct 2015 10:37:55 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k38si26931887qgd.64.2015.10.18.10.37.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 18 Oct 2015 10:37:55 -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]:34952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Znru6-0006IS-M9 for patch@linaro.org; Sun, 18 Oct 2015 13:37:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Znrrv-0004u0-GW for qemu-devel@nongnu.org; Sun, 18 Oct 2015 13:35:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Znrrs-0001Kg-TI for qemu-devel@nongnu.org; Sun, 18 Oct 2015 13:35:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Znrrs-0001Kc-Nu for qemu-devel@nongnu.org; Sun, 18 Oct 2015 13:35:36 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 643DBC0C1895; Sun, 18 Oct 2015 17:35:36 +0000 (UTC) Received: from hawk.localdomain.com (dhcp-1-125.brq.redhat.com [10.34.1.125]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9IHZVTq030229; Sun, 18 Oct 2015 13:35:35 -0400 From: Andrew Jones To: qemu-devel@nongnu.org Date: Sun, 18 Oct 2015 19:35:28 +0200 Message-Id: <1445189728-860-3-git-send-email-drjones@redhat.com> In-Reply-To: <1445189728-860-1-git-send-email-drjones@redhat.com> References: <1445189728-860-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, ehabkost@redhat.com Subject: [Qemu-devel] [PATCH v2 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.173 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 | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4e7160ce96997..8ec346f8fda3e 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -923,7 +923,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; @@ -957,6 +957,22 @@ 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 = GIC_NCPU; + } + + if (smp_cpus > max_cpus) { + error_report("Number of SMP CPUs requested (%d) exceeds max CPUs " + "supported by machine 'mach-virt' (%d)", + smp_cpus, max_cpus); + exit(1); + } + vbi->smp_cpus = smp_cpus; if (machine->ram_size > vbi->memmap[VIRT_MEM].size) { @@ -1155,10 +1171,11 @@ 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 + /* Start max_cpus at the maximum QEMU supports. We'll further restrict + * it later in machvirt_init, where we have more information about the + * configuration of the particular instance. */ - 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;