From patchwork Thu Jan 25 13:43:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 125854 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1133946ljf; Thu, 25 Jan 2018 06:04:32 -0800 (PST) X-Google-Smtp-Source: AH8x227yRIM/OfUnX/2m8Z8Mzi8zCQxMFgcQDx652jDtg6GZLRhfksJ6MwJLLZUj+DjnsUTfRJ/Y X-Received: by 10.37.201.194 with SMTP id z185mr8027916ybf.405.1516889072267; Thu, 25 Jan 2018 06:04:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516889072; cv=none; d=google.com; s=arc-20160816; b=QFs1Iu/2PaGUw23agS2k+YmKK9uINqiev4RZf25lgVRqbNbT/LxlGaCkSAd/I1RBWQ HpNbO8R0irvgCZ8HWHn/cX7nnnc5skyKk4+dZ2Loq2DiVHiIfmpo7wi+6chtAMt9YaNE qUHsYROoNtAQr5VcACPndCLwB8+7Cl3mmmLthQkRI3PdlIoBlffI4pjkl7dbSz+WB6ez gHkb6UXYikUvbler3n2fddU3uyxnjDVsH9WYGEILwFCw97SYpyKtDCvzEYd0MYOMzIje E5y0us9OqRbiE8Rk0n71MOfC8+nq6f+N3nYlmxEVT7GVUK8cZ3bSxIfAZRL9mxEac6jY WSyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=nxiG6OtXXD/PWiqaLaEtbBR3ovM0vubmAvygshFcVXw=; b=TvPwMayxUjsW2xqfpOh5/A0bMbzGVVLLSAe9rqGCfj3ugLM7moQVkwAKynYt+wuwPj PUNVmOJ6YGRDv1+NWK6oMKPmHK5O5dfpM+byANaxd7OMJxGVeEAIZFDN/BmB47ZiuM0H vUUDqe0HnkJkgpe9ezfUcRNnduoW/i8Ovu3XShuleFSYpFALJk5y0nrQc+eSbaZbX3D/ UJviO64tvAW0BU5/1w4ZEIcJ+6fZiSw/cbQxWvdj3Nl1I5UvBmXtjwkgOb4a71onkirb XYBPYVzT8DdVxl0Fy5qjJZMx3XMvLjtiTd9B1YWb8mInLDhxZ/Ch3c7qSoTEpErEICFd AB3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q10si2479073ybj.227.2018.01.25.06.04.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 25 Jan 2018 06:04:32 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eei8k-0002r0-N3 for patch@linaro.org; Thu, 25 Jan 2018 09:04:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eehoh-0003Fh-Ce for qemu-devel@nongnu.org; Thu, 25 Jan 2018 08:43:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eehog-00039g-Dr for qemu-devel@nongnu.org; Thu, 25 Jan 2018 08:43:47 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:45990) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eehog-00038r-6e for qemu-devel@nongnu.org; Thu, 25 Jan 2018 08:43:46 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eehoe-0006w0-S5 for qemu-devel@nongnu.org; Thu, 25 Jan 2018 13:43:44 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 25 Jan 2018 13:43:23 +0000 Message-Id: <1516887809-6265-16-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516887809-6265-1-git-send-email-peter.maydell@linaro.org> References: <1516887809-6265-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 15/21] hw/intc/arm_gic: Fix C_RPR value on idle priority X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Luc MICHEL When there is no active interrupts in the GIC, a read to the C_RPR register should return the value of the "Idle priority", which is either the maximum value an IRQ priority field can be set to, or 0xff. Since the QEMU GIC model implements all the 8 priority bits, the Idle priority is 0xff. Internally, when there is no active interrupt, the running priority value is 0x100. The gic_get_running_priority function returns an uint8_t and thus, truncate this value to 0x00 when returning it. This is wrong since a value of 0x00 correspond to the maximum possible priority. This commit fixes the returned value when the internal value is 0x100. Note that it is correct for the Non-Secure view to return 0xff even though from the NS world point of view, only 7 priority bits are implemented. The specification states that the Idle priority can be 0xff even when not all the 8 priority bits are implemented. This has been verified against a real GICv2 hardware on a Xilinx ZynqMP based board. Regarding the ARM11MPCore version of the GIC, the specification is not clear on that point, so this commit does not alter its behavior. Signed-off-by: Luc MICHEL Message-id: 20180119145756.7629-4-luc.michel@greensocs.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/intc/arm_gic.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.7.4 diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index dad383e..713de30 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -504,6 +504,11 @@ static void gic_set_cpu_control(GICState *s, int cpu, uint32_t value, static uint8_t gic_get_running_priority(GICState *s, int cpu, MemTxAttrs attrs) { + if ((s->revision != REV_11MPCORE) && (s->running_priority[cpu] > 0xff)) { + /* Idle priority */ + return 0xff; + } + if (s->security_extn && !attrs.secure) { if (s->running_priority[cpu] & 0x80) { /* Running priority in upper half of range: return the Non-secure