From nobody Sun Nov 24 08:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=kernkonzept.com ARC-Seal: i=1; a=rsa-sha256; t=1725280354; cv=none; d=zohomail.com; s=zohoarc; b=TXc4q4UvMU9XLJBg1rcvtkvPe2Awk5NbRu3IqBoXjC5EFquuqY6GB+fgwG6VIgIZd50l8j3T8ezs8rJjcoavGitIEJhwLrPX9tOU2DCM2SOaJPwtoVds7B59ggdwdSg2GGnaMLIU2Udd+KpM6PB9BdJ3Sbz6qmc0vlQXp69dbDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725280354; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0lHBMMLjyV66zNy0vADjphnQD9Jvz+0KNvkhvWpuC8g=; b=RY2+JFc6qVW0jF0tZMxbMvX+65fEOndWC5Uw0e58KsrEfaGH1essSI6xvkhkfMVmMyQ25nN8nTuLe4ATkXuNf6hat83mqOIZ79pTEMaVzKJrLmAaicQ6xBW5R0b8GO1gRBLe8aZnlwIxSIDTH079Yq6Z8Y0kkSxUOYP1SP5GTnU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725280353809931.4375172092189; Mon, 2 Sep 2024 05:32:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sl6Dl-0004rK-Td; Mon, 02 Sep 2024 08:31:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sl6D1-0004jz-6Z for qemu-devel@nongnu.org; Mon, 02 Sep 2024 08:31:03 -0400 Received: from serv1.kernkonzept.com ([2a01:4f8:1c1c:b490::2] helo=mx.kernkonzept.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sl6Cv-0008UR-R0 for qemu-devel@nongnu.org; Mon, 02 Sep 2024 08:31:02 -0400 Received: from p50883c9a.dip0.t-ipconnect.de ([80.136.60.154] helo=shark.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1sl6Cr-009sVb-12; Mon, 02 Sep 2024 14:30:53 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-Id:Date:Subject:Cc:To:From:References:In-Reply-To: Reply-To:Content-ID:Content-Description; bh=0lHBMMLjyV66zNy0vADjphnQD9Jvz+0KNvkhvWpuC8g=; b=mBLUezLnbDrgq4L6BKIq+72db2 3n/OFWHBuVsw2ev2PQVAFmU33JghhL36HW2YvlMyuh6pAknqscaWpBfMIOgloxaXCgGUj7SjvhKxD mkDb9j+bFsgPDjk1GCZG2oJ5ieI9p2lKmE/OvwIL1kChCEDcofPqg3dSa515w2NP2GIBwcSs23haC b7rsv+ttVS01T6Z3fldefjDC349aFXY2ao7jN00euNdlL9M+SuZ4uEWmSDpZP9Mqclsuw21GkP0Bz qJ2zrfWmQLzXet9gceIacOACBHwnVSvreoge3X0YtM+AneNYBEFsrvduKhZMXDoQb9vcc1Tsb3yiV cIMkrLMA==; From: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= Subject: [PATCH] hw/intc/arm_gic: fix spurious level triggered interrupts Date: Mon, 2 Sep 2024 14:30:38 +0200 Message-Id: <20240902123038.1135412-1-jan.kloetzke@kernkonzept.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a01:4f8:1c1c:b490::2; envelope-from=jan.kloetzke@kernkonzept.com; helo=mx.kernkonzept.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernkonzept.com) X-ZM-MESSAGEID: 1725280356970116600 Level triggered interrupts are pending when either the interrupt line is asserted or the interrupt was made pending by a GICD_ISPENDRn write. Making a level triggered interrupt pending by software persists until either the interrupt is acknowledged or cleared by writing GICD_ICPENDRn. As long as the interrupt line is asserted, the interrupt is pending in any case. This logic is transparently implemented in gic_test_pending(). The function combines the "pending" irq_state flag (used for edge triggered interrupts and software requests) and the line status (tracked in the "level" field). Now, writing GICD_ISENABLERn incorrectly set the pending flag if the line of a level triggered interrupt was asserted. This keeps the interrupt pending even if the line is de-asserted after some time. Fix this by simply removing the code. The pending status is fully handled by gic_test_pending() and does not need any special treatment when enabling the level interrupt. Signed-off-by: Jan Kl=C3=B6tzke --- hw/intc/arm_gic.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 806832439b..10fc9bfd14 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -1248,9 +1248,6 @@ static void gic_dist_writeb(void *opaque, hwaddr offs= et, =20 for (i =3D 0; i < 8; i++) { if (value & (1 << i)) { - int mask =3D - (irq < GIC_INTERNAL) ? (1 << cpu) - : GIC_DIST_TARGET(irq + i); int cm =3D (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MAS= K; =20 if (s->security_extn && !attrs.secure && @@ -1263,13 +1260,6 @@ static void gic_dist_writeb(void *opaque, hwaddr off= set, trace_gic_enable_irq(irq + i); } GIC_DIST_SET_ENABLED(irq + i, cm); - /* If a raised level triggered IRQ enabled then mark - is as pending. */ - if (GIC_DIST_TEST_LEVEL(irq + i, mask) - && !GIC_DIST_TEST_EDGE_TRIGGER(irq + i)) { - DPRINTF("Set %d pending mask %x\n", irq + i, mask); - GIC_DIST_SET_PENDING(irq + i, mask); - } } } } else if (offset < 0x200) { --=20 2.39.2