From patchwork Thu Oct 30 22:12:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 39949 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8EA47202FE for ; Fri, 31 Oct 2014 18:02:17 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id n3sf932798wiv.1 for ; Fri, 31 Oct 2014 11:02:16 -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=E50DivOS9BQ4Tw+vGnII3MSBo11p17WllckOpyX0f1Y=; b=QEQkSzUJ4bclb5A63v8BCVlHUjV6EBilTao12JYbaaW7giN35u+3cTiR3uzYxylczZ Pw0zWOlBBmjlEtLvA5Xxzs0QdTDDNOT9lvH6oihaOgLkCVA9Zim7UNJJpkqyMlTJffXS 9Vav+kPd4b3fyNMnbKt1UKmn3isTTMuO66DCgz/FhY4SYWocv1Z/cE2vOaSkJw6u3Amf Emj2PYUt66+PMNqBu5gNSXBkGUH8/edChVexCylneAC9eip/4+lsjjJaGmvvTwYLl0Qb ZlEphxHO/mNbYbzwzOc5uQp004g3sOM/cnwUOq68c69p+/GHkCz5PYGFLLHJNvlHOGZo 8tcw== X-Gm-Message-State: ALoCoQkclnT8d7ax8F3OFvJf391JWDSyPg+WCBCNM6hmFYONJ5Oowoi315Y+rf279vDsbYAAe5DG X-Received: by 10.112.137.202 with SMTP id qk10mr703445lbb.11.1414778536457; Fri, 31 Oct 2014 11:02:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.133 with SMTP id m5ls486904laf.102.gmail; Fri, 31 Oct 2014 11:02:16 -0700 (PDT) X-Received: by 10.112.93.231 with SMTP id cx7mr27764087lbb.89.1414778536310; Fri, 31 Oct 2014 11:02:16 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id wt3si17998399lbb.44.2014.10.31.11.02.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 11:02:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id 10so6509715lbg.36 for ; Fri, 31 Oct 2014 11:02:15 -0700 (PDT) X-Received: by 10.112.189.10 with SMTP id ge10mr27923001lbc.23.1414778535786; Fri, 31 Oct 2014 11:02:15 -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 c5csp240298lbz; Fri, 31 Oct 2014 11:02:15 -0700 (PDT) X-Received: by 10.224.103.74 with SMTP id j10mr18992057qao.101.1414778534412; Fri, 31 Oct 2014 11:02:14 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id e74si18211168qgd.89.2014.10.31.11.02.13 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 31 Oct 2014 11:02:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Received: from localhost ([::1]:40390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkGWb-0005GS-Cs for patch@linaro.org; Fri, 31 Oct 2014 14:02:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkE4w-0004GS-Bo for qemu-devel@nongnu.org; Fri, 31 Oct 2014 11:26:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xjxxf-0006DI-3b for qemu-devel@nongnu.org; Thu, 30 Oct 2014 18:13:01 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:53189) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xjxxe-0006Ck-TS for qemu-devel@nongnu.org; Thu, 30 Oct 2014 18:12:55 -0400 Received: by mail-pd0-f172.google.com with SMTP id r10so6026590pdi.3 for ; Thu, 30 Oct 2014 15:12:54 -0700 (PDT) X-Received: by 10.68.90.34 with SMTP id bt2mr20392937pbb.29.1414707174290; Thu, 30 Oct 2014 15:12:54 -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.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Oct 2014 15:12:53 -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:07 -0500 Message-Id: <1414707132-24588-12-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.172 Cc: daniel.thompson@linaro.org Subject: [Qemu-devel] [PATCH v2 11/16] hw/intc/arm_gic: Handle grouping for GICC_HPPIR 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.177 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 Grouping (GICv2) and Security Extensions change the behaviour of reads of the highest priority pending interrupt register (ICCHPIR/GICC_HPPIR). Signed-off-by: Fabian Aggeler --- hw/intc/arm_gic.c | 29 ++++++++++++++++++++++++++++- hw/intc/gic_internal.h | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 9b021d7..15fd660 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -329,6 +329,33 @@ uint8_t gic_get_running_priority(GICState *s, int cpu) } } +uint16_t gic_get_current_pending_irq(GICState *s, int cpu) +{ + bool isGrp0; + uint16_t pendingId = s->current_pending[cpu]; + + if (pendingId < GIC_MAXIRQ && (s->revision >= 2 || s->security_extn)) { + isGrp0 = GIC_TEST_GROUP0(pendingId, (1 << cpu)); + if ((isGrp0 && !s->enabled_grp[0]) + || (!isGrp0 && !s->enabled_grp[1])) { + return 1023; + } + if (s->security_extn) { + if (isGrp0 && ns_access()) { + /* Group0 interrupts hidden from Non-secure access */ + return 1023; + } + if (!isGrp0 && !ns_access() + && !(s->cpu_control[cpu][0] & GICC_CTLR_S_ACK_CTL)) { + /* Group1 interrupts only seen by Secure access if + * AckCtl bit set. */ + return 1022; + } + } + } + return pendingId; +} + void gic_complete_irq(GICState *s, int cpu, int irq) { int update = 0; @@ -866,7 +893,7 @@ static uint32_t gic_cpu_read(GICState *s, int cpu, int offset) case 0x14: /* Running Priority */ return gic_get_running_priority(s, cpu); case 0x18: /* Highest Pending Interrupt */ - return s->current_pending[cpu]; + return gic_get_current_pending_irq(s, cpu); case 0x1c: /* Aliased Binary Point */ if (!s->security_extn || (s->security_extn && ns_access())) { /* If Security Extensions are present ABPR is a secure register, diff --git a/hw/intc/gic_internal.h b/hw/intc/gic_internal.h index 821ce16..fbb1f66 100644 --- a/hw/intc/gic_internal.h +++ b/hw/intc/gic_internal.h @@ -79,6 +79,7 @@ void gic_set_priority(GICState *s, int cpu, int irq, uint8_t val); uint32_t gic_get_cpu_control(GICState *s, int cpu); void gic_set_cpu_control(GICState *s, int cpu, uint32_t value); uint8_t gic_get_running_priority(GICState *s, int cpu); +uint16_t gic_get_current_pending_irq(GICState *s, int cpu); static inline bool gic_test_pending(GICState *s, int irq, int cm)