From patchwork Mon Feb 20 03:53:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 6829 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 7DE9323F8D for ; Mon, 20 Feb 2012 03:54:27 +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 47112A183A0 for ; Mon, 20 Feb 2012 03:54:27 +0000 (UTC) Received: by iabz7 with SMTP id z7so9895747iab.11 for ; Sun, 19 Feb 2012 19:54:26 -0800 (PST) Received: from mr.google.com ([10.42.131.129]) by 10.42.131.129 with SMTP id z1mr19290116ics.53.1329710066813 (num_hops = 1); Sun, 19 Feb 2012 19:54:26 -0800 (PST) Received: by 10.42.131.129 with SMTP id z1mr15394751ics.53.1329710066743; Sun, 19 Feb 2012 19:54:26 -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 r10csp35737ibr; Sun, 19 Feb 2012 19:54:24 -0800 (PST) Received: by 10.68.190.8 with SMTP id gm8mr41756578pbc.146.1329710064681; Sun, 19 Feb 2012 19:54:24 -0800 (PST) Received: from ozlabs.org (ozlabs.org. [203.10.76.45]) by mx.google.com with ESMTPS id t9si18355739pbi.193.2012.02.19.19.54.24 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 19 Feb 2012 19:54:24 -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 E7496B6FA7; Mon, 20 Feb 2012 14:54:21 +1100 (EST) From: Rusty Russell To: Christoffer Dall Cc: Peter Maydell , qemu-devel@nongnu.org, android-virt@lists.cs.columbia.edu, patches@linaro.org Subject: [PATCH 3/2] arm: make sure that number of irqs can be represented in GICD_TYPER. In-Reply-To: References: <1326487969-12462-1-git-send-email-peter.maydell@linaro.org> <1326487969-12462-3-git-send-email-peter.maydell@linaro.org> <87fwf5ebjw.fsf@rustcorp.com.au> <87vcnyc7cg.fsf@rustcorp.com.au> <87fwe68lt0.fsf@rustcorp.com.au> User-Agent: Notmuch/0.6.1-1 (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) Date: Mon, 20 Feb 2012 14:23:53 +1030 Message-ID: <874num88j2.fsf@rustcorp.com.au> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkE9953omnWdBnNbDrmf+FTmeA3aQHFwE62mZ5lky10o0X2cHNkuvdR5S4WJSPzBvl7rhmO 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. Thanks to Christoffer Dall for undoing comment thinko. Signed-off-by: Rusty Russell diff --git a/hw/arm_gic.c b/hw/arm_gic.c index fa6a60a..6446800 100644 --- a/hw/arm_gic.c +++ b/hw/arm_gic.c @@ -818,6 +818,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]);