From patchwork Thu Jan 25 13:43:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 125857 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1136078ljf; Thu, 25 Jan 2018 06:07:15 -0800 (PST) X-Google-Smtp-Source: AH8x226cgZixtc/4s99ro0qIdO6HKblanTZmCiZxynHHRv9c2br4oHQRNsaso2txZhzPMA2I9xBH X-Received: by 10.129.175.19 with SMTP id n19mr8359325ywh.37.1516889235484; Thu, 25 Jan 2018 06:07:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516889235; cv=none; d=google.com; s=arc-20160816; b=lpW2CgvFEv6YYsEXUvA8Ue8jpXhFl/ngHMYqX8zwQLYeYv2j6Z6J0T5sstPVofxQC0 n+dRGeHzrT9K69ABmWmTgJ+VhKYhXpGt+pIEGEZxgKCSZAloFa9JtgZmetVt1i1TNPzw b3curhM83J8RJMXj+PvyZO5V4RdV8b+OKnt2uEpM5yGLAK1YHpNeWeL88HVdEV1wtgRM RueUeu9OBSYsUMIIV3ETKfl+YXE3raifuSlabBXseStolYrqP3GNYAnHKoMsGoIEwzmz CQ2zOFvr44Zk3MX9SpGiAxy5f/fR2ry8Zzw6fvv1gcQeRBNI44TkSbso47O13IBPnhfw dJxA== 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=gQsZyHDoJnQMxfTnVGFTzVeywZrOocYBglJqRIRpK1c=; b=IJKnm5h25dNr4jjXWhjPBa/iOPL5KtT+DNhucob/EXC2o0izP/I6T4rAr2zIusEXfS 2sNvvVMQJSmhF+Bmt4Ig14JgyivXEqlxm8Js/Dcb05a1Z8Q5lXLXT3cDk64NzSbpl0Cq 8cWesSl6ntRFn2zigAxFjxRDd8gY0DpGieBvRvCmeEnzf/+vD52TyxOuy55mB7jgz6yi vhpwuOeaICZXm6LTaMLCvt1o7rWBJmNQQoVpxyyGBJmBkm02KL0Y0Qmp/1MdxGd3Z/oX OjVyb2wKBY6IWUdZVggdKe74uEnvtZ9CBiHT5m6GekcSr6XcScZ2bH+GO7q08ZVU1CI3 KiPw== 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 p126si3240314ybp.54.2018.01.25.06.07.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 25 Jan 2018 06:07:15 -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]:42174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeiBO-00058X-Uh for patch@linaro.org; Thu, 25 Jan 2018 09:07:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eehoh-0003FO-4P for qemu-devel@nongnu.org; Thu, 25 Jan 2018 08:43:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eehog-00039P-7e for qemu-devel@nongnu.org; Thu, 25 Jan 2018 08:43:47 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:45982) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eehog-00030M-05 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-0006v4-5e 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:22 +0000 Message-Id: <1516887809-6265-15-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 14/21] 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: , Errors-To: qemu-devel-bounces+patch=linaro.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 Message-id: 20180119145756.7629-3-luc.michel@greensocs.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/intc/arm_gic.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index d701e49..dad383e 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);