From patchwork Thu Oct 30 22:12:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 39923 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 169B92405B for ; Fri, 31 Oct 2014 15:57:06 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id q1sf4314972lam.0 for ; Fri, 31 Oct 2014 08:57:05 -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=Yvz/xl27nLVw0g2xuhSlOTRxdy+2YfYYil8kbYlTRek=; b=IfUVu1eS2jwmBJ7Ai5biHja/gxPV6r0UZT4a3SVu6R1ZclqHAzK0SyAhYIyEmhZkih /kZVkWonNaDHB8q68y0BNg46GmbE4coNtiwzQtzKVh0/Rwzm8XkJ6Tnzy0F8jxteXFi8 HglSe7q2reJ2h1BKmS2DPxzJaCxcDEn0NliEISbXtt56LsKPgQauFohLnfq/hivRes1r WH9IqMm7nZ8Z3j29GVqAqJkHEdPphTJ0a7mPCx8LMFWmAQrlPUB9J4j7VxQxoymYiwnp jAhlW44+7h8AbmxSwI0X5XLCq2LFcrMXzCUPRqYJhMO9N37Eos1q0MflMfoq+GrVJ+zB eveQ== X-Gm-Message-State: ALoCoQn38iZR++aJ+in2ESjCCFRi1A2Jd1xB6QjRUVUO3MdVOEXjM6VeJ48JlhNy957q/0Zru+L/ X-Received: by 10.194.206.10 with SMTP id lk10mr737055wjc.3.1414771025943; Fri, 31 Oct 2014 08:57:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.169 with SMTP id f9ls472958lam.11.gmail; Fri, 31 Oct 2014 08:57:05 -0700 (PDT) X-Received: by 10.152.29.41 with SMTP id g9mr27646377lah.83.1414771025563; Fri, 31 Oct 2014 08:57:05 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id lb6si17314373lac.111.2014.10.31.08.57.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 08:57:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id b6so6211913lbj.6 for ; Fri, 31 Oct 2014 08:57:05 -0700 (PDT) X-Received: by 10.152.116.102 with SMTP id jv6mr27394041lab.40.1414771025130; Fri, 31 Oct 2014 08:57:05 -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 c5csp224004lbz; Fri, 31 Oct 2014 08:57:04 -0700 (PDT) X-Received: by 10.224.80.6 with SMTP id r6mr37476135qak.5.1414771023331; Fri, 31 Oct 2014 08:57:03 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t7si368250qah.113.2014.10.31.08.57.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 31 Oct 2014 08:57:03 -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]:38531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkEZS-00058W-GP for patch@linaro.org; Fri, 31 Oct 2014 11:57:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkE4w-0006vX-42 for qemu-devel@nongnu.org; Fri, 31 Oct 2014 11:26:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xjxxi-0006Gk-3E for qemu-devel@nongnu.org; Thu, 30 Oct 2014 18:13:04 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:63172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xjxxh-0006G1-TI for qemu-devel@nongnu.org; Thu, 30 Oct 2014 18:12:58 -0400 Received: by mail-pa0-f51.google.com with SMTP id kq14so6382171pab.10 for ; Thu, 30 Oct 2014 15:12:57 -0700 (PDT) X-Received: by 10.68.231.232 with SMTP id tj8mr39097pbc.166.1414707177273; Thu, 30 Oct 2014 15:12:57 -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.55 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Oct 2014 15:12:56 -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:09 -0500 Message-Id: <1414707132-24588-14-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.220.51 Cc: daniel.thompson@linaro.org Subject: [Qemu-devel] [PATCH v2 13/16] hw/intc/arm_gic: Change behavior of IAR writes 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.175 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 behavior of IAR reads. Acknowledging Group0 interrupts is only allowed from Secure state and acknowledging Group1 interrupts from Secure state is only allowed if AckCtl bit is set. Signed-off-by: Fabian Aggeler --- v1 -> v2 - Fix issue in gic_acknowledge_irq() where the GICC_CTLR_S_ACK_CTL flag is applied without first checking whether the read is secure or non-secure. Secure reads of IAR when AckCtl is 0 return a spurious ID of 1022, but non-secure ignores the flag. --- hw/intc/arm_gic.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 2d83225..7eb72df 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -190,11 +190,36 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu) int ret, irq, src; int cm = 1 << cpu; irq = s->current_pending[cpu]; + bool isGrp0; if (irq == 1023 || GIC_GET_PRIORITY(irq, cpu) >= s->running_priority[cpu]) { DPRINTF("ACK no pending IRQ\n"); return 1023; } + + if (s->revision >= 2 || s->security_extn) { + isGrp0 = GIC_TEST_GROUP0(irq, (1 << cpu)); + if ((isGrp0 && (!s->enabled_grp[0] + || !(s->cpu_control[cpu][0] & GICC_CTLR_S_EN_GRP0))) + || (!isGrp0 && (!s->enabled_grp[1] + || !(s->cpu_control[cpu][1] & GICC_CTLR_NS_EN_GRP1)))) { + return 1023; + } + + if ((s->revision >= 2 && !s->security_extn) + || (s->security_extn && !ns_access())) { + if (!isGrp0 && !ns_access() && + !(s->cpu_control[cpu][0] & GICC_CTLR_S_ACK_CTL)) { + DPRINTF("Read of IAR ignored for Group1 interrupt %d " + "(AckCtl disabled)\n", irq); + return 1022; + } + } else if (s->security_extn && ns_access() && isGrp0) { + DPRINTF("Non-secure read of IAR ignored for Group0 interrupt %d\n", + irq); + return 1023; + } + } s->last_active[irq][cpu] = s->running_irq[cpu]; if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {