From patchwork Sun Feb 19 23:07:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 6827 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 5F54D23E01 for ; Sun, 19 Feb 2012 23:09:42 +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 16033A18318 for ; Sun, 19 Feb 2012 23:09:41 +0000 (UTC) Received: by iabz7 with SMTP id z7so9603489iab.11 for ; Sun, 19 Feb 2012 15:09:41 -0800 (PST) Received: from mr.google.com ([10.43.52.74]) by 10.43.52.74 with SMTP id vl10mr18625004icb.55.1329692981606 (num_hops = 1); Sun, 19 Feb 2012 15:09:41 -0800 (PST) Received: by 10.43.52.74 with SMTP id vl10mr14843977icb.55.1329692981534; Sun, 19 Feb 2012 15:09:41 -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 r10csp32272ibr; Sun, 19 Feb 2012 15:09:40 -0800 (PST) Received: by 10.68.136.231 with SMTP id qd7mr26682336pbb.28.1329692979699; Sun, 19 Feb 2012 15:09:39 -0800 (PST) Received: from ozlabs.org (ozlabs.org. [203.10.76.45]) by mx.google.com with ESMTPS id s4si17757081pbc.45.2012.02.19.15.09.38 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 19 Feb 2012 15:09:39 -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 0B6ECB6F9F; Mon, 20 Feb 2012 10:09:34 +1100 (EST) From: Rusty Russell To: Peter Maydell Cc: qemu-devel@nongnu.org, android-virt@lists.cs.columbia.edu, patches@linaro.org Subject: [PATCH] arm: make sure that number of irqs can be represented in GICD_TYPER. In-Reply-To: <87vcnyc7cg.fsf@rustcorp.com.au> 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> User-Agent: Notmuch/0.6.1-1 (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) Date: Mon, 20 Feb 2012 09:37:07 +1030 Message-ID: <87fwe68lt0.fsf@rustcorp.com.au> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQm9spiOq8S8rdlb21d7lU+4kvabeF3wV6KADLq2M55c346tvJaPFeamZw7tqUPCXuZYQRAn 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 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]);