linux-stable/drivers/irqchip
He Ying 7be4db5c2b irqchip/gic-v3: Do not enable irqs when handling spurious interrups
commit a97709f563 upstream.

We triggered the following error while running our 4.19 kernel
with the pseudo-NMI patches backported to it:

[   14.816231] ------------[ cut here ]------------
[   14.816231] kernel BUG at irq.c:99!
[   14.816232] Internal error: Oops - BUG: 0 [#1] SMP
[   14.816232] Process swapper/0 (pid: 0, stack limit = 0x(____ptrval____))
[   14.816233] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G           O      4.19.95.aarch64 #14
[   14.816233] Hardware name: evb (DT)
[   14.816234] pstate: 80400085 (Nzcv daIf +PAN -UAO)
[   14.816234] pc : asm_nmi_enter+0x94/0x98
[   14.816235] lr : asm_nmi_enter+0x18/0x98
[   14.816235] sp : ffff000008003c50
[   14.816235] pmr_save: 00000070
[   14.816237] x29: ffff000008003c50 x28: ffff0000095f56c0
[   14.816238] x27: 0000000000000000 x26: ffff000008004000
[   14.816239] x25: 00000000015e0000 x24: ffff8008fb916000
[   14.816240] x23: 0000000020400005 x22: ffff0000080817cc
[   14.816241] x21: ffff000008003da0 x20: 0000000000000060
[   14.816242] x19: 00000000000003ff x18: ffffffffffffffff
[   14.816243] x17: 0000000000000008 x16: 003d090000000000
[   14.816244] x15: ffff0000095ea6c8 x14: ffff8008fff5ab40
[   14.816244] x13: ffff8008fff58b9d x12: 0000000000000000
[   14.816245] x11: ffff000008c8a200 x10: 000000008e31fca5
[   14.816246] x9 : ffff000008c8a208 x8 : 000000000000000f
[   14.816247] x7 : 0000000000000004 x6 : ffff8008fff58b9e
[   14.816248] x5 : 0000000000000000 x4 : 0000000080000000
[   14.816249] x3 : 0000000000000000 x2 : 0000000080000000
[   14.816250] x1 : 0000000000120000 x0 : ffff0000095f56c0
[   14.816251] Call trace:
[   14.816251]  asm_nmi_enter+0x94/0x98
[   14.816251]  el1_irq+0x8c/0x180                    (IRQ C)
[   14.816252]  gic_handle_irq+0xbc/0x2e4
[   14.816252]  el1_irq+0xcc/0x180                    (IRQ B)
[   14.816253]  arch_timer_handler_virt+0x38/0x58
[   14.816253]  handle_percpu_devid_irq+0x90/0x240
[   14.816253]  generic_handle_irq+0x34/0x50
[   14.816254]  __handle_domain_irq+0x68/0xc0
[   14.816254]  gic_handle_irq+0xf8/0x2e4
[   14.816255]  el1_irq+0xcc/0x180                    (IRQ A)
[   14.816255]  arch_cpu_idle+0x34/0x1c8
[   14.816255]  default_idle_call+0x24/0x44
[   14.816256]  do_idle+0x1d0/0x2c8
[   14.816256]  cpu_startup_entry+0x28/0x30
[   14.816256]  rest_init+0xb8/0xc8
[   14.816257]  start_kernel+0x4c8/0x4f4
[   14.816257] Code: 940587f1 d5384100 b9401001 36a7fd01 (d4210000)
[   14.816258] Modules linked in: start_dp(O) smeth(O)
[   15.103092] ---[ end trace 701753956cb14aa8 ]---
[   15.103093] Kernel panic - not syncing: Fatal exception in interrupt
[   15.103099] SMP: stopping secondary CPUs
[   15.103100] Kernel Offset: disabled
[   15.103100] CPU features: 0x36,a2400218
[   15.103100] Memory Limit: none

which is cause by a 'BUG_ON(in_nmi())' in nmi_enter().

From the call trace, we can find three interrupts (noted A, B, C above):
interrupt (A) is preempted by (B), which is further interrupted by (C).

Subsequent investigations show that (B) results in nmi_enter() being
called, but that it actually is a spurious interrupt. Furthermore,
interrupts are reenabled in the context of (B), and (C) fires with
NMI priority. We end-up with a nested NMI situation, something
we definitely do not want to (and cannot) handle.

The bug here is that spurious interrupts should never result in any
state change, and we should just return to the interrupted context.
Moving the handling of spurious interrupts as early as possible in
the GICv3 handler fixes this issue.

Fixes: 3f1f3234bc ("irqchip/gic-v3: Switch to PMR masking before calling IRQ handler")
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: He Ying <heying24@huawei.com>
[maz: rewrote commit message, corrected Fixes: tag]
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210423083516.170111-1-heying24@huawei.com
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-11 14:47:15 +02:00
..
alphascale_asm9260-icoll.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
exynos-combiner.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
irq-al-fic.c irqchip/al-fic: Add support for irq retrigger 2019-09-09 18:11:47 +01:00
irq-alpine-msi.c irqchip/alpine-msi: Fix freeing of interrupts on allocation error path 2020-12-30 11:53:50 +01:00
irq-armada-370-xp.c irqchip/armada-370-xp: Configure IPIs as standard interrupts 2020-09-17 16:37:27 +01:00
irq-aspeed-i2c-ic.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
irq-aspeed-scu-ic.c irqchip: Add Aspeed SCU interrupt controller 2020-01-20 19:10:04 +00:00
irq-aspeed-vic.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
irq-ath79-cpu.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
irq-ath79-misc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
irq-ativic32.c irqchip/ativic32: Constify irq_domain_ops 2020-07-27 08:55:02 +01:00
irq-atmel-aic-common.c irqchip/atmel-aic: Remove root argument from ->fixup() prototype 2017-07-04 11:10:37 +01:00
irq-atmel-aic-common.h irqchip/atmel-aic: Remove root argument from ->fixup() prototype 2017-07-04 11:10:37 +01:00
irq-atmel-aic.c irqchip/atmel-aic: Fix irq_retrigger callback return value 2020-03-16 15:48:54 +00:00
irq-atmel-aic5.c irqchip/atmel-aic5: Add support for sam9x60 rtt fixup 2020-06-27 11:55:45 +01:00
irq-bcm2835.c irqchip/bcm2835: Quiesce IRQs left enabled by bootloader 2020-03-16 15:48:54 +00:00
irq-bcm2836.c irqchip/bcm2836: Fix missing __init annotation 2020-10-25 11:10:29 +00:00
irq-bcm6345-l1.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
irq-bcm7038-l1.c irqchip/irq-bcm7038-l1: Guard uses of cpu_logical_map 2020-07-27 08:55:03 +01:00
irq-bcm7120-l2.c irqchip/bcm7120-l2: Set controller as wake-up source 2020-07-17 13:41:42 +01:00
irq-brcmstb-l2.c irqchip/brcmstb-l2: Match UPG_AUX_AON_INTR2 compatible 2020-07-17 13:41:42 +01:00
irq-clps711x.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
irq-crossbar.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
irq-csky-apb-intc.c irqchip/csky: fixup handle_irq_perbit break irq 2019-01-09 00:18:46 +08:00
irq-csky-mpintc.c Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-07-08 11:01:13 -07:00
irq-davinci-aintc.c irqchip: davinci-aintc: move the driver to drivers/irqchip 2019-02-19 20:02:17 +05:30
irq-davinci-cp-intc.c irqchip: davinci-cp-intc: move the driver to drivers/irqchip 2019-02-19 20:03:42 +05:30
irq-digicolor.c irqchip: Convert to using %pOF instead of full_name 2017-08-23 10:09:28 +01:00
irq-dw-apb-ictl.c irqchip/dw-apb-ictl: Add primary interrupt controller support 2020-09-25 16:49:14 +01:00
irq-eznps.c
irq-ftintc010.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
irq-gic-common.c irqchip/gic-common: Don't enable SGIs by default 2020-09-17 16:37:27 +01:00
irq-gic-common.h irqchip/gic: Prepare for more than 16 PPIs 2019-08-20 10:23:34 +01:00
irq-gic-pm.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
irq-gic-realview.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
irq-gic-v2m.c PCI: Remove unused includes and superfluous struct declaration 2019-11-21 07:49:29 -06:00
irq-gic-v3-its-fsl-mc-msi.c bus: fsl-mc: Add ACPI support for fsl-mc 2020-07-28 15:51:32 +01:00
irq-gic-v3-its-pci-msi.c PCI: Remove unused includes and superfluous struct declaration 2019-11-21 07:49:29 -06:00
irq-gic-v3-its-platform-msi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
irq-gic-v3-its.c irqchip fixes for Linux 5.10, take #2 2020-11-25 00:56:28 +01:00
irq-gic-v3-mbi.c irqchip/gic-v3-mbi: Don't map the MSI page in mbi_compose_m{b, s}i_msg() 2019-05-03 15:30:03 +01:00
irq-gic-v3.c irqchip/gic-v3: Do not enable irqs when handling spurious interrups 2021-05-11 14:47:15 +02:00
irq-gic-v4.c irqchip/gic-v4.1: Add VSGI property setup 2020-03-24 12:15:51 +00:00
irq-gic.c Merge remote-tracking branch 'origin/irq/gic-retrigger' into irq/irqchip-next 2020-09-17 16:50:02 +01:00
irq-goldfish-pic.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
irq-hip04.c irqchip/hip04: Configure IPIs as standard interrupts 2020-09-17 16:37:27 +01:00
irq-i8259.c irqchip: Replace setup_irq() by request_irq() 2020-03-08 14:25:46 +00:00
irq-imgpdc.c irqchip: Remove dev_err() usage after platform_get_irq() 2019-08-20 10:35:55 +01:00
irq-imx-gpcv2.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
irq-imx-intmux.c irqchip/imx-intmux: Use dev_err_probe() to simplify error handling 2020-09-13 17:38:52 +01:00
irq-imx-irqsteer.c irqchip/imx-irqsteer: Use dev_err_probe() to simplify error handling 2020-09-13 17:38:52 +01:00
irq-ingenic-tcu.c irqchip/ingenic: Add support for the JZ4760 2021-03-30 14:31:50 +02:00
irq-ingenic.c irqchip/ingenic: Add support for the JZ4760 2021-03-30 14:31:50 +02:00
irq-ixp4xx.c irqchip/ixp4xx: Register the base PA instead of its VA in fwnode 2019-08-07 14:24:41 +01:00
irq-jcore-aic.c
irq-keystone.c irqchip: Remove dev_err() usage after platform_get_irq() 2019-08-20 10:35:55 +01:00
irq-loongson-htpic.c irqchip/loongson-htpic: Remove redundant kfree operation 2020-07-17 13:41:42 +01:00
irq-loongson-htvec.c irqchip/loongson-htvec: Fix initial interrupt clearing 2020-09-13 15:30:11 +01:00
irq-loongson-liointc.c irqchip/loongson-liointc: Fix misuse of gc->mask_cache 2020-07-30 12:57:51 +01:00
irq-loongson-pch-msi.c irqchip/loongson-pch-msi: Use bitmap_zalloc() to allocate bitmap 2021-03-04 11:38:42 +01:00
irq-loongson-pch-pic.c irqchip/loongson-pch-pic: Fix the misused irq flow handler 2020-07-30 12:58:17 +01:00
irq-lpc32xx.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 159 2019-05-30 11:26:37 -07:00
irq-ls-extirq.c irqchip: Add support for Layerscape external interrupt lines 2019-11-10 18:47:49 +00:00
irq-ls-scfg-msi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
irq-ls1x.c irqchip/irq-ls1x: Missing error code in ls1x_intc_of_init() 2019-04-05 14:37:56 +02:00
irq-madera.c irqchip/madera: Drop GPIO includes 2019-01-17 17:04:24 +00:00
irq-mbigen.c irqchip/mbigen: Free msi_desc on device teardown 2020-04-17 08:59:27 +01:00
irq-meson-gpio.c irqchip/meson-gpio: Fix HARDIRQ-safe -> HARDIRQ-unsafe lock order 2020-04-17 08:59:29 +01:00
irq-mips-cpu.c irqchip/mips-cpu: Set IPI domain parent chip 2021-01-27 11:55:13 +01:00
irq-mips-gic.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
irq-mmp.c irqchip/mmp: Coexist with GIC root IRQ controller 2019-08-30 15:23:30 +01:00
irq-mscc-ocelot.c irqchhip: Convert to using %pOFn instead of device_node.name 2018-12-13 09:35:56 +00:00
irq-mst-intc.c irqchip/mst: Make mst_intc_of_init static 2020-10-15 22:32:31 +01:00
irq-mtk-cirq.c irqchip: Revert modular support for drivers using IRQCHIP_PLATFORM_DRIVER helperse 2020-08-25 10:48:54 +01:00
irq-mtk-sysirq.c irqchip: Revert modular support for drivers using IRQCHIP_PLATFORM_DRIVER helperse 2020-08-25 10:48:54 +01:00
irq-mvebu-gicp.c treewide: devm_kzalloc() -> devm_kcalloc() 2018-06-12 16:19:22 -07:00
irq-mvebu-icu.c irqchip/irq-mvebu-icu: Make legacy_bindings static 2020-04-17 08:59:29 +01:00
irq-mvebu-odmi.c
irq-mvebu-pic.c
irq-mvebu-sei.c irqchip/irq-mvebu-sei: Make mvebu_sei_ap806_caps static 2019-03-21 16:43:00 +01:00
irq-mxs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 1 2019-05-21 11:28:39 +02:00
irq-nvic.c irqchip/nvic: Use irq_domain_translate_onecell instead of custom func 2020-01-20 09:24:47 +00:00
irq-omap-intc.c irqchip/irq-omap-intc: Do not statically initialize variables 2017-10-16 21:05:14 +02:00
irq-ompic.c irqchip/ompic: fix return value check in ompic_of_init() 2018-01-04 11:13:22 +00:00
irq-or1k-pic.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
irq-orion.c irqchip: Convert to using %pOFn instead of device_node.name 2018-11-27 10:54:17 -06:00
irq-owl-sirq.c irqchip: Add Actions Semi Owl SIRQ controller 2020-09-25 16:57:33 +01:00
irq-partition-percpu.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
irq-pic32-evic.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
irq-pruss-intc.c irqchip/irq-pruss-intc: Add support for ICSSG INTC on K3 SoCs 2020-09-17 12:20:32 +01:00
irq-rda-intc.c irqchip/irq-rda-intc: Fix return value check in rda8810_intc_init() 2018-12-18 12:55:23 +00:00
irq-renesas-h8s.c genirq: Fix various typos in comments 2018-12-18 14:22:28 +01:00
irq-renesas-h8300h.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
irq-renesas-intc-irqpin.c irqchip/renesas-intc-irqpin: Merge irlm_bit and needs_irlm 2020-11-01 11:59:22 +00:00
irq-renesas-irqc.c irqchip/renesas-irqc: Use proper irq_chip name and parent 2019-06-11 12:22:42 +01:00
irq-renesas-rza1.c irqchip/renesas-rza1: Fix an use-after-free in rza1_irqc_probe() 2019-07-26 14:40:01 +01:00
irq-riscv-intc.c irqchip/riscv-intc: Fix a typo in a pr_warn() 2020-06-21 15:15:41 +01:00
irq-sa11x0.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
irq-sifive-plic.c irqchip/sifive-plic: Fix chip_data access within a hierarchy 2020-11-01 11:52:27 +00:00
irq-sirfsoc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 4 2019-05-21 11:28:40 +02:00
irq-sl28cpld.c irqchip: Add sl28cpld interrupt controller support 2020-09-17 15:58:37 +01:00
irq-sni-exiu.c irqchip/exiu: Fix the index of fwspec for IRQ type 2020-11-22 10:27:23 +00:00
irq-st.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
irq-stm32-exti.c irqchip/stm32-exti: Add all LP timer exti direct events support 2020-10-25 12:04:13 +00:00
irq-sun4i.c irqchip/sun4i: Add support for Allwinner ARMv5 F1C100s 2018-12-13 09:35:58 +00:00
irq-sunxi-nmi.c
irq-tango.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
irq-tb10x.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
irq-tegra.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
irq-ti-sci-inta.c irqchip/ti-sci-inta: Fix printing of inta id on probe success 2020-12-30 11:53:50 +01:00
irq-ti-sci-intr.c irqchip/ti-sci-intr: Fix freeing of irqs 2020-12-30 11:53:50 +01:00
irq-ts4800.c
irq-uniphier-aidet.c irqchip/uniphier-aidet: Use devm_platform_ioremap_resource() 2019-09-05 09:28:13 +01:00
irq-versatile-fpga.c irqchip/versatile-fpga: Apply clear-mask earlier 2020-03-22 11:52:16 +00:00
irq-vf610-mscm-ir.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
irq-vic.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
irq-vt8500.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
irq-xilinx-intc.c Revert "irqchip/xilinx: Enable generic irq multi handler" 2020-04-01 09:12:24 +01:00
irq-xtensa-mx.c drivers/irqchip: xtensa-mx: fix mask and unmask 2019-01-26 02:02:15 -08:00
irq-xtensa-pic.c drivers/irqchip: xtensa: add warning to irq_retrigger 2019-01-26 02:02:14 -08:00
irq-zevio.c irqchip: Remove redundant semicolon after while 2019-11-10 18:47:44 +00:00
irqchip.c treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
Kconfig irqchip/imx: IMX_INTMUX should not default to y, unconditionally 2021-03-04 11:37:51 +01:00
Makefile ARM: SoC platform updates 2020-10-24 10:33:08 -07:00
qcom-irq-combiner.c irqchip/qcom-irq-combiner: Replace zero-length array with flexible-array member 2020-03-22 11:52:52 +00:00
qcom-pdc.c irqchip/qcom-pdc: Fix phantom irq when changing between rising/falling 2020-12-30 11:53:51 +01:00
spear-shirq.c