Skip to content

Commit 9d0ac18

Browse files
Lucas Zampierigregkh
authored andcommitted
irqchip/sifive-plic: Avoid interrupt ID 0 handling during suspend/resume
[ 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: e80f0b6 ("irqchip/irq-sifive-plic: Add syscore callbacks for hibernation") Co-developed-by: Jia Wang <[email protected]> Signed-off-by: Jia Wang <[email protected]> Co-developed-by: Charles Mirabile <[email protected]> Signed-off-by: Charles Mirabile <[email protected]> Signed-off-by: Lucas Zampieri <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://github.com/riscv/riscv-plic-spec/releases/tag/1.0.0 Signed-off-by: Sasha Levin <[email protected]>
1 parent 91f6615 commit 9d0ac18

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/irqchip/irq-sifive-plic.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ static int plic_irq_suspend(void)
252252

253253
priv = per_cpu_ptr(&plic_handlers, smp_processor_id())->priv;
254254

255-
for (i = 0; i < priv->nr_irqs; i++) {
255+
/* irq ID 0 is reserved */
256+
for (i = 1; i < priv->nr_irqs; i++) {
256257
__assign_bit(i, priv->prio_save,
257258
readl(priv->regs + PRIORITY_BASE + i * PRIORITY_PER_ID));
258259
}
@@ -283,7 +284,8 @@ static void plic_irq_resume(void)
283284

284285
priv = per_cpu_ptr(&plic_handlers, smp_processor_id())->priv;
285286

286-
for (i = 0; i < priv->nr_irqs; i++) {
287+
/* irq ID 0 is reserved */
288+
for (i = 1; i < priv->nr_irqs; i++) {
287289
index = BIT_WORD(i);
288290
writel((priv->prio_save[index] & BIT_MASK(i)) ? 1 : 0,
289291
priv->regs + PRIORITY_BASE + i * PRIORITY_PER_ID);

0 commit comments

Comments
 (0)