From patchwork Thu Oct 30 22:12:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 39952 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D06D1202FE for ; Fri, 31 Oct 2014 18:08:56 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id b13sf3461086wgh.6 for ; Fri, 31 Oct 2014 11:08: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=ya6jRWy5YznyfQuLxEwicQg8HXcq7w6QDazyw9v6THE=; b=S1gN6D0qk51zlKTA2YxKi8Q02kR56HMn02Apm+gMfhg4KfeX8xz3CwRl7TcqBHL9Hf 5JunM6nHy9udRSGOAcIyiTYF7t1iujYJhMULdCSCfBVxx4KtrtzfZJqdP0yJdCwTxpWx vJ/sfk7OQpQYJlAHASf5hoewvKk8GHlSywHx4HHW1uQ9w1LamxX8ZkfiV5AnftNpG6LR PRPSd7cAZI/jSr3bPGBIW3NMDHxLxjw/pQPnORvJn59N2aGeWRKSLCl1kwOlLKOU5Wtq 8N3k6uyC3zxfFhkhiaD4/8eJ7xiW6VGj5bPz2ILEA+GCrMD5+9qBn973WrxzkRXmrDJx FwPw== X-Gm-Message-State: ALoCoQnbZZz4vGH8r5jRf5Zj4vm10K5G8onpRQQv3kwegr09RDWLJHRHw7sM++H1B9BMIV6GOOf5 X-Received: by 10.194.172.35 with SMTP id az3mr4300667wjc.0.1414778935937; Fri, 31 Oct 2014 11:08:55 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.161.203 with SMTP id xu11ls105287lab.90.gmail; Fri, 31 Oct 2014 11:08:55 -0700 (PDT) X-Received: by 10.112.16.39 with SMTP id c7mr27855419lbd.19.1414778935652; Fri, 31 Oct 2014 11:08:55 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id w2si18038618laz.35.2014.10.31.11.08.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 11:08:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id f15so7242983lbj.27 for ; Fri, 31 Oct 2014 11:08:55 -0700 (PDT) X-Received: by 10.153.8.164 with SMTP id dl4mr28276697lad.29.1414778935554; Fri, 31 Oct 2014 11:08:55 -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.84.229 with SMTP id c5csp241156lbz; Fri, 31 Oct 2014 11:08:54 -0700 (PDT) X-Received: by 10.140.25.167 with SMTP id 36mr37020372qgt.56.1414778933949; Fri, 31 Oct 2014 11:08:53 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w6si18312944qax.23.2014.10.31.11.08.53 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 31 Oct 2014 11:08:53 -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]:40478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkGd2-0001SU-Vs for patch@linaro.org; Fri, 31 Oct 2014 14:08:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkE4x-00065m-It for qemu-devel@nongnu.org; Fri, 31 Oct 2014 11:26:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjxxY-00066E-Mu for qemu-devel@nongnu.org; Thu, 30 Oct 2014 18:12:57 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:39775) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjxxY-00065K-Ex for qemu-devel@nongnu.org; Thu, 30 Oct 2014 18:12:48 -0400 Received: by mail-pd0-f182.google.com with SMTP id fp1so6000893pdb.13 for ; Thu, 30 Oct 2014 15:12:47 -0700 (PDT) X-Received: by 10.70.38.165 with SMTP id h5mr20122565pdk.121.1414707167892; Thu, 30 Oct 2014 15:12:47 -0700 (PDT) Received: from gbellows-linaro.qualcomm.com (rrcs-67-52-129-61.west.biz.rr.com. [67.52.129.61]) by mx.google.com with ESMTPSA id h3sm7270163pdl.22.2014.10.30.15.12.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Oct 2014 15:12:46 -0700 (PDT) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org, serge.fdrv@gmail.com, edgar.iglesias@gmail.com, aggelerf@ethz.ch, christoffer.dall@linaro.org Date: Thu, 30 Oct 2014 17:12:03 -0500 Message-Id: <1414707132-24588-8-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1414707132-24588-1-git-send-email-greg.bellows@linaro.org> References: <1414707132-24588-1-git-send-email-greg.bellows@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.182 Cc: daniel.thompson@linaro.org Subject: [Qemu-devel] [PATCH v2 07/16] hw/intc/arm_gic: Make ICDDCR/GICD_CTLR banked 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: greg.bellows@linaro.org 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.182 as permitted sender) smtp.mail=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 From: Fabian Aggeler ICDDCR/GICD_CTLR is banked in GICv1 implementations with Security Extensions or in GICv2 in independent from Security Extensions. This makes it possible to enable forwarding of interrupts from Distributor to the CPU interfaces for Group0 and Group1. EnableGroup0 (Bit [1]) in GICv1 is IMPDEF. Since this bit (Enable Non-secure) is present in the integrated IC of the Cortex-A9 MPCore, which implements the GICv1 profile, we support this bit in GICv1 too. Signed-off-by: Fabian Aggeler --- v1 -> v2 - Fix gic_dist_writeb() update of GICD_CTRL to only use bit[0] of the EnableGrp1 field not bit[1]. - Add clarifying comments --- hw/intc/arm_gic.c | 49 ++++++++++++++++++++++++++++++++++++---- hw/intc/arm_gic_common.c | 2 +- include/hw/intc/arm_gic_common.h | 7 +++++- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 36ac188..1db15aa 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -302,8 +302,25 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset) cpu = gic_get_current_cpu(s); cm = 1 << cpu; if (offset < 0x100) { - if (offset == 0) - return s->enabled; + if (offset == 0) { /* GICD_CTLR */ + res = 0; + if ((s->revision == 2 && !s->security_extn) + || (s->security_extn && !ns_access())) { + /* In this case the GICD_CTRL contains both a group0 and group1 + * enable bit, so we create the resuling value by aggregating + * the bits from the two enable values. + * The group0 enable bit is only visible to secure accesses. + * The group1 enable bit (bit[1]) is an alias of bit[0] in + * the non-secure copy (enabled_grp[1]). + */ + res = (s->enabled_grp[1] << 1) | s->enabled_grp[0]; + } else if (s->security_extn && ns_access()) { + res = s->enabled_grp[1]; + } else { + /* Neither GICv2 nor Security Extensions present */ + res = s->enabled; + } + } if (offset == 4) /* Interrupt Controller Type Register */ return ((s->num_irq / 32) - 1) @@ -471,8 +488,32 @@ static void gic_dist_writeb(void *opaque, hwaddr offset, cpu = gic_get_current_cpu(s); if (offset < 0x100) { if (offset == 0) { - s->enabled = (value & 1); - DPRINTF("Distribution %sabled\n", s->enabled ? "En" : "Dis"); + if ((s->revision == 2 && !s->security_extn) + || (s->security_extn && !ns_access())) { + s->enabled_grp[0] = value & (1U << 0); /* EnableGrp0 */ + /* For a GICv1 with Security Extn "EnableGrp1" is IMPDEF. */ + /* We only use the first bit of the enabled_grp vars to + * indicate enabled or disabled. In this case we have to shift + * the incoming value down to the low bit because the group1 + * enabled bit is bit[1] in the secure/GICv2 GICD_CTLR.. + */ + s->enabled_grp[1] = (value >> 1) & 0x1; /* EnableGrp1 */ + DPRINTF("Group0 distribution %sabled\n" + "Group1 distribution %sabled\n", + s->enabled_grp[0] ? "En" : "Dis", + s->enabled_grp[1] ? "En" : "Dis"); + } else if (s->security_extn && ns_access()) { + /* If we are non-secure only the group1 enable bit is visible + * as bit[0] in the GICD_CTLR. + */ + s->enabled_grp[1] = (value & 0x1); + DPRINTF("Group1 distribution %sabled\n", + s->enabled_grp[1] ? "En" : "Dis"); + } else { + /* Neither GICv2 nor Security Extensions present */ + s->enabled = (value & 0x1); + DPRINTF("Distribution %sabled\n", s->enabled ? "En" : "Dis"); + } } else if (offset < 4) { /* ignored. */ } else if (offset >= 0x80) { diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c index 28f3b2a..c44050d 100644 --- a/hw/intc/arm_gic_common.c +++ b/hw/intc/arm_gic_common.c @@ -64,7 +64,7 @@ static const VMStateDescription vmstate_gic = { .pre_save = gic_pre_save, .post_load = gic_post_load, .fields = (VMStateField[]) { - VMSTATE_BOOL(enabled, GICState), + VMSTATE_UINT8_ARRAY(enabled_grp, GICState, GIC_NR_GROUP), VMSTATE_BOOL_ARRAY(cpu_enabled, GICState, GIC_NCPU), VMSTATE_STRUCT_ARRAY(irq_state, GICState, GIC_MAXIRQ, 1, vmstate_gic_irq_state, gic_irq_state), diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_common.h index b78981e..16e193d 100644 --- a/include/hw/intc/arm_gic_common.h +++ b/include/hw/intc/arm_gic_common.h @@ -30,6 +30,8 @@ #define GIC_NR_SGIS 16 /* Maximum number of possible CPU interfaces, determined by GIC architecture */ #define GIC_NCPU 8 +/* Number of Groups (Group0 [Secure], Group1 [Non-secure]) */ +#define GIC_NR_GROUP 2 #define MAX_NR_GROUP_PRIO 128 #define GIC_NR_APRS (MAX_NR_GROUP_PRIO / 32) @@ -52,7 +54,10 @@ typedef struct GICState { qemu_irq parent_irq[GIC_NCPU]; qemu_irq parent_fiq[GIC_NCPU]; - bool enabled; + union { + uint8_t enabled; + uint8_t enabled_grp[GIC_NR_GROUP]; /* EnableGrp0 and EnableGrp1 */ + }; bool cpu_enabled[GIC_NCPU]; gic_irq_state irq_state[GIC_MAXIRQ];