From patchwork Fri Jan 19 14:57:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 863647 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=greensocs.com header.i=@greensocs.com header.b="DBRH2mZV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="KucRMA2o"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="28BinC0m"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zNRgK74F9z9s7G for ; Sat, 20 Jan 2018 03:51:41 +1100 (AEDT) Received: from localhost ([::1]:59078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecZtE-0003DL-31 for incoming@patchwork.ozlabs.org; Fri, 19 Jan 2018 11:51:40 -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) 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 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) 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= 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=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 = 1023; for (irq = 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 = GIC_GET_PRIORITY(irq, cpu);