From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27B2F19E7F7; Fri, 17 Oct 2025 15:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760714040; cv=none; b=dcFsJ3VQuYqfC040Q/vufRmrwN6E4uHBJ5pBLhSy0PN/14lvHTr9l91rk++LOCDrLmplw1VSa8FLuZNEVaWyjuBMuU4MDN5E97S83toQx337hgthOcTJ2wkFJ7T6plzd+kRgPmOwXD4/04G4KklgirsKay8yoYLUNv7UoszZDDg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760714040; c=relaxed/simple; bh=NtfdWc/t5G5zsII2aKcMdpADG8OdsaTLE8P6kS9+qTc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TMA0qZGi+HW/oA7MPrJQu46BVvKLToHxElvILzsNHJ0cit2iaYfpdebz+EcH2KkaqCpualys/mt6RcC65jAHIvgPa7LCc2v3NCHrkW85QNJK9AN6Yo2l3bE3T3IExcjqkatSy42Df+ffs2kDOyPpjDO9hXgdeK6Htprwb2XXe1c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LgMd2Y0q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="LgMd2Y0q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B01AC4CEE7; Fri, 17 Oct 2025 15:13:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760714039; bh=NtfdWc/t5G5zsII2aKcMdpADG8OdsaTLE8P6kS9+qTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LgMd2Y0qfvOUeMdonAJCoaIurReSva0PRtWKeDO+1cwpG0Nqw3++qyatqzO+yHNbJ gCeXystcD4gZWY83tt+QHn4LMHwVefQFYqYx6Mh/E2wNHi/35+UT0H4GVG2qJzCJsi Dm5tVSfdu8YkJBVx1Dwo1hykKbE+3GC7aXbHbu5g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jia Wang , Charles Mirabile , Lucas Zampieri , Thomas Gleixner , Sasha Levin Subject: [PATCH 6.6 193/201] irqchip/sifive-plic: Avoid interrupt ID 0 handling during suspend/resume Date: Fri, 17 Oct 2025 16:54:14 +0200 Message-ID: <20251017145141.851091130@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251017145134.710337454@linuxfoundation.org> References: <20251017145134.710337454@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lucas Zampieri [ Upstream commit f75e07bf5226da640fa99a0594687c780d9bace4 ] According to the PLIC specification[1], global interrupt sources are assigned small unsigned integer identifiers beginning at the value 1. An interrupt ID of 0 is reserved to mean "no interrupt". The current plic_irq_resume() and plic_irq_suspend() functions incorrectly start the loop from index 0, which accesses the register space for the reserved interrupt ID 0. Change the loop to start from index 1, skipping the reserved interrupt ID 0 as per the PLIC specification. This prevents potential undefined behavior when accessing the reserved register space during suspend/resume cycles. Fixes: e80f0b6a2cf3 ("irqchip/irq-sifive-plic: Add syscore callbacks for hibernation") Co-developed-by: Jia Wang Signed-off-by: Jia Wang Co-developed-by: Charles Mirabile Signed-off-by: Charles Mirabile Signed-off-by: Lucas Zampieri Signed-off-by: Thomas Gleixner Link: https://github.com/riscv/riscv-plic-spec/releases/tag/1.0.0 Signed-off-by: Sasha Levin --- drivers/irqchip/irq-sifive-plic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 0fcd37108b67e..2d20cf9d84cea 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -248,7 +248,8 @@ static int plic_irq_suspend(void) priv = per_cpu_ptr(&plic_handlers, smp_processor_id())->priv; - for (i = 0; i < priv->nr_irqs; i++) { + /* irq ID 0 is reserved */ + for (i = 1; i < priv->nr_irqs; i++) { __assign_bit(i, priv->prio_save, readl(priv->regs + PRIORITY_BASE + i * PRIORITY_PER_ID)); } @@ -278,7 +279,8 @@ static void plic_irq_resume(void) priv = per_cpu_ptr(&plic_handlers, smp_processor_id())->priv; - for (i = 0; i < priv->nr_irqs; i++) { + /* irq ID 0 is reserved */ + for (i = 1; i < priv->nr_irqs; i++) { index = BIT_WORD(i); writel((priv->prio_save[index] & BIT_MASK(i)) ? 1 : 0, priv->regs + PRIORITY_BASE + i * PRIORITY_PER_ID); -- 2.51.0