From nobody Mon Apr 29 14:30:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516380783774154.91908547500634; Fri, 19 Jan 2018 08:53:03 -0800 (PST) Received: from localhost ([::1]:59084 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZuY-0004dU-0Q for importer@patchew.org; Fri, 19 Jan 2018 11:53:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecY7W-0002pR-HX for qemu-devel@nongnu.org; Fri, 19 Jan 2018 09:58:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecY7V-0003mw-Ls for qemu-devel@nongnu.org; Fri, 19 Jan 2018 09:58:18 -0500 Received: from greensocs.com ([193.104.36.180]:39270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecY7P-0003iM-W3; Fri, 19 Jan 2018 09:58:12 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 7365B319FD1; Fri, 19 Jan 2018 15:58:01 +0100 (CET) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZOD40wOXCPEF; Fri, 19 Jan 2018 15:58:00 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 0D324319FC7; Fri, 19 Jan 2018 15:58:00 +0100 (CET) Received: from michell-laptop.hive.antfield.fr (tima-dhcp-h14.imag.fr [147.171.132.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id B54355E2F8; Fri, 19 Jan 2018 15:57:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373881; bh=HrHpyMxolNmkgunbKJZFrlz035vs8W/r8Ad5WckIJao=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DBRH2mZV1CeRM+GBB2yjEalJ38brZKoC2amh661gfYMjF++RLrVAB/R7hrORvNvYn J7MDKlet+DBFMo87rmlSub9ySam5yFoSzJPqT2YUzsHglF1AeiLLJQfGqa5bNDmk+c V8XfV0ciQPK4RbSG0gt7EqUm58oHtgQLlHHzokgg= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=KucRMA2o; dkim=pass (1024-bit key) header.d=greensocs.com header.b=28BinC0m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373880; bh=HrHpyMxolNmkgunbKJZFrlz035vs8W/r8Ad5WckIJao=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KucRMA2o81uQh4F9qBuLpmhVND+faKI22wnlZDWMGePrH9bAZZl9BGT66HpofqmJc 3LQEj1/E1QFT9e6JOEIXDZl29BfeRhz4zCK2OltzenkQKnAMHVrgxnvWM9TJC3NHEU CAVqD04UVbafAm4Nsqz1hUAnlJsYubH9XqIg8Qoo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373879; bh=HrHpyMxolNmkgunbKJZFrlz035vs8W/r8Ad5WckIJao=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=28BinC0mPAFgWEJDhSg6rCd0mdRit7fcW5zBoAvMR2q8iL3tbOsQe+S7tmuRMmPZ1 ItEM6/mZtd4C0GyhZ9uibD9ky56YCc9jVCqxJvwoPpcXb7qRDwDPIOjRciNu32ESvQ VKRGI+tYKvNrr0LkKyltPbYa0BdWjK3afBH4yYcQ= From: luc.michel@greensocs.com To: qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 15:57:53 +0100 Message-Id: <20180119145756.7629-3-luc.michel@greensocs.com> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180119145756.7629-1-luc.michel@greensocs.com> References: <20180119145756.7629-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 X-Mailman-Approved-At: Fri, 19 Jan 2018 11:42:55 -0500 Subject: [Qemu-devel] [PATCH 1/4] hw/intc/arm_gic: Prevent the GIC from signaling an IRQ when it's "active and pending" 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: , Cc: "Edgar E . Iglesias" , Peter Maydell , Alistair Francis , qemu-arm@nongnu.org, Luc MICHEL Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 3 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Luc MICHEL In the GIC, when an IRQ is acknowledged, its state goes from "pending" to: - "active" if the corresponding IRQ pin has been de-asserted - "active and pending" otherwise. The GICv2 manual states that when a IRQ becomes active (or active and pending), the GIC should either signal another (higher priority) IRQ to the CPU if there is one, or de-assert the CPU IRQ pin. The current implementation of the GIC in QEMU does not check if the IRQ is already active when looking for pending interrupts with sufficient priority in gic_update(). This can lead to signaling an interrupt that is already active. This usually happens when splitting priority drop and interrupt deactivation. On priority drop, the IRQ stays active until deactivation. If it becomes pending again, chances are that it will be incorrectly selected as best_irq in gic_update(). This commit fixes this by checking if the IRQ is not already active when looking for best_irq in gic_update(). Note that regarding the ARM11MPCore GIC version, the corresponding manual is not clear on that point, but it has has no priority drop/interrupt deactivation separation, so this case should not happen. Signed-off-by: Luc MICHEL --- hw/intc/arm_gic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index d701e49ff9..dad383ea12 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -93,6 +93,7 @@ void gic_update(GICState *s) best_irq =3D 1023; for (irq =3D 0; irq < s->num_irq; irq++) { if (GIC_TEST_ENABLED(irq, cm) && gic_test_pending(s, irq, cm) = && + (!GIC_TEST_ACTIVE(irq, cm)) && (irq < GIC_INTERNAL || GIC_TARGET(irq) & cm)) { if (GIC_GET_PRIORITY(irq, cpu) < best_prio) { best_prio =3D GIC_GET_PRIORITY(irq, cpu); --=20 2.16.0 From nobody Mon Apr 29 14:30:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516381701233791.9473888315994; Fri, 19 Jan 2018 09:08:21 -0800 (PST) Received: from localhost ([::1]:59965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eca9M-0001hB-FD for importer@patchew.org; Fri, 19 Jan 2018 12:08:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecY7W-0002pF-AG for qemu-devel@nongnu.org; Fri, 19 Jan 2018 09:58:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecY7V-0003mY-Ej for qemu-devel@nongnu.org; Fri, 19 Jan 2018 09:58:18 -0500 Received: from greensocs.com ([193.104.36.180]:39271) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecY7Q-0003iJ-07; Fri, 19 Jan 2018 09:58:12 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id E0338319FD9; Fri, 19 Jan 2018 15:58:02 +0100 (CET) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gFFmqKY4nc5C; Fri, 19 Jan 2018 15:58:01 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 56E995E2F8; Fri, 19 Jan 2018 15:58:00 +0100 (CET) Received: from michell-laptop.hive.antfield.fr (tima-dhcp-h14.imag.fr [147.171.132.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 109C9319FC8; Fri, 19 Jan 2018 15:58:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373882; bh=v+8I3H1qOqPd2WU9LWyfosRG0vDqmGje0yEI+Fsyyg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=7a9JZIa8ayVlAqcYbgJU2tVEH293HQOLYeKYyg27d+BCLrnx6BNDo+r8gI3MMllf6 Zoml2ETjJYhlFvW9Rc2PRzTWtldiF4/hZDBRr1x5JAqQf9ll+CLzDUnIpvpZ1U/ne4 Lc2I1w6ObaXPySbcxY7yCydUd1yH6+mK6OZp7qo8= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=tSpuIPYz; dkim=pass (1024-bit key) header.d=greensocs.com header.b=tSpuIPYz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373880; bh=v+8I3H1qOqPd2WU9LWyfosRG0vDqmGje0yEI+Fsyyg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tSpuIPYzP4aWXyPfcXrerPQtWwfMfEF6crRt9Ie1vgtOjTwhNkM6RUdZrG0RfovLk w85GBNHGTpBfRWm2KJLmRpE47vDM2hP/6mwx6wvG7t6uIUhayVSEqSp3Tg3/Hvw06R C3zkx9LxvbwXlgGiLVcaknbVieDAevb08YgIyews= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373880; bh=v+8I3H1qOqPd2WU9LWyfosRG0vDqmGje0yEI+Fsyyg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tSpuIPYzP4aWXyPfcXrerPQtWwfMfEF6crRt9Ie1vgtOjTwhNkM6RUdZrG0RfovLk w85GBNHGTpBfRWm2KJLmRpE47vDM2hP/6mwx6wvG7t6uIUhayVSEqSp3Tg3/Hvw06R C3zkx9LxvbwXlgGiLVcaknbVieDAevb08YgIyews= From: luc.michel@greensocs.com To: qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 15:57:54 +0100 Message-Id: <20180119145756.7629-4-luc.michel@greensocs.com> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180119145756.7629-1-luc.michel@greensocs.com> References: <20180119145756.7629-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 X-Mailman-Approved-At: Fri, 19 Jan 2018 11:42:55 -0500 Subject: [Qemu-devel] [PATCH 2/4] 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: , Cc: "Edgar E . Iglesias" , Peter Maydell , Alistair Francis , qemu-arm@nongnu.org, Luc MICHEL Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- hw/intc/arm_gic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index dad383ea12..713de3084f 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, =20 static uint8_t gic_get_running_priority(GICState *s, int cpu, MemTxAttrs a= ttrs) { + if ((s->revision !=3D REV_11MPCORE) && (s->running_priority[cpu] > 0xf= f)) { + /* 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-sec= ure --=20 2.16.0 From nobody Mon Apr 29 14:30:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516381322690216.1142307320904; Fri, 19 Jan 2018 09:02:02 -0800 (PST) Received: from localhost ([::1]:59369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eca3G-0004JQ-0h for importer@patchew.org; Fri, 19 Jan 2018 12:02:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecY7W-0002pE-9v for qemu-devel@nongnu.org; Fri, 19 Jan 2018 09:58:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecY7V-0003mf-Fq for qemu-devel@nongnu.org; Fri, 19 Jan 2018 09:58:18 -0500 Received: from greensocs.com ([193.104.36.180]:39272) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecY7P-0003iK-W6; Fri, 19 Jan 2018 09:58:12 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id A23FE5E2F8; Fri, 19 Jan 2018 15:58:03 +0100 (CET) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O-rtn_aslmTM; Fri, 19 Jan 2018 15:58:02 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id C3E0965A17; Fri, 19 Jan 2018 15:58:00 +0100 (CET) Received: from michell-laptop.hive.antfield.fr (tima-dhcp-h14.imag.fr [147.171.132.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 5AED2319FD0; Fri, 19 Jan 2018 15:58:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373883; bh=FlcRuHgM7HCaRegPGAVU37r0+yEoKHRp0N1iIQwTaDw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pQSyzoOe8YEX3VzsCnuqBiU0qYrk40pUDsWguGegoVpIR/k7ISPSm8kpbGNWzSd+C rAVeP/0BgzXW0R3YkSfex9vlHAQXx4iLA2OeUlnY+EHnoPgzvgUl7xpvtjDWXlFNqW ydHM0wLmEPmwVIy0igClzSSWJsl07AYsMN1S+aro= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=pOv5g5cu; dkim=pass (1024-bit key) header.d=greensocs.com header.b=pOv5g5cu DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373880; bh=FlcRuHgM7HCaRegPGAVU37r0+yEoKHRp0N1iIQwTaDw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pOv5g5cuZZ7Zj7Pm5RiUa7aUMzq0foA9mpsEnqQkKfkM+duwlYilfj9oW1hUQOk6T boLvYnedTZ+cIRgBp4I5b7XQlICVLd3LPsSmW7ProsgIu9P35UGVmVAa1l+YPcV/Z/ tLKbzu0l72EBfvJR9yowiSUcTAo4Fb8kjPbEaUzY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373880; bh=FlcRuHgM7HCaRegPGAVU37r0+yEoKHRp0N1iIQwTaDw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pOv5g5cuZZ7Zj7Pm5RiUa7aUMzq0foA9mpsEnqQkKfkM+duwlYilfj9oW1hUQOk6T boLvYnedTZ+cIRgBp4I5b7XQlICVLd3LPsSmW7ProsgIu9P35UGVmVAa1l+YPcV/Z/ tLKbzu0l72EBfvJR9yowiSUcTAo4Fb8kjPbEaUzY= From: luc.michel@greensocs.com To: qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 15:57:55 +0100 Message-Id: <20180119145756.7629-5-luc.michel@greensocs.com> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180119145756.7629-1-luc.michel@greensocs.com> References: <20180119145756.7629-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 X-Mailman-Approved-At: Fri, 19 Jan 2018 11:42:55 -0500 Subject: [Qemu-devel] [PATCH 3/4] hw/intc/arm_gic: Fix group priority computation for group 1 IRQs 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: , Cc: "Edgar E . Iglesias" , Peter Maydell , Alistair Francis , qemu-arm@nongnu.org, Luc MICHEL Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Luc MICHEL When determining the group priority of a group 1 IRQ, if C_CTRL.CBPR is 0, the non-secure BPR value is used. However, this value must be incremented by one so that it matches the secure world number of implemented priority bits (NS world has one less priority bit compared to the Secure world). Signed-off-by: Luc MICHEL --- hw/intc/arm_gic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 713de3084f..d0a41a89ae 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -256,7 +256,7 @@ static int gic_get_group_priority(GICState *s, int cpu,= int irq) if (gic_has_groups(s) && !(s->cpu_ctlr[cpu] & GICC_CTLR_CBPR) && GIC_TEST_GROUP(irq, (1 << cpu))) { - bpr =3D s->abpr[cpu]; + bpr =3D s->abpr[cpu] - 1; } else { bpr =3D s->bpr[cpu]; } --=20 2.16.0 From nobody Mon Apr 29 14:30:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516381513799677.3390903729427; Fri, 19 Jan 2018 09:05:13 -0800 (PST) Received: from localhost ([::1]:59723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eca6K-0007DP-62 for importer@patchew.org; Fri, 19 Jan 2018 12:05:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecY7W-0002pT-I2 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 09:58:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecY7V-0003mn-Hw for qemu-devel@nongnu.org; Fri, 19 Jan 2018 09:58:18 -0500 Received: from greensocs.com ([193.104.36.180]:39273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecY7P-0003iL-WD; Fri, 19 Jan 2018 09:58:12 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id CA09B65A14; Fri, 19 Jan 2018 15:58:03 +0100 (CET) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R0UB70wXBmRD; Fri, 19 Jan 2018 15:58:03 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id F30F0319FD0; Fri, 19 Jan 2018 15:58:00 +0100 (CET) Received: from michell-laptop.hive.antfield.fr (tima-dhcp-h14.imag.fr [147.171.132.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id A6F28319FD1; Fri, 19 Jan 2018 15:58:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373883; bh=g6nlRw/e1ZG7zJp5fvespuMpsjuDbplCDnFGXjGLpqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uAeCMlxctAH1yPiklSRoKiYLxqxwQnxPLh5nbq5MgwC7V3glk2SaYa70IYwPeOYxp NPoBefgSkJGTF6UnwGcN8b2I513UwRxE1ZiP3qTqUcPhc3bzsxhk96rVX2c1PSGIV2 SRXwSaMXftd+rDUNzFnDYkAg5u4YB6phiabHpmKA= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=qsxARHN1; dkim=pass (1024-bit key) header.d=greensocs.com header.b=qsxARHN1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373880; bh=g6nlRw/e1ZG7zJp5fvespuMpsjuDbplCDnFGXjGLpqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qsxARHN1C+Ui/0ZHHZWqmqm/aLbYZkTYWWflUKvQFGIMefKzHm1+/JIaaB4pqSpCJ 36ezMNc3ELXX1/dxFaMY4z2p4gCDzWym1amhDmAC4aldB5rum2F+R9AQx8k7H0tI75 LwhOrjJlBmTDgq/V13yfy3jQNqkZMov4IgAKR6oI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1516373880; bh=g6nlRw/e1ZG7zJp5fvespuMpsjuDbplCDnFGXjGLpqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qsxARHN1C+Ui/0ZHHZWqmqm/aLbYZkTYWWflUKvQFGIMefKzHm1+/JIaaB4pqSpCJ 36ezMNc3ELXX1/dxFaMY4z2p4gCDzWym1amhDmAC4aldB5rum2F+R9AQx8k7H0tI75 LwhOrjJlBmTDgq/V13yfy3jQNqkZMov4IgAKR6oI= From: luc.michel@greensocs.com To: qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 15:57:56 +0100 Message-Id: <20180119145756.7629-6-luc.michel@greensocs.com> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180119145756.7629-1-luc.michel@greensocs.com> References: <20180119145756.7629-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 X-Mailman-Approved-At: Fri, 19 Jan 2018 11:42:55 -0500 Subject: [Qemu-devel] [PATCH 4/4] hw/intc/arm_gic: Fix the NS view of C_BPR when C_CTRL.CBPR is 1 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: , Cc: "Edgar E . Iglesias" , Peter Maydell , Alistair Francis , qemu-arm@nongnu.org, Luc MICHEL Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Luc MICHEL When C_CTRL.CBPR is 1, the Non-Secure view of C_BPR is altered: - A Non-Secure read of C_BPR should return the BPR value plus 1, saturated to 7, - A Non-Secure write should be ignored. Signed-off-by: Luc MICHEL --- hw/intc/arm_gic.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index d0a41a89ae..7418b7a082 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -1211,8 +1211,13 @@ static MemTxResult gic_cpu_read(GICState *s, int cpu= , int offset, break; case 0x08: /* Binary Point */ if (s->security_extn && !attrs.secure) { - /* BPR is banked. Non-secure copy stored in ABPR. */ - *data =3D s->abpr[cpu]; + if (s->cpu_ctlr[cpu] & GICC_CTLR_CBPR) { + /* NS view of BPR when CBPR is 1 */ + *data =3D MIN(s->bpr[cpu] + 1, 7); + } else { + /* BPR is banked. Non-secure copy stored in ABPR. */ + *data =3D s->abpr[cpu]; + } } else { *data =3D s->bpr[cpu]; } @@ -1285,7 +1290,12 @@ static MemTxResult gic_cpu_write(GICState *s, int cp= u, int offset, break; case 0x08: /* Binary Point */ if (s->security_extn && !attrs.secure) { - s->abpr[cpu] =3D MAX(value & 0x7, GIC_MIN_ABPR); + if (s->cpu_ctlr[cpu] & GICC_CTLR_CBPR) { + /* WI when CTLR is 1 */ + return MEMTX_OK; + } else { + s->abpr[cpu] =3D MAX(value & 0x7, GIC_MIN_ABPR); + } } else { s->bpr[cpu] =3D MAX(value & 0x7, GIC_MIN_BPR); } --=20 2.16.0