summaryrefslogtreecommitdiff
path: root/kernel/cfi.c
diff options
context:
space:
mode:
authorWaiman Long <longman@redhat.com>2025-02-06 14:18:44 -0500
committerIngo Molnar <mingo@kernel.org>2025-02-25 14:38:43 +0100
commitfe37c699ae3eed6e02ee55fbf5cb9ceb7fcfd76c (patch)
tree23b198e966cf50a86996e5ab418dfbae8f7e9d3e /kernel/cfi.c
parent684b12916a107157633311f07bb74307221eff92 (diff)
downloadlinux-fe37c699ae3eed6e02ee55fbf5cb9ceb7fcfd76c.tar.gz
linux-fe37c699ae3eed6e02ee55fbf5cb9ceb7fcfd76c.tar.bz2
linux-fe37c699ae3eed6e02ee55fbf5cb9ceb7fcfd76c.zip
x86/nmi: Add an emergency handler in nmi_desc & use it in nmi_shootdown_cpus()
Depending on the type of panics, it was found that the __register_nmi_handler() function can be called in NMI context from nmi_shootdown_cpus() leading to a lockdep splat: WARNING: inconsistent lock state inconsistent {INITIAL USE} -> {IN-NMI} usage. lock(&nmi_desc[0].lock); <Interrupt> lock(&nmi_desc[0].lock); Call Trace: _raw_spin_lock_irqsave __register_nmi_handler nmi_shootdown_cpus kdump_nmi_shootdown_cpus native_machine_crash_shutdown __crash_kexec In this particular case, the following panic message was printed before: Kernel panic - not syncing: Fatal hardware error! This message seemed to be given out from __ghes_panic() running in NMI context. The __register_nmi_handler() function which takes the nmi_desc lock with irq disabled shouldn't be called from NMI context as this can lead to deadlock. The nmi_shootdown_cpus() function can only be invoked once. After the first invocation, all other CPUs should be stuck in the newly added crash_nmi_callback() and cannot respond to a second NMI. Fix it by adding a new emergency NMI handler to the nmi_desc structure and provide a new set_emergency_nmi_handler() helper to set crash_nmi_callback() in any context. The new emergency handler will preempt other handlers in the linked list. That will eliminate the need to take any lock and serve the panic in NMI use case. Signed-off-by: Waiman Long <longman@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Rik van Riel <riel@surriel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20250206191844.131700-1-longman@redhat.com
Diffstat (limited to 'kernel/cfi.c')
0 files changed, 0 insertions, 0 deletions