From patchwork Wed Apr 15 16:02:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 47213 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 46FD22121F for ; Wed, 15 Apr 2015 16:04:10 +0000 (UTC) Received: by widjs5 with SMTP id js5sf12568398wid.3 for ; Wed, 15 Apr 2015 09:04:09 -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=vJXhUi6tQpMFNgPetSdd8T/dIvxy5waKrCPJeJcDJms=; b=XPbkdnlAGJ+enuE6us4y5ZN2JMbZV2RGr6EK2dPaDv+77rgJHFoXxkjbRE57Cjecb4 Yl7irqS6XaYK+PWrN0yRyimgzIt/NDggiifwodVzRd5cPR6cf13CB8YCjKhBiyCZ6Xr7 t+1Nern4PE+av+KRU7UhXJAirGKFdvIyJzA9901fMdFfSjmIjSGZYIORtUNfA7Eec/66 l8Src4gQrRxRGaV03ufkffj1rsz4cE4lj7xpieg2ui5cn3jEzBSUdt9EGibe52BpmHPB Uc2gkGZvmrqds2gzd/eaa8KjBJYN0cgJNiumtf4dB8ePKLSBV7cACsL9QJI2Q413iyFU DQ3A== X-Gm-Message-State: ALoCoQn4U4mvjQ7ugtPAqkdOtzkNvhpWGsYhPZvrp5Qy/qXP3ZCR7vVLI2hcpR90lGKgTKYHLuFH X-Received: by 10.194.178.67 with SMTP id cw3mr5681571wjc.2.1429113849594; Wed, 15 Apr 2015 09:04:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.7 with SMTP id w7ls196049law.96.gmail; Wed, 15 Apr 2015 09:04:09 -0700 (PDT) X-Received: by 10.112.139.130 with SMTP id qy2mr18188179lbb.33.1429113849298; Wed, 15 Apr 2015 09:04:09 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id i6si4209203laa.144.2015.04.15.09.04.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2015 09:04:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by layy10 with SMTP id y10so36356489lay.0 for ; Wed, 15 Apr 2015 09:04:09 -0700 (PDT) X-Received: by 10.152.116.11 with SMTP id js11mr24584656lab.106.1429113849128; Wed, 15 Apr 2015 09:04:09 -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.67.65 with SMTP id l1csp2606161lbt; Wed, 15 Apr 2015 09:04:08 -0700 (PDT) X-Received: by 10.140.94.104 with SMTP id f95mr31696590qge.38.1429113847701; Wed, 15 Apr 2015 09:04:07 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m8si5065353qco.39.2015.04.15.09.04.06 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 15 Apr 2015 09:04:07 -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]:32947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiPnK-00032A-0t for patch@linaro.org; Wed, 15 Apr 2015 12:04:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiPmD-0001xn-JR for qemu-devel@nongnu.org; Wed, 15 Apr 2015 12:02:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YiPmA-0001uD-Q9 for qemu-devel@nongnu.org; Wed, 15 Apr 2015 12:02:57 -0400 Received: from mail-vn0-f41.google.com ([209.85.216.41]:44139) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiPmA-0001u6-Ld for qemu-devel@nongnu.org; Wed, 15 Apr 2015 12:02:54 -0400 Received: by vnbg7 with SMTP id g7so16694306vnb.11 for ; Wed, 15 Apr 2015 09:02:54 -0700 (PDT) X-Received: by 10.182.48.231 with SMTP id p7mr21649846obn.19.1429113774264; Wed, 15 Apr 2015 09:02:54 -0700 (PDT) Received: from gbellows-linaro.gateway.pace.com (99-179-1-214.lightspeed.austtx.sbcglobal.net. [99.179.1.214]) by mx.google.com with ESMTPSA id x142sm2567707oie.19.2015.04.15.09.02.52 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Apr 2015 09:02:53 -0700 (PDT) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Wed, 15 Apr 2015 11:02:19 -0500 Message-Id: <1429113742-8371-14-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1429113742-8371-1-git-send-email-greg.bellows@linaro.org> References: <1429113742-8371-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.216.41 Cc: Fabian Aggeler , Greg Bellows Subject: [Qemu-devel] [PATCH v3 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.215.45 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 Signed-off-by: Greg Bellows --- 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 1ba4dfd..3959693 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) {