From patchwork Tue Feb 21 02:33:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 6845 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DBDB923E24 for ; Tue, 21 Feb 2012 02:34:22 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 9BC64A1855B for ; Tue, 21 Feb 2012 02:34:22 +0000 (UTC) Received: by iabz7 with SMTP id z7so11650836iab.11 for ; Mon, 20 Feb 2012 18:34:22 -0800 (PST) Received: from mr.google.com ([10.50.89.196]) by 10.50.89.196 with SMTP id bq4mr16615728igb.26.1329791662158 (num_hops = 1); Mon, 20 Feb 2012 18:34:22 -0800 (PST) Received: by 10.50.89.196 with SMTP id bq4mr13423825igb.26.1329791662078; Mon, 20 Feb 2012 18:34:22 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.11.10 with SMTP id r10csp71535ibr; Mon, 20 Feb 2012 18:34:21 -0800 (PST) Received: by 10.68.216.40 with SMTP id on8mr56772753pbc.97.1329791660658; Mon, 20 Feb 2012 18:34:20 -0800 (PST) Received: from ozlabs.org (ozlabs.org. [203.10.76.45]) by mx.google.com with ESMTPS id b8si21115023pbe.301.2012.02.20.18.34.20 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Feb 2012 18:34:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of rusty@ozlabs.org designates 203.10.76.45 as permitted sender) client-ip=203.10.76.45; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rusty@ozlabs.org designates 203.10.76.45 as permitted sender) smtp.mail=rusty@ozlabs.org Received: by ozlabs.org (Postfix, from userid 1011) id C8CE5B6EF3; Tue, 21 Feb 2012 13:34:16 +1100 (EST) From: Rusty Russell To: Peter Maydell , qemu-devel@nongnu.org Cc: android-virt@lists.cs.columbia.edu, patches@linaro.org Subject: [PATCH 2/2] arm: make sure that number of irqs can be represented in GICD_TYPER. In-Reply-To: <1326487969-12462-3-git-send-email-peter.maydell@linaro.org> References: <1326487969-12462-1-git-send-email-peter.maydell@linaro.org> <1326487969-12462-3-git-send-email-peter.maydell@linaro.org> User-Agent: Notmuch/0.6.1-1 (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) Date: Tue, 21 Feb 2012 13:03:34 +1030 Message-ID: <877gzg7w5d.fsf@rustcorp.com.au> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQm/HxOqSvFMd/AeDTFd4+RbT4hXPHcTt0rEi9WVLYfdVqZT1eSEWJwaPYTc+oeKUQRWLAnd We currently assume that the number of interrupts (ITLinesNumber in the architecture reference manual) is divisible by 32, since we present it to the guest when it reads GICD_TYPER (in gic_dist_readb()) as (N / 32) - 1. Signed-off-by: Rusty Russell Reviewed-by: Peter Maydell --- hw/arm_gic.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/hw/arm_gic.c b/hw/arm_gic.c index 4b1b486..a19212e 100644 --- a/hw/arm_gic.c +++ b/hw/arm_gic.c @@ -819,6 +819,15 @@ static void gic_init(gic_state *s, int num_irq) hw_error("requested %u interrupt lines exceeds GIC maximum %d\n", num_irq, GIC_MAXIRQ); } + /* ITLinesNumber is represented as (N / 32) - 1 (see + * gic_dist_readb) so this is an implementation imposed + * restriction, not an architectural one: + */ + if (s->num_irq < 32 || (s->num_irq % 32)) { + hw_error("%d interrupt lines unsupported: not divisible by 32\n", + num_irq); + } + qdev_init_gpio_in(&s->busdev.qdev, gic_set_irq, s->num_irq - GIC_INTERNAL); for (i = 0; i < NUM_CPU(s); i++) { sysbus_init_irq(&s->busdev, &s->parent_irq[i]);