Re: [PATCH v2] irqchip/gic-v3: Print a warning for out-of-range interrupt numbers

Marc Zyngier
2026-03-26T16:00:33Z

On Fri, 06 Mar 2026 12:13:32 +0000,
Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>
> gic_irq_domain_translate() does not check if an interrupt number lies
> within the valid range of the specified interrupt type. Add these
> checks, and print a warning if the interrupt number is out of range.
>
> This can help flagging incorrectly described Extended SPI and PPI
> interrupts in DT.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> This would have prevented the issue fixed by "[PATCH] arm64: dts:
> renesas: r8a78000: Fix out-of-range SPI interrupt numbers"[1].
>
> v2:
> - Fix off-by-one error in PPI range check.
>
> [1] https://lore.kernel.org/1f9dd274720ea1b66617a5dd84f76c3efc829dc8.1772641415.git.geert+renesas@glider.be/
> ---
> drivers/irqchip/irq-gic-v3.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
> index 20f13b686ab22faf..9e97505d4b767043 100644
> --- a/drivers/irqchip/irq-gic-v3.c
> +++ b/drivers/irqchip/irq-gic-v3.c
> @@ -1603,15 +1603,27 @@ static int gic_irq_domain_translate(struct irq_domain *d,
>
> switch (fwspec->param[0]) {
> case 0: /* SPI */
> + if (fwspec->param[1] > 987)
> + pr_warn_once("SPI %u out of range (use ESPI?)\n",
> + fwspec->param[1]);
> *hwirq = fwspec->param[1] + 32;
> break;
> case 1: /* PPI */
> + if (fwspec->param[1] > 15)
> + pr_warn_once("PPI %u out of range (use EPPI?)\n",
> + fwspec->param[1]);
> *hwirq = fwspec->param[1] + 16;
> break;
> case 2: /* ESPI */
> + if (fwspec->param[1] > 1023)
> + pr_warn_once("ESPI %u out of range\n",
> + fwspec->param[1]);
> *hwirq = fwspec->param[1] + ESPI_BASE_INTID;
> break;
> case 3: /* EPPI */
> + if (fwspec->param[1] > 63)
> + pr_warn_once("EPPI %u out of range\n",
> + fwspec->param[1]);
> *hwirq = fwspec->param[1] + EPPI_BASE_INTID;
> break;
> case GIC_IRQ_TYPE_LPI: /* LPI */

Acked-by: Marc Zyngier <maz@kernel.org>

M.

--
Without deviation from the norm, progress is not possible.