panic, x86/vmware: Preserve crash logs before kdump
Subsystems (7)
v2 cover panic, x86/vmware: Preserve crash logs before kdump
A VMware guest may have no persistent storage or working userspace after a crash. Preserve its newest kernel log tail in the host's vmware.log before entering kdump, without enabling every panic notifier by default.
Following Petr's suggestion, add one generic panic_pre_kdump_list with VMware as its first client. A set-once helper covers panic() and direct crash-kexec entry. Fatal oopses can reach kdump without calling panic(), so patch 2 adds that call after capturing the original registers under the existing kexec lock. The late panic call follows sys_info() and precedes the kmsg dumpers.
Patch 3 adds Guilherme's suggested escape hatch for debugging kdump failures involving early callbacks. With panic_pre_kdump_postpone set, the list runs before kdump only when crash_kexec_post_notifiers is also set. This can omit hypervisor crash handling as well as diagnostics. The late panic call remains eligible. This policy is a separate patch; I can omit patch 3 if it is not wanted.
The logger preallocates an 8 KiB buffer and bounds its register-based RPC transfer and retries. Michael suggested increasing the buffer because 4 KiB can omit useful stack-trace context. Ordinary guests enable logging by default; encrypted guests must opt in. Use bool/proc_dobool for the sysctl as Joel requested. The potentially terminating REPORTGUESTCRASH event remains a separate late dumper, suppressed whenever a crash image is loaded. The v1 assignment to crash_kexec_post_notifiers is dropped.
Tested on VMware Workstation and ESXi with ordinary guests, and on ESXi with SEV-SNP and TDX guests.
v1:
https://lore.kernel.org/r/[email protected]
Zack Rusin (6):
panic: Add a notifier chain for pre-kdump callbacks
crash: Notify pre-kdump callbacks before switching kernels
panic: Allow postponing pre-kdump notifiers x86/vmware: Add a bounded pre-kdump log sender x86/vmware: Add the vmware_record_panic_msg sysctl x86/vmware: Report guest crashes after kmsg dumpers
.../admin-guide/kernel-parameters.txt | 14 + Documentation/admin-guide/sysctl/kernel.rst | 20 ++ arch/x86/include/asm/vmware.h | 2 + arch/x86/kernel/cpu/vmware.c | 250 ++++++++++++++++++ include/linux/panic_notifier.h | 4 + kernel/crash_core.c | 3 + kernel/panic.c | 28 ++ 7 files changed, 321 insertions(+)
base-commit: fd73f4a6659897191fa0d40695fe370925dd3780
PATCH v2 1/6 panic: Add a notifier chain for pre-kdump callbacks
Selected crash callbacks should not require running every panic notifier before kdump. Add a separate atomic chain with an at-most-once dispatch helper, and invoke it before panic reaches the kmsg dumpers.
The helper permits another call from the crash path without repeating callbacks or recursing into them. Document that callbacks may run in NMI context, with other CPUs running and the kexec lock held.
---
New in v2: separate pre-kdump chain, with a set-once dispatch guard.
include/linux/panic_notifier.h | 3 +++ kernel/panic.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
include/linux/panic_notifier.h +3 -0
@@ -6,6 +6,9 @@#include <linux/types.h> extern struct atomic_notifier_head panic_notifier_list; +extern struct atomic_notifier_head panic_pre_kdump_list; + +void panic_notify_pre_kdump (char *msg);extern bool crash_kexec_post_notifiers;
kernel/panic.c +26 -0
@@ -82,6 +82,10 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);EXPORT_SYMBOL (panic_notifier_list); +struct atomic_notifier_head panic_pre_kdump_list = +ATOMIC_NOTIFIER_INIT (panic_pre_kdump_list); +EXPORT_SYMBOL_GPL (panic_pre_kdump_list); +static void panic_print_deprecated (void ) {pr_info_once ("Kernel: The 'panic_print' parameter is now deprecated. Please use 'panic_sys_info' and 'panic_console_replay' instead.\n" );
@@ -567,6 +571,27 @@ static void panic_other_cpus_shutdown(bool crash_kexec)crash_smp_send_stop (); } +/** +* panic_notify_pre_kdump - invoke selected callbacks before kdump +* @msg: Panic message, or NULL for direct crash-kexec entry +* +* Dispatch at most once per boot, including recursive entry. Callbacks run +* with interrupts disabled, possibly in NMI context, before other CPUs have +* necessarily stopped. The kexec lock may be held. They must not sleep, +* allocate, wait for other CPUs, or call into kexec management operations. +* The message is read-only and may only be used during the callback. +*/ +void panic_notify_pre_kdump (char *msg) +{ +static atomic_t started =ATOMIC_INIT (0 ); +unsigned long flags; + +local_irq_save (flags); +if (!atomic_xchg (&started,1 )) +atomic_notifier_call_chain (&panic_pre_kdump_list,0 , msg); +local_irq_restore (flags); +} +/** * vpanic - halt the system * @fmt: The text string to print
@@ -682,6 +707,7 @@ void vpanic(const char *fmt, va_list args)sys_info (panic_print); +panic_notify_pre_kdump (buf);kmsg_dump_desc (KMSG_DUMP_PANIC , buf);/*
[email protected]
AI reviewRe: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
Selected crash callbacks should not require running every panic notifier before kdump. Add a separate atomic chain with an at-most-once dispatch helper, and invoke it before panic reaches the kmsg dumpers.
The helper permits another call from the crash path without repeating callbacks or recursing into them. Document that callbacks may run in NMI context, with other CPUs running and the kexec lock held.
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
In reply to Zack RusinQuoted 75 lines · Zack Rusin
Selected crash callbacks should not require running every panic notifier before kdump. Add a separate atomic chain with an at-most-once dispatch helper, and invoke it before panic reaches the kmsg dumpers.
The helper permits another call from the crash path without repeating callbacks or recursing into them. Document that callbacks may run in NMI context, with other CPUs running and the kexec lock held.
Signed-off-by Zack Rusin <[email protected]>---
New in v2: separate pre-kdump chain, with a set-once dispatch guard.include/linux/panic_notifier.h | 3 +++ kernel/panic.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)include/linux/panic_notifier.h +3
-0@@ -6,6 +6,9 @@#include <linux/types.h> extern struct atomic_notifier_head panic_notifier_list; +extern struct atomic_notifier_head panic_pre_kdump_list; + +void panic_notify_pre_kdump (char *msg);extern bool crash_kexec_post_notifiers;kernel/panic.c +25
-0@@ -82,6 +82,10 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);EXPORT_SYMBOL (panic_notifier_list); +struct atomic_notifier_head panic_pre_kdump_list = +ATOMIC_NOTIFIER_INIT (panic_pre_kdump_list); +EXPORT_SYMBOL_GPL (panic_pre_kdump_list); +static void panic_print_deprecated (void ) {pr_info_once ("Kernel: The 'panic_print' parameter is now deprecated. Please use 'panic_sys_info' and 'panic_console_replay' instead.\n" );@@ -567,6 +571,27 @@ static void panic_other_cpus_shutdown(bool crash_kexec)crash_smp_send_stop (); } +/** +* panic_notify_pre_kdump - invoke selected callbacks before kdump +* @msg: Panic message, or NULL for direct crash-kexec entry +* +* Dispatch at most once per boot, including recursive entry. Callbacks run +* with interrupts disabled, possibly in NMI context, before other CPUs have +* necessarily stopped. The kexec lock may be held. They must not sleep, +* allocate, wait for other CPUs, or call into kexec management operations. +* The message is read-only and may only be used during the callback. +*/ +void panic_notify_pre_kdump (char *msg) +{ +static atomic_t started =ATOMIC_INIT (0 ); +unsigned long flags; + +local_irq_save (flags); +if (!atomic_xchg (&started,1 )) +atomic_notifier_call_chain (&panic_pre_kdump_list,0 , msg); +local_irq_restore (flags); +} +/** * vpanic - halt the system * @fmt: The text string to print
kernel/panic.c void vpanic(const char *fmt, va_list args) · line 713
Quoted 7 lines
kernel/panic.c +1
-0@@ -682,6 +707,7 @@ void vpanic(const char *fmt, va_list args)sys_info (panic_print); +panic_notify_pre_kdump (buf);kmsg_dump_desc (KMSG_DUMP_PANIC , buf);/*
Hi Zack, thanks for trying to improve this conundrum called panic notifiers heh
I confess at first sight I got a bit confused, and only after reading patch 1 and 2 twice, things made sense to me: you're hooking __crash_kexec() directly!
So, in my head, 2 things that would make sense upfront: merge patches #1 and #2, and comment a bit about it in the code.
But more than this, IIUC (and please correct me if I'm wrong): in case __crash_kexec() is called earlier, THAT call invokes panic_notify_pre_kdump(). Now, if that call doesn't happen (for example, 'cause crash_kexec_post_notifiers=Y), then panic_notify_pre_kdump() is called from vpanic(), *after* the regular panic notifiers!!? Is it intentional?
If it is, why even call it here, if __crash_exec() will be called again, in next line, in such case of crash_kexec_post_notifiers=Y? It could be easily done outside of if(kexec_crash_image) [at __crash_kexec()].
Is it really correct/expected that such "early" notifiers will end-up being the latest notifiers if crash_kexec_post_notifiers=Y? Maybe this is aimed at collecting also the potential extra info dumped in some regular panic notifier?
Thanks,
Guilherme
Re: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
Quoted 60 lines · Guilherme G. Piccoli
Quoted 59 lines · Zack Rusin
Selected crash callbacks should not require running every panic notifier before kdump. Add a separate atomic chain with an at-most-once dispatch helper, and invoke it before panic reaches the kmsg dumpers.
The helper permits another call from the crash path without repeating callbacks or recursing into them. Document that callbacks may run in NMI context, with other CPUs running and the kexec lock held.
Signed-off-by Zack Rusin <[email protected]>---
New in v2: separate pre-kdump chain, with a set-once dispatch guard.include/linux/panic_notifier.h | 3 +++ kernel/panic.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)include/linux/panic_notifier.h +3
-0@@ -6,6 +6,9 @@#include <linux/types.h> extern struct atomic_notifier_head panic_notifier_list; +extern struct atomic_notifier_head panic_pre_kdump_list; + +void panic_notify_pre_kdump (char *msg);extern bool crash_kexec_post_notifiers;kernel/panic.c +13
-0@@ -82,6 +82,10 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);EXPORT_SYMBOL (panic_notifier_list); +struct atomic_notifier_head panic_pre_kdump_list = +ATOMIC_NOTIFIER_INIT (panic_pre_kdump_list); +EXPORT_SYMBOL_GPL (panic_pre_kdump_list); +static void panic_print_deprecated (void ) {pr_info_once ("Kernel: The 'panic_print' parameter is now deprecated. Please use 'panic_sys_info' and 'panic_console_replay' instead.\n" );@@ -567,6 +571,27 @@ static void panic_other_cpus_shutdown(bool crash_kexec)crash_smp_send_stop (); } +/** +* panic_notify_pre_kdump - invoke selected callbacks before kdump +* @msg: Panic message, or NULL for direct crash-kexec entry +* +* Dispatch at most once per boot, including recursive entry. Callbacks run +* with interrupts disabled, possibly in NMI context, before other CPUs have +* necessarily stopped. The kexec lock may be held. They must not sleep, +* allocate, wait for other CPUs, or call into kexec management operations. +* The message is read-only and may only be used during the callback.
Quoted 8 lines
kernel/panic.c static void panic_other_cpus_shutdown(bool crash_kexec) · line 590
Quoted 8 lines
kernel/panic.c +8
-0+*/ +void panic_notify_pre_kdump (char *msg) +{ +static atomic_t started =ATOMIC_INIT (0 ); +unsigned long flags; + +local_irq_save (flags); +if (!atomic_xchg (&started,1 ))
It is far from clear why this is needed. It would deserve a comment in the code and explanation in the commit message.
Well, I am not even sure whether this synchronization is enough. If __crash_exec() and vpanic() are running in parallel on two CPUS then one path will skip the notifiers but it will not wait until they are finished.
But I think that the problem is the explicitly called __crash_exec() is not synchronized against vpanic() in the first place. IMHO, it is an existing problem which probably should get fixed.
Quoted 19 lines
Quoted 8 lines
kernel/panic.c +4
-0+atomic_notifier_call_chain (&panic_pre_kdump_list,0 , msg); +local_irq_restore (flags); +} +/** * vpanic - halt the system * @fmt: The text string to print kernel/panic.c void vpanic(const char *fmt, va_list args) · line 713
Quoted 7 lines
kernel/panic.c +1
-0@@ -682,6 +707,7 @@ void vpanic(const char *fmt, va_list args)sys_info (panic_print); +panic_notify_pre_kdump (buf);kmsg_dump_desc (KMSG_DUMP_PANIC , buf);/* Hi Zack, thanks for trying to improve this conundrum called panic notifiers heh
Quoted 6 lines
I confess at first sight I got a bit confused, and only after reading patch 1 and 2 twice, things made sense to me: you're hooking
__crash_kexec()directly!So, in my head, 2 things that would make sense upfront: merge patches #1 and #2, and comment a bit about it in the code.
+1
But honestly, the semantic and ordering of all the variables and functions is very complicated. It is very hard to follow and understand all the rules.
I am going to think about it. But I'll first comment the 2nd and 3rd patch.
Best Regards,
Petr
Re: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
Quoted 73 lines · Petr Mladek
Quoted 60 lines · Guilherme G. Piccoli
Quoted 59 lines · Zack Rusin
Selected crash callbacks should not require running every panic notifier before kdump. Add a separate atomic chain with an at-most-once dispatch helper, and invoke it before panic reaches the kmsg dumpers.
The helper permits another call from the crash path without repeating callbacks or recursing into them. Document that callbacks may run in NMI context, with other CPUs running and the kexec lock held.
Signed-off-by Zack Rusin <[email protected]>---
New in v2: separate pre-kdump chain, with a set-once dispatch guard.include/linux/panic_notifier.h | 3 +++ kernel/panic.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)include/linux/panic_notifier.h +3
-0@@ -6,6 +6,9 @@#include <linux/types.h> extern struct atomic_notifier_head panic_notifier_list; +extern struct atomic_notifier_head panic_pre_kdump_list; + +void panic_notify_pre_kdump (char *msg);extern bool crash_kexec_post_notifiers;kernel/panic.c +13
-0@@ -82,6 +82,10 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);EXPORT_SYMBOL (panic_notifier_list); +struct atomic_notifier_head panic_pre_kdump_list = +ATOMIC_NOTIFIER_INIT (panic_pre_kdump_list); +EXPORT_SYMBOL_GPL (panic_pre_kdump_list); +static void panic_print_deprecated (void ) {pr_info_once ("Kernel: The 'panic_print' parameter is now deprecated. Please use 'panic_sys_info' and 'panic_console_replay' instead.\n" );@@ -567,6 +571,27 @@ static void panic_other_cpus_shutdown(bool crash_kexec)crash_smp_send_stop (); } +/** +* panic_notify_pre_kdump - invoke selected callbacks before kdump +* @msg: Panic message, or NULL for direct crash-kexec entry +* +* Dispatch at most once per boot, including recursive entry. Callbacks run +* with interrupts disabled, possibly in NMI context, before other CPUs have +* necessarily stopped. The kexec lock may be held. They must not sleep, +* allocate, wait for other CPUs, or call into kexec management operations. +* The message is read-only and may only be used during the callback. Quoted 8 lines
kernel/panic.c static void panic_other_cpus_shutdown(bool crash_kexec) · line 590
Quoted 8 lines
kernel/panic.c +8
-0+*/ +void panic_notify_pre_kdump (char *msg) +{ +static atomic_t started =ATOMIC_INIT (0 ); +unsigned long flags; + +local_irq_save (flags); +if (!atomic_xchg (&started,1 ))It is far from clear why this is needed. It would deserve a comment in the code and explanation in the commit message.
Quoted 8 lines
Well, I am not even sure whether this synchronization is enough. If
__crash_exec()andvpanic()are running in parallel on two CPUS then one path will skip the notifiers but it will not wait until they are finished.But I think that the problem is the explicitly called
__crash_exec()is not synchronized againstvpanic()in the first place. IMHO, it is an existing problem which probably should get fixed.
It seems that __crash_exec() should be called only when panic_cpu is set. This is why crash_exec() does:
__bpf_kfunc void crash_kexec(struct pt_regs *regs)
{
if (panic_try_start()) {
/* This is the 1st CPU which comes here, so go ahead. */
__crash_kexec(regs);The only exception seems to be (found by gemini) in Hyper-V code:
static void __noreturn hv_crash_handle(void)
{
hv_crash_restore_tss();
hv_crash_clear_kernpt();
/* we are now fully in devirtualized normal kernel mode */
__crash_kexec(NULL);
hv_panic_timeout_reboot();
}I belive that it is a bug and it should do:
/* Only one CPU is allowed to process with kdump and panic. */ if (!panic_try_start()) return;
But it is possible that it is serialized another way. Anyway, even Hyper-V must make sure that __crash_kexec() is called only on one CPU.
Result: We should not need any extra synchronization for
the panic_notify_pre_kdump().
We might just need to prevent calling them twice if we decide to call this function in __crash_exec() as well. A simple bool variable should be enough. But I am still not sure if it is a good design.
Continue thinking...
Best Regards,
Petr
Re: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
In reply to Petr MladekQuoted 105 lines · Petr Mladek
Quoted 60 lines · Guilherme G. Piccoli
Quoted 59 lines · Zack Rusin
Selected crash callbacks should not require running every panic notifier before kdump. Add a separate atomic chain with an at-most-once dispatch helper, and invoke it before panic reaches the kmsg dumpers.
The helper permits another call from the crash path without repeating callbacks or recursing into them. Document that callbacks may run in NMI context, with other CPUs running and the kexec lock held.
Signed-off-by Zack Rusin <[email protected]>---
New in v2: separate pre-kdump chain, with a set-once dispatch guard.include/linux/panic_notifier.h | 3 +++ kernel/panic.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)include/linux/panic_notifier.h +3
-0@@ -6,6 +6,9 @@#include <linux/types.h> extern struct atomic_notifier_head panic_notifier_list; +extern struct atomic_notifier_head panic_pre_kdump_list; + +void panic_notify_pre_kdump (char *msg);extern bool crash_kexec_post_notifiers;kernel/panic.c +13
-0@@ -82,6 +82,10 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);EXPORT_SYMBOL (panic_notifier_list); +struct atomic_notifier_head panic_pre_kdump_list = +ATOMIC_NOTIFIER_INIT (panic_pre_kdump_list); +EXPORT_SYMBOL_GPL (panic_pre_kdump_list); +static void panic_print_deprecated (void ) {pr_info_once ("Kernel: The 'panic_print' parameter is now deprecated. Please use 'panic_sys_info' and 'panic_console_replay' instead.\n" );@@ -567,6 +571,27 @@ static void panic_other_cpus_shutdown(bool crash_kexec)crash_smp_send_stop (); } +/** +* panic_notify_pre_kdump - invoke selected callbacks before kdump +* @msg: Panic message, or NULL for direct crash-kexec entry +* +* Dispatch at most once per boot, including recursive entry. Callbacks run +* with interrupts disabled, possibly in NMI context, before other CPUs have +* necessarily stopped. The kexec lock may be held. They must not sleep, +* allocate, wait for other CPUs, or call into kexec management operations. +* The message is read-only and may only be used during the callback. Quoted 8 lines
kernel/panic.c static void panic_other_cpus_shutdown(bool crash_kexec) · line 590
Quoted 8 lines
kernel/panic.c +8
-0+*/ +void panic_notify_pre_kdump (char *msg) +{ +static atomic_t started =ATOMIC_INIT (0 ); +unsigned long flags; + +local_irq_save (flags); +if (!atomic_xchg (&started,1 ))It is far from clear why this is needed. It would deserve a comment in the code and explanation in the commit message.
Well, I am not even sure whether this synchronization is enough. If
__crash_exec()andvpanic()are running in parallel on two CPUS then one path will skip the notifiers but it will not wait until they are finished.But I think that the problem is the explicitly called
__crash_exec()is not synchronized againstvpanic()in the first place. IMHO, it is an existing problem which probably should get fixed.Quoted 23 lines
Quoted 8 lines
kernel/panic.c +4
-0+atomic_notifier_call_chain (&panic_pre_kdump_list,0 , msg); +local_irq_restore (flags); +} +/** * vpanic - halt the system * @fmt: The text string to print kernel/panic.c void vpanic(const char *fmt, va_list args) · line 713
Quoted 7 lines
kernel/panic.c +1
-0@@ -682,6 +707,7 @@ void vpanic(const char *fmt, va_list args)sys_info (panic_print); +panic_notify_pre_kdump (buf);kmsg_dump_desc (KMSG_DUMP_PANIC , buf);/* Hi Zack, thanks for trying to improve this conundrum called panic notifiers heh
I confess at first sight I got a bit confused, and only after reading patch 1 and 2 twice, things made sense to me: you're hooking
__crash_kexec()directly!
Quoted 8 lines
Quoted 2 lines
So, in my head, 2 things that would make sense upfront: merge patches #1 and #2, and comment a bit about it in the code.
+1
But honestly, the semantic and ordering of all the variables and functions is very complicated. It is very hard to follow and understand all the rules.
Warning: You might skip the first part about my confusion.
Maybe, I am the only one who is a bit lost this way.
My motivation is to do not repeat the mess which I saw in the printk registration code. People added many features there for over two decades. Each change made sense on its own. But, for me, it was really hard to understand and distinguish what were the wanted and unwanted effects.
I trying to understans why I am confused by the panic notifiers code. There are several aspects:
1. I was involved in many mail threads where we discussed calling:
notifiers before/after kdump
but the variable "crash_kexec_post_notifiers" defines calling:
kdump before/after notifiers
It actually matches the code because __crash_kexec() is called twice in vpanic() before and after the notifiers.
Sigh, it looks like a trivial mental switch. But it is not that trivial when we though about splitting the notifiers into more lists and discussed where to call them.
The discussion always was where to call notifiers and not where to call kdump.
And we are also discussing about disabling notifiers. Not about disabling kdump.
2. We call the new list "panic_pre_kdump" and this patchset calls it in both vpanic() and __crash_kexec() code paths.
The name "pre_kdump" suggests that it is needed only when kdump is called. But we want to call it in panic() even when kdump is not called.
3. The new "pre_kdump" notifiers are called before stopping CPUs. While the rest is called in the more safe environment with stopped CPUs.
4. I am a bit confused by this patch set because it allows dumping printk log before kdump. It does not fit with my understanding of having "pre_kdump" list only for the strictly needed operations.
5. There is the idea of splitting the remainig notifiers into _safe and _unsafe lists, see
https://lore.kernel.org/r/[email protected]
It would complicate the design even more. But it might help with the endless war whether "crash_kexec_post_notifiers" should be "true" or "false" by a platform-specific default.
I wonder how all this fits together.
Top-level look:
===============
Sigh, one problem is that the notifiers have different purpose:
1. Notify hypervisor (platform). This looks like a must-to-have.
2. Platform specific dump of printk messages. This is nice-to-have. But note that we also have kmsg_dump API for this, see kmsg_dump_desc().
3. Print extra info. Also this is nice-to-have.
Some is optional when kdump is created because it might be read from there. Some can't be found in crash dump, e.g. dumping lowlevel HW state.
In addition, there is sys_info() info API which allows to dump state of various subsystems.
4. Some notifiers are smp-safe and some just a best effort and more safe after disabling other CPUs.
In addition, I guess that it is better to call crash_kexec() without stopping other CPUs because stopping is not reliable without NMI. And it would create extra noise in the backtrace. And ???
Now, different people have different preferences but mainly:
+ the more safe kdump the better
+ the more safe reboot the better
+ the more info the better
Now, the question is how to satisfy the various requirements and keep the design sane. We need a compromise but where.
Continue thinking...
Best Regards,
Petr
Re: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
Quoted 124 lines · Petr Mladek
Quoted 28 lines · Petr Mladek
Quoted 27 lines · Guilherme G. Piccoli
Quoted 11 lines · Zack Rusin
Selected crash callbacks should not require running every panic notifier before kdump. Add a separate atomic chain with an at-most-once dispatch helper, and invoke it before panic reaches the kmsg dumpers.
The helper permits another call from the crash path without repeating callbacks or recursing into them. Document that callbacks may run in NMI context, with other CPUs running and the kexec lock held.
kernel/panic.c void vpanic(const char *fmt, va_list args) · line 713
Quoted 7 lines
kernel/panic.c +1
-0@@ -682,6 +707,7 @@ void vpanic(const char *fmt, va_list args)sys_info (panic_print); +panic_notify_pre_kdump (buf);kmsg_dump_desc (KMSG_DUMP_PANIC , buf);/* Hi Zack, thanks for trying to improve this conundrum called panic notifiers heh
I confess at first sight I got a bit confused, and only after reading patch 1 and 2 twice, things made sense to me: you're hooking
__crash_kexec()directly!Quoted 8 lines
Quoted 2 lines
So, in my head, 2 things that would make sense upfront: merge patches #1 and #2, and comment a bit about it in the code.
+1
But honestly, the semantic and ordering of all the variables and functions is very complicated. It is very hard to follow and understand all the rules.
I trying to understans why I am confused by the panic notifiers code. There are several aspects:
1. I was involved in many mail threads where we discussed calling:
notifiers before/after kdump
but the variable "
crash_kexec_post_notifiers" defines calling:kdump before/after notifiers
It actually matches the code because
__crash_kexec()is called twice invpanic()before and after the notifiers.Sigh, it looks like a trivial mental switch. But it is not that trivial when we though about splitting the notifiers into more lists and discussed where to call them.
The discussion always was where to call notifiers and not where to call kdump.
And we are also discussing about disabling notifiers. Not about disabling kdump.
2. We call the new list "
panic_pre_kdump" and this patchset calls it in bothvpanic()and__crash_kexec()code paths.The name "
pre_kdump" suggests that it is needed only when kdump is called. But we want to call it inpanic()even when kdump is not called.3. The new "
pre_kdump" notifiers are called before stopping CPUs. While the rest is called in the more safe environment with stopped CPUs.4. I am a bit confused by this patch set because it allows dumping printk log before kdump. It does not fit with my understanding of having "
pre_kdump" list only for the strictly needed operations.5. There is the idea of splitting the remainig notifiers into
_safeand_unsafelists, see
https://lore.kernel.org/r/[email protected]It would complicate the design even more. But it might help with the endless war whether "
crash_kexec_post_notifiers" should be "true" or "false" by a platform-specific default.I wonder how all this fits together.
Top-level look:
===============Sigh, one problem is that the notifiers have different purpose:
1. Notify hypervisor (platform). This looks like a must-to-have.
2. Platform specific dump of printk messages. This is nice-to-have. But note that we also have
kmsg_dumpAPI for this, seekmsg_dump_desc().3. Print extra info. Also this is nice-to-have.
Some is optional when kdump is created because it might be read from there. Some can't be found in crash dump, e.g. dumping lowlevel HW state.
In addition, there is
sys_info()info API which allows to dump state of various subsystems.4. Some notifiers are smp-safe and some just a best effort and more safe after disabling other CPUs.
In addition, I guess that it is better to call
crash_kexec()without stopping other CPUs because stopping is not reliable without NMI. And it would create extra noise in the backtrace. And ???Now, different people have different preferences but mainly:
Quoted 7 lines
+ the more safe kdump the better
+ the more safe reboot the better
+ the more info the betterNow, the question is how to satisfy the various requirements and keep the design sane. We need a compromise but where.
With the above in mind, I think about two approaches. I have the following constrains in mind:
+ keep it simple (2-3 lists max)
+ If people configure kdump then they want to use it. Post crash_kexec() paths are just a fallback.
+ If people configure panic_sys_info + crash dump then they want it even in crash dump.
+ If people configure any kmsg dump and configure kdump then they want it before crash_kexec().
+ If a platform wants to do something then it wants to do it before __crash_kexec().
+ If something cause problems then fix it. But allow to disable it for debugging purposes.
One very important aspect is when other cpus should get disabled. I guess that most people would want to call __crash_kexec() before disabling other CPU. Even though, I am not completely sure why. But some notifiers might be hard to do smp_safe.
The disabling of other CPUs seems to be the most critical operation which would split notifiers into two groups.
Approach A: Two list: smp_safe vs. smp_unsafe
=============================================
We could create two list:
+ panic_notifiers_smp_safe_list
+ panic_notifiers_smp_unsafe_list
Where the safe list would be called before __crash_kexec(). And the other after CPUs get disabled.
In the long term, I would get rid of the controversial "crash_kexec_post_notifiers" options. Instead, I would add:
+ disable_panic_notifiers_smp_safe
+ disable_panic_notifiers_smp_unsafe
+ disable_cpus_before_kdump
Then we might call:
panic_notify_smp_safe();
if (disable_cpus_before_kdump) {
crash_smp_send_stop();
panic_notify_smp_unsafe();
}
__crash_kexec();
if (!disable_cpus_before_kdump) {
crash_smp_send_stop();
panic_notify_smp_unsafe();
}Where the panic_notify* functions would get implemented as:
void panic_notify_smp_safe(void)
{
if (disable_panic_notifiers_smp_safe)
return;
...
}Approach B: Three lists: platform, smp_safe, and smp_unsafe()
=============================================================
It is similar to approach A. We would just add an extra:
+ panic_notifiers_platform_list
+ disable_panic_notifiers_platform_list
This list would be used for smp-safe notifiers which are required be some platform. It would be the notifiers which are crucial. Which are currently the reason to set "_crash_kexec_post_notifiers".
It might be called also when __crash_kexec() is called outside panic().
It would allow to separate the most crucial stuff from the rest. It might help when it might be enough to disable the less crucial stuff for debugging kdump issues.
Conclusion:
===========
Of course, there are many details which might need to be sorted, for example:
+ how to put this together with the existing list until all notifiers are migrated.
+ which list should be called when (__)crash_kexec() is called explicitly outside vpanic().
This patchset, adding vmware_log_notifier, might implement just the panic_notifiers_platform_list. The rest might be added by another volunteer.
How does this sounds, please?
Best Regards,
Petr
Re: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
Hi, Petr.
First of all I really appreciate you going over this. Thanks!
Quoted 15 lines · Petr Mladek
Approach B: Three lists: platform,
smp_safe, andsmp_unsafe()
=============================================================It is similar to approach A. We would just add an extra:
+
panic_notifiers_platform_list
+disable_panic_notifiers_platform_listThis list would be used for smp-safe notifiers which are required be some platform. It would be the notifiers which are crucial. Which are currently the reason to set "
_crash_kexec_post_notifiers".It might be called also when
__crash_kexec()is called outsidepanic().
[...]
Quoted 5 lines
This patchset, adding
vmware_log_notifier, might implement just thepanic_notifiers_platform_list. The rest might be added by another volunteer.How does this sounds, please?
That sounds good to me. For v3 I'd do just the platform list:
- One call in vpanic(), right after kgdb_panic() and before the first __crash_kexec(), whatever crash_kexec_post_notifiers is set to. The list runs before kdump and before the other CPUs are stopped.
- One call in __crash_kexec(), after it has taken the kexec lock, found a crash image and saved the registers, for paths that enter kdump without panic(), like oops_end() or Hyper-V's hv_crash_handle(). Once the early panic call has run the list, the guard makes this one a no-op. That removes the dependence on crash_kexec_post_notifiers you pointed out before.
- A once-only guard shared by both, so the list also runs only once when a callback panics.
- disable_panic_notifiers_platform_list as a boot and runtime switch, checked in the same helper, replacing panic_pre_kdump_postpone.
- Kernel-doc with your definition: smp-safe callbacks a platform needs, which would otherwise be a reason to set crash_kexec_post_notifiers.
Roughly:
kgdb_panic(buf);
panic_notify_platform();
if (!_crash_kexec_post_notifiers)
__crash_kexec(NULL);and in __crash_kexec():
crash_setup_regs(&fixed_regs, regs);
/* Direct entry outside panic() */
panic_notify_platform();
crash_save_vmcoreinfo();I'd keep the second call in __crash_kexec() rather than crash_kexec(), because afaict crash_kexec() can return without a crash image, e.g. from the BPF kfunc, or from oops_end() before it panics. Calling the list there would use up the guard even when no kdump follows.
crash_kexec_post_notifiers, the existing list and the kmsg dumpers stay as they are, and moving other platforms over can come later.
The VMware log copy would be the only user, and it's still best-effort
diagnostics: kdump and the reboot don't depend on it. It copies the log tail into an 8 KiB buffer. On panic() that happens after the panic message and any local backtrace; on direct entry from an oops, after the exception output. With the list enabled throughout, the copy precedes the later panic notifiers, sys_info() and the all-CPU backtrace step. The guest-crash report stays a late kmsg dumper that's skipped while a crash kernel is loaded, because the host can power off the VM inside that call.
If that matches what you had in mind, I'll do it that way in v3.
Guilherme, Stephen, Baoquan, does that work for you too?
z
Baoquan He
maintainerRe: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
Quoted 79 lines · Zack Rusin
Hi, Petr.
First of all I really appreciate you going over this. Thanks!
Quoted 15 lines · Petr Mladek
Approach B: Three lists: platform,
smp_safe, andsmp_unsafe()
=============================================================It is similar to approach A. We would just add an extra:
+
panic_notifiers_platform_list
+disable_panic_notifiers_platform_listThis list would be used for smp-safe notifiers which are required be some platform. It would be the notifiers which are crucial. Which are currently the reason to set "
_crash_kexec_post_notifiers".It might be called also when
__crash_kexec()is called outsidepanic().[...]
Quoted 5 lines
This patchset, adding
vmware_log_notifier, might implement just thepanic_notifiers_platform_list. The rest might be added by another volunteer.How does this sounds, please?
That sounds good to me. For v3 I'd do just the platform list:
- One call in
vpanic(), right afterkgdb_panic()and before the first__crash_kexec(), whatevercrash_kexec_post_notifiersis set to. The list runs before kdump and before the other CPUs are stopped.
- One call in__crash_kexec(), after it has taken the kexec lock, found a crash image and saved the registers, for paths that enter kdump withoutpanic(), likeoops_end()or Hyper-V'shv_crash_handle(). Once the early panic call has run the list, the guard makes this one a no-op. That removes the dependence oncrash_kexec_post_notifiersyou pointed out before.
- A once-only guard shared by both, so the list also runs only once when a callback panics.
-disable_panic_notifiers_platform_listas a boot and runtime switch, checked in the same helper, replacingpanic_pre_kdump_postpone.
- Kernel-doc with your definition: smp-safe callbacks a platform needs, which would otherwise be a reason to setcrash_kexec_post_notifiers.Roughly:
kgdb_panic(buf); panic_notify_platform(); if (!_crash_kexec_post_notifiers) __crash_kexec(NULL);and in
__crash_kexec():crash_setup_regs(&fixed_regs, regs); /* Direct entry outside panic() */ panic_notify_platform(); crash_save_vmcoreinfo();I'd keep the second call in
__crash_kexec()rather thancrash_kexec(), because afaictcrash_kexec()can return without a crash image, e.g. from the BPF kfunc, or fromoops_end()before it panics. Calling the list there would use up the guard even when no kdump follows.
crash_kexec_post_notifiers, the existing list and the kmsg dumpers stay as they are, and moving other platforms over can come later.The VMware log copy would be the only user, and it's still best-effort
diagnostics: kdump and the reboot don't depend on it. It copies the log tail into an 8 KiB buffer. Onpanic()that happens after the panic message and any local backtrace; on direct entry from an oops, after the exception output. With the list enabled throughout, the copy precedes the later panic notifiers,sys_info()and the all-CPU backtrace step. The guest-crash report stays a late kmsg dumper that's skipped while a crash kernel is loaded, because the host can power off the VM inside that call.
Quoted 3 lines
If that matches what you had in mind, I'll do it that way in v3.
Guilherme, Stephen, Baoquan, does that work for you too?
Hi Zack,
Sorry I didn't check this series before, just trying to catch up.
I like the Approach B direction: one panic_notifiers_platform_list for platform callbacks that must run before kdump. While I have one concern about the long term.
Today the list has only the VMware log sender. Later, more handlers may join (for example pvpanic, Hyper-V, Xen, gsmi, SNP). When the list grows, someone will want to run only their handler, or to skip some handlers. The easy answer is "add a new list for my handler". I think this will be a problem too in the future. Every new list adds a new global ordering rule and a new disable switch. Petr already said we should keep the number of lists small.
Currently, atomic_notifier_call_chain() runs all registered callbacks. There is no per-handler enable/disable and no filter. NOTIFY_STOP_MASK can stop the chain, but we must not use it here, because one handler could hide all the later handlers. The list-level disable_panic_notifiers_platform_list can only disable the whole list.
I have some rough though, just for reference:
1. Keep one panic_notifiers_platform_list.
2. Give each handler a small wrapper with a name and an enabled flag:
struct panic_pre_kdump_notifier {
struct notifier_block nb;
const char *name;
bool enabled;
};3. In the dispatch, skip a handler when enabled is false. Print the name before calling it. This also helps when a handler hangs and we want to know which one it was.
4. Add a boot parameter to disable handlers by name, for example:
panic_pre_kdump.disable=vmware_log,hyperv_crash
Parse it early. At panic time we only read the flag. We do not parse strings in the panic path.
5. Keep the list-level disable_panic_notifiers_platform_list. It is still useful to disable the whole list for debugging.
6. If the list is still too broad later, we can add a reason/class argument (for example PANIC, OOPS_DIRECT). A handler can then decide if it cares. This is better than adding a new list.
So with them:
- We keep one place to register, one ordering rule, and one place to look when something goes wrong.
- "Run only my handler" becomes a debug switch (disable the others), not a new global list. Or vice versa.
- We do not change the general struct notifier_block.
- The panic path only reads a bool, so it is safe and cheap.
just some rough thoughts, maybe not well polished, just for reference. Thinking of these becasue I do meet requirement in real use case where they really want to run their own one specific panic handler before kdump while not easy to make it.
Thanks,
Baoquan
Re: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
Quoted 129 lines · Baoquan He
Quoted 79 lines · Zack Rusin
Hi, Petr.
First of all I really appreciate you going over this. Thanks!
Quoted 15 lines · Petr Mladek
Approach B: Three lists: platform,
smp_safe, andsmp_unsafe()
=============================================================It is similar to approach A. We would just add an extra:
+
panic_notifiers_platform_list
+disable_panic_notifiers_platform_listThis list would be used for smp-safe notifiers which are required be some platform. It would be the notifiers which are crucial. Which are currently the reason to set "
_crash_kexec_post_notifiers".It might be called also when
__crash_kexec()is called outsidepanic().[...]
Quoted 5 lines
This patchset, adding
vmware_log_notifier, might implement just thepanic_notifiers_platform_list. The rest might be added by another volunteer.How does this sounds, please?
That sounds good to me. For v3 I'd do just the platform list:
- One call in
vpanic(), right afterkgdb_panic()and before the first__crash_kexec(), whatevercrash_kexec_post_notifiersis set to. The list runs before kdump and before the other CPUs are stopped.
- One call in__crash_kexec(), after it has taken the kexec lock, found a crash image and saved the registers, for paths that enter kdump withoutpanic(), likeoops_end()or Hyper-V'shv_crash_handle(). Once the early panic call has run the list, the guard makes this one a no-op. That removes the dependence oncrash_kexec_post_notifiersyou pointed out before.
- A once-only guard shared by both, so the list also runs only once when a callback panics.
-disable_panic_notifiers_platform_listas a boot and runtime switch, checked in the same helper, replacingpanic_pre_kdump_postpone.
- Kernel-doc with your definition: smp-safe callbacks a platform needs, which would otherwise be a reason to setcrash_kexec_post_notifiers.Roughly:
kgdb_panic(buf); panic_notify_platform(); if (!_crash_kexec_post_notifiers) __crash_kexec(NULL);and in
__crash_kexec():crash_setup_regs(&fixed_regs, regs); /* Direct entry outside panic() */ panic_notify_platform(); crash_save_vmcoreinfo();I'd keep the second call in
__crash_kexec()rather thancrash_kexec(), because afaictcrash_kexec()can return without a crash image, e.g. from the BPF kfunc, or fromoops_end()before it panics. Calling the list there would use up the guard even when no kdump follows.
crash_kexec_post_notifiers, the existing list and the kmsg dumpers stay as they are, and moving other platforms over can come later.The VMware log copy would be the only user, and it's still best-effort
diagnostics: kdump and the reboot don't depend on it. It copies the log tail into an 8 KiB buffer. Onpanic()that happens after the panic message and any local backtrace; on direct entry from an oops, after the exception output. With the list enabled throughout, the copy precedes the later panic notifiers,sys_info()and the all-CPU backtrace step. The guest-crash report stays a late kmsg dumper that's skipped while a crash kernel is loaded, because the host can power off the VM inside that call.Quoted 3 lines
If that matches what you had in mind, I'll do it that way in v3.
Guilherme, Stephen, Baoquan, does that work for you too?
Hi Zack,
Sorry I didn't check this series before, just trying to catch up.
I like the Approach B direction: one
panic_notifiers_platform_listfor platform callbacks that must run before kdump. While I have one concern about the long term.Today the list has only the VMware log sender. Later, more handlers may join (for example pvpanic, Hyper-V, Xen, gsmi, SNP). When the list grows, someone will want to run only their handler, or to skip some handlers. The easy answer is "add a new list for my handler". I think this will be a problem too in the future. Every new list adds a new global ordering rule and a new disable switch. Petr already said we should keep the number of lists small.
Currently,
atomic_notifier_call_chain()runs all registered callbacks. There is no per-handler enable/disable and no filter.NOTIFY_STOP_MASKcan stop the chain, but we must not use it here, because one handler could hide all the later handlers. The list-leveldisable_panic_notifiers_platform_listcan only disable the whole list.I have some rough though, just for reference:
1. Keep one
panic_notifiers_platform_list.2. Give each handler a small wrapper with a name and an enabled flag:
struct panic_pre_kdump_notifier { struct notifier_block nb; const char *name; bool enabled; };3. In the dispatch, skip a handler when enabled is false. Print the name before calling it. This also helps when a handler hangs and we want to know which one it was.
4. Add a boot parameter to disable handlers by name, for example:
panic_pre_kdump.disable=vmware_log,hyperv_crash
Parse it early. At panic time we only read the flag. We do not parse strings in the panic path.
Quoted 6 lines
5. Keep the list-level
disable_panic_notifiers_platform_list. It is still useful to disable the whole list for debugging.6. If the list is still too broad later, we can add a reason/class argument (for example PANIC,
OOPS_DIRECT). A handler can then decide if it cares. This is better than adding a new list.
Thanks for looking at it. I agree we shouldn't add a separate list for each handler, and named handlers with their own switch on the one list sound like the right way to grow it.
For v3 I'd like to keep the series to the list itself. With VMware as the only callback, the list-wide boot switch already lets us disable platform logging. The sender also has its own sysctl, kernel.vmware_record_panic_msg. We can add per-handler selection with the next user, when there's an actual choice between handlers. I'm happy to help with that when it comes up.
Two of your points do fit in v3 as documentation. I'll change the panic_notify_platform() kernel-doc to also say that:
- callbacks must return NOTIFY_DONE, because NOTIFY_STOP would skip the callbacks after them
- the notifier value is 0.
The VMware callback ignores that value, which leaves room to add reason information later.
Petr, does keeping v3 to that sound right to you?
z
Re: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
Quoted 32 lines · Zack Rusin
Quoted 31 lines · Baoquan He
Quoted 29 lines · Zack Rusin
Hi, Petr.
First of all I really appreciate you going over this. Thanks!
Quoted 15 lines · Petr Mladek
Approach B: Three lists: platform,
smp_safe, andsmp_unsafe()
=============================================================It is similar to approach A. We would just add an extra:
+
panic_notifiers_platform_list
+disable_panic_notifiers_platform_listThis list would be used for smp-safe notifiers which are required be some platform. It would be the notifiers which are crucial. Which are currently the reason to set "
_crash_kexec_post_notifiers".It might be called also when
__crash_kexec()is called outsidepanic().[...]
Quoted 5 lines
This patchset, adding
vmware_log_notifier, might implement just thepanic_notifiers_platform_list. The rest might be added by another volunteer.How does this sounds, please?
That sounds good to me. For v3 I'd do just the platform list:
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
- One call in
vpanic(), right afterkgdb_panic()and before the first__crash_kexec(), whatevercrash_kexec_post_notifiersis set to. The list runs before kdump and before the other CPUs are stopped.
- One call in__crash_kexec(), after it has taken the kexec lock, found a crash image and saved the registers, for paths that enter kdump withoutpanic(), likeoops_end()or Hyper-V'shv_crash_handle(). Once the early panic call has run the list, the guard makes this one a no-op. That removes the dependence oncrash_kexec_post_notifiersyou pointed out before.
- A once-only guard shared by both, so the list also runs only once when a callback panics.
Just to be sure. I think that a simple static bool or int should be enough. The caller is responsible for the synchronization. I believe that it should be done by the "panic_cpu".
Quoted 51 lines
Quoted 51 lines
Quoted 39 lines
-
disable_panic_notifiers_platform_listas a boot and runtime switch, checked in the same helper, replacingpanic_pre_kdump_postpone.
- Kernel-doc with your definition: smp-safe callbacks a platform needs, which would otherwise be a reason to setcrash_kexec_post_notifiers.Roughly:
kgdb_panic(buf); panic_notify_platform(); if (!_crash_kexec_post_notifiers) __crash_kexec(NULL);and in
__crash_kexec():crash_setup_regs(&fixed_regs, regs); /* Direct entry outside panic() */ panic_notify_platform(); crash_save_vmcoreinfo();I'd keep the second call in
__crash_kexec()rather thancrash_kexec(), because afaictcrash_kexec()can return without a crash image, e.g. from the BPF kfunc, or fromoops_end()before it panics. Calling the list there would use up the guard even when no kdump follows.
crash_kexec_post_notifiers, the existing list and the kmsg dumpers stay as they are, and moving other platforms over can come later.The VMware log copy would be the only user, and it's still best-effort
diagnostics: kdump and the reboot don't depend on it. It copies the log tail into an 8 KiB buffer. Onpanic()that happens after the panic message and any local backtrace; on direct entry from an oops, after the exception output. With the list enabled throughout, the copy precedes the later panic notifiers,sys_info()and the all-CPU backtrace step. The guest-crash report stays a late kmsg dumper that's skipped while a crash kernel is loaded, because the host can power off the VM inside that call.Quoted 3 lines
If that matches what you had in mind, I'll do it that way in v3.
Guilherme, Stephen, Baoquan, does that work for you too?
Hi Zack,
Sorry I didn't check this series before, just trying to catch up.
I like the Approach B direction: one
panic_notifiers_platform_listfor platform callbacks that must run before kdump. While I have one concern about the long term.
Quoted 6 lines
Quoted 6 lines
Today the list has only the VMware log sender. Later, more handlers may join (for example pvpanic, Hyper-V, Xen, gsmi, SNP). When the list grows, someone will want to run only their handler, or to skip some handlers. The easy answer is "add a new list for my handler". I think this will be a problem too in the future. Every new list adds a new global ordering rule and a new disable switch. Petr already said we should keep the number of lists small.
My hope is most of the potential users won't be registered at the same time or will be a NOP in the real life. Because each particular system will actively used only some technology.
But maybe I am naive and there will be selection and ordering problems.
Quoted 10 lines
Quoted 10 lines
Currently,
atomic_notifier_call_chain()runs all registered callbacks. There is no per-handler enable/disable and no filter.NOTIFY_STOP_MASKcan stop the chain, but we must not use it here, because one handler could hide all the later handlers. The list-leveldisable_panic_notifiers_platform_listcan only disable the whole list.I have some rough though, just for reference:
1. Keep one
panic_notifiers_platform_list.
Quoted 7 lines
Quoted 7 lines
2. Give each handler a small wrapper with a name and an enabled flag:
struct panic_pre_kdump_notifier { struct notifier_block nb; const char *name; bool enabled; };
This looks good to me.
Quoted 7 lines
Quoted 7 lines
3. In the dispatch, skip a handler when enabled is false. Print the name before calling it. This also helps when a handler hangs and we want to know which one it was.
4. Add a boot parameter to disable handlers by name, for example:
panic_pre_kdump.disable=vmware_log,hyperv_crash
I like this. I think that we just would want to do s/_pre_dump/_notifiers_platform/.
Quoted 14 lines
Quoted 9 lines
Parse it early. At panic time we only read the flag. We do not parse strings in the panic path.
5. Keep the list-level
disable_panic_notifiers_platform_list. It is still useful to disable the whole list for debugging.6. If the list is still too broad later, we can add a reason/class argument (for example PANIC,
OOPS_DIRECT). A handler can then decide if it cares. This is better than adding a new list.Thanks for looking at it. I agree we shouldn't add a separate list for each handler, and named handlers with their own switch on the one list sound like the right way to grow it.
Quoted 6 lines
For v3 I'd like to keep the series to the list itself. With VMware as the only callback, the list-wide boot switch already lets us disable platform logging. The sender also has its own sysctl, kernel.vmware_record_panic_msg. We can add per-handler selection with the next user, when there's an actual choice between handlers. I'm happy to help with that when it comes up.
Sound good to me. I would like to start simple. We could add the selection later when it is needed in the real life.
Quoted 5 lines
Two of your points do fit in v3 as documentation. I'll change the
panic_notify_platform()kernel-doc to also say that:
- callbacks must returnNOTIFY_DONE, becauseNOTIFY_STOPwould skip the callbacks after them
- the notifier value is 0.
Great catch!
Quoted 4 lines
The VMware callback ignores that value, which leaves room to add reason information later.
Petr, does keeping v3 to that sound right to you?
Sounds good to me. But you might want to wait few more days for more potential feedback.
Best Regards,
Petr
Baoquan He
maintainerRe: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
Quoted 107 lines · Petr Mladek
Quoted 32 lines · Zack Rusin
Quoted 31 lines · Baoquan He
Quoted 29 lines · Zack Rusin
Hi, Petr.
First of all I really appreciate you going over this. Thanks!
Quoted 15 lines · Petr Mladek
Approach B: Three lists: platform,
smp_safe, andsmp_unsafe()
=============================================================It is similar to approach A. We would just add an extra:
+
panic_notifiers_platform_list
+disable_panic_notifiers_platform_listThis list would be used for smp-safe notifiers which are required be some platform. It would be the notifiers which are crucial. Which are currently the reason to set "
_crash_kexec_post_notifiers".It might be called also when
__crash_kexec()is called outsidepanic().[...]
Quoted 5 lines
This patchset, adding
vmware_log_notifier, might implement just thepanic_notifiers_platform_list. The rest might be added by another volunteer.How does this sounds, please?
That sounds good to me. For v3 I'd do just the platform list:
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
- One call in
vpanic(), right afterkgdb_panic()and before the first__crash_kexec(), whatevercrash_kexec_post_notifiersis set to. The list runs before kdump and before the other CPUs are stopped.
- One call in__crash_kexec(), after it has taken the kexec lock, found a crash image and saved the registers, for paths that enter kdump withoutpanic(), likeoops_end()or Hyper-V'shv_crash_handle(). Once the early panic call has run the list, the guard makes this one a no-op. That removes the dependence oncrash_kexec_post_notifiersyou pointed out before.
- A once-only guard shared by both, so the list also runs only once when a callback panics.Just to be sure. I think that a simple static bool or int should be enough. The caller is responsible for the synchronization. I believe that it should be done by the "
panic_cpu".Quoted 51 lines
Quoted 51 lines
Quoted 39 lines
-
disable_panic_notifiers_platform_listas a boot and runtime switch, checked in the same helper, replacingpanic_pre_kdump_postpone.
- Kernel-doc with your definition: smp-safe callbacks a platform needs, which would otherwise be a reason to setcrash_kexec_post_notifiers.Roughly:
kgdb_panic(buf); panic_notify_platform(); if (!_crash_kexec_post_notifiers) __crash_kexec(NULL);and in
__crash_kexec():crash_setup_regs(&fixed_regs, regs); /* Direct entry outside panic() */ panic_notify_platform(); crash_save_vmcoreinfo();I'd keep the second call in
__crash_kexec()rather thancrash_kexec(), because afaictcrash_kexec()can return without a crash image, e.g. from the BPF kfunc, or fromoops_end()before it panics. Calling the list there would use up the guard even when no kdump follows.
crash_kexec_post_notifiers, the existing list and the kmsg dumpers stay as they are, and moving other platforms over can come later.The VMware log copy would be the only user, and it's still best-effort
diagnostics: kdump and the reboot don't depend on it. It copies the log tail into an 8 KiB buffer. Onpanic()that happens after the panic message and any local backtrace; on direct entry from an oops, after the exception output. With the list enabled throughout, the copy precedes the later panic notifiers,sys_info()and the all-CPU backtrace step. The guest-crash report stays a late kmsg dumper that's skipped while a crash kernel is loaded, because the host can power off the VM inside that call.Quoted 3 lines
If that matches what you had in mind, I'll do it that way in v3.
Guilherme, Stephen, Baoquan, does that work for you too?
Hi Zack,
Sorry I didn't check this series before, just trying to catch up.
I like the Approach B direction: one
panic_notifiers_platform_listfor platform callbacks that must run before kdump. While I have one concern about the long term.Quoted 6 lines
Quoted 6 lines
Today the list has only the VMware log sender. Later, more handlers may join (for example pvpanic, Hyper-V, Xen, gsmi, SNP). When the list grows, someone will want to run only their handler, or to skip some handlers. The easy answer is "add a new list for my handler". I think this will be a problem too in the future. Every new list adds a new global ordering rule and a new disable switch. Petr already said we should keep the number of lists small.
Quoted 5 lines
My hope is most of the potential users won't be registered at the same time or will be a NOP in the real life. Because each particular system will actively used only some technology.
But maybe I am naive and there will be selection and ordering problems.
If they are all platform related handling, that's fine. The platform system vendor can wrap them up in one handler, and usually the handler is a msut-be-done thing. If a platform system user wants to add an action for their own, that could be different. I am not very sure either. Unless we can collect information and be certain this won't happen.
Quoted 25 lines
Quoted 11 lines
Quoted 11 lines
Currently,
atomic_notifier_call_chain()runs all registered callbacks. There is no per-handler enable/disable and no filter.NOTIFY_STOP_MASKcan stop the chain, but we must not use it here, because one handler could hide all the later handlers. The list-leveldisable_panic_notifiers_platform_listcan only disable the whole list.I have some rough though, just for reference:
1. Keep one
panic_notifiers_platform_list.Quoted 7 lines
Quoted 7 lines
2. Give each handler a small wrapper with a name and an enabled flag:
struct panic_pre_kdump_notifier { struct notifier_block nb; const char *name; bool enabled; };This looks good to me.
Quoted 4 lines
Quoted 4 lines
3. In the dispatch, skip a handler when enabled is false. Print the name before calling it. This also helps when a handler hangs and we want to know which one it was.
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
4. Add a boot parameter to disable handlers by name, for example:
panic_pre_kdump.disable=vmware_log,hyperv_crash
I like this. I think that we just would want to do s/_pre_dump/_notifiers_platform/.
Sure, the name is just for demonstrating.
Quoted 33 lines
Quoted 15 lines
Quoted 10 lines
Parse it early. At panic time we only read the flag. We do not parse strings in the panic path.
5. Keep the list-level
disable_panic_notifiers_platform_list. It is still useful to disable the whole list for debugging.6. If the list is still too broad later, we can add a reason/class argument (for example PANIC,
OOPS_DIRECT). A handler can then decide if it cares. This is better than adding a new list.Thanks for looking at it. I agree we shouldn't add a separate list for each handler, and named handlers with their own switch on the one list sound like the right way to grow it.
Quoted 6 lines
For v3 I'd like to keep the series to the list itself. With VMware as the only callback, the list-wide boot switch already lets us disable platform logging. The sender also has its own sysctl, kernel.vmware_record_panic_msg. We can add per-handler selection with the next user, when there's an actual choice between handlers. I'm happy to help with that when it comes up.
Sound good to me. I would like to start simple. We could add the selection later when it is needed in the real life.
Quoted 5 lines
Two of your points do fit in v3 as documentation. I'll change the
panic_notify_platform()kernel-doc to also say that:
- callbacks must returnNOTIFY_DONE, becauseNOTIFY_STOPwould skip the callbacks after them
- the notifier value is 0.Great catch!
Quoted 7 lines
Quoted 4 lines
The VMware callback ignores that value, which leaves room to add reason information later.
Petr, does keeping v3 to that sound right to you?
Sounds good to me. But you might want to wait few more days for more potential feedback.
ACK.
Baoquan He
maintainerRe: [PATCH v2 1/6] panic: Add a notifier chain for pre-kdump callbacks
In reply to Petr MladekQuoted 4 lines · Petr Mladek
Quoted 3 lines · Zack Rusin
Quoted 2 lines · Baoquan He
On 10/20/26 at 03:23pm, Zack Rusin wrote:
...snip...
Quoted 37 lines
Quoted 30 lines
Quoted 30 lines
Quoted 18 lines
I'd keep the second call in
__crash_kexec()rather thancrash_kexec(), because afaictcrash_kexec()can return without a crash image, e.g. from the BPF kfunc, or fromoops_end()before it panics. Calling the list there would use up the guard even when no kdump follows.
crash_kexec_post_notifiers, the existing list and the kmsg dumpers stay as they are, and moving other platforms over can come later.The VMware log copy would be the only user, and it's still best-effort
diagnostics: kdump and the reboot don't depend on it. It copies the log tail into an 8 KiB buffer. Onpanic()that happens after the panic message and any local backtrace; on direct entry from an oops, after the exception output. With the list enabled throughout, the copy precedes the later panic notifiers,sys_info()and the all-CPU backtrace step. The guest-crash report stays a late kmsg dumper that's skipped while a crash kernel is loaded, because the host can power off the VM inside that call.Quoted 3 lines
If that matches what you had in mind, I'll do it that way in v3.
Guilherme, Stephen, Baoquan, does that work for you too?
Hi Zack,
Sorry I didn't check this series before, just trying to catch up.
I like the Approach B direction: one
panic_notifiers_platform_listfor platform callbacks that must run before kdump. While I have one concern about the long term.Quoted 6 lines
Quoted 6 lines
Today the list has only the VMware log sender. Later, more handlers may join (for example pvpanic, Hyper-V, Xen, gsmi, SNP). When the list grows, someone will want to run only their handler, or to skip some handlers. The easy answer is "add a new list for my handler". I think this will be a problem too in the future. Every new list adds a new global ordering rule and a new disable switch. Petr already said we should keep the number of lists small.
Quoted 5 lines
My hope is most of the potential users won't be registered at the same time or will be a NOP in the real life. Because each particular system will actively used only some technology.
But maybe I am naive and there will be selection and ordering problems.
When I revisited this thread, I suddenly realize I may made mistake on comments. You folks seem to discussing the platform relatd handlers and list, but not generic handlers and list. If so, I am not sure if my suggestion is suitable because I didn't know these platforms well, esp the various virt platforms and their correspondent handlers.
If the next steps also involve the generic handler part, my suggestions may be relevant and could be of some reference value.
Thanks
Baoquan
Quoted 73 lines
Quoted 11 lines
Quoted 11 lines
Currently,
atomic_notifier_call_chain()runs all registered callbacks. There is no per-handler enable/disable and no filter.NOTIFY_STOP_MASKcan stop the chain, but we must not use it here, because one handler could hide all the later handlers. The list-leveldisable_panic_notifiers_platform_listcan only disable the whole list.I have some rough though, just for reference:
1. Keep one
panic_notifiers_platform_list.Quoted 7 lines
Quoted 7 lines
2. Give each handler a small wrapper with a name and an enabled flag:
struct panic_pre_kdump_notifier { struct notifier_block nb; const char *name; bool enabled; };This looks good to me.
Quoted 7 lines
Quoted 7 lines
3. In the dispatch, skip a handler when enabled is false. Print the name before calling it. This also helps when a handler hangs and we want to know which one it was.
4. Add a boot parameter to disable handlers by name, for example:
panic_pre_kdump.disable=vmware_log,hyperv_crash
I like this. I think that we just would want to do s/_pre_dump/_notifiers_platform/.
Quoted 14 lines
Quoted 9 lines
Parse it early. At panic time we only read the flag. We do not parse strings in the panic path.
5. Keep the list-level
disable_panic_notifiers_platform_list. It is still useful to disable the whole list for debugging.6. If the list is still too broad later, we can add a reason/class argument (for example PANIC,
OOPS_DIRECT). A handler can then decide if it cares. This is better than adding a new list.Thanks for looking at it. I agree we shouldn't add a separate list for each handler, and named handlers with their own switch on the one list sound like the right way to grow it.
Quoted 6 lines
For v3 I'd like to keep the series to the list itself. With VMware as the only callback, the list-wide boot switch already lets us disable platform logging. The sender also has its own sysctl, kernel.vmware_record_panic_msg. We can add per-handler selection with the next user, when there's an actual choice between handlers. I'm happy to help with that when it comes up.
Sound good to me. I would like to start simple. We could add the selection later when it is needed in the real life.
Quoted 5 lines
Two of your points do fit in v3 as documentation. I'll change the
panic_notify_platform()kernel-doc to also say that:
- callbacks must returnNOTIFY_DONE, becauseNOTIFY_STOPwould skip the callbacks after them
- the notifier value is 0.Great catch!
Quoted 4 lines
The VMware callback ignores that value, which leaves room to add reason information later.
Petr, does keeping v3 to that sound right to you?
Sounds good to me. But you might want to wait few more days for more potential feedback.
Best Regards,
Petr
PATCH v2 2/6 crash: Notify pre-kdump callbacks before switching kernels
In reply to Zack RusinFatal x86 oopses can call crash_kexec() without reaching panic(). Run the pre-kdump chain from __crash_kexec() as well, after finding a loaded image under the kexec lock and capturing the original registers.
This covers direct crash entry without moving all panic notifiers ahead of kdump. A missing image or failed trylock leaves callbacks uncalled; the shared guard skips callbacks already invoked by panic().
---
New in v2: cover direct crash-kexec entry in a separate core patch.
kernel/crash_core.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/crash_core.c +2 -0
@@ -23,6 +23,7 @@#include <linux/objtool.h> #include <linux/delay.h> #include <linux/panic.h> +#include <linux/panic_notifier.h> #include <asm/page.h> #include <asm/sections.h>
@@ -139,6 +140,7 @@ void __noclone __crash_kexec(struct pt_regs *regs)struct pt_regs fixed_regs;crash_setup_regs (&fixed_regs, regs); +panic_notify_pre_kdump (NULL );crash_save_vmcoreinfo ();machine_crash_shutdown (&fixed_regs);crash_cma_clear_pending_dma ();
[email protected]
AI reviewRe: [PATCH v2 2/6] crash: Notify pre-kdump callbacks before switching kernels
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] panic: Pre-kdump callbacks always receive NULL message in default config --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] panic: Pre-kdump callbacks always receive NULL message in default config --
commit 8884313d127ae4b9734baebea7b4ba8dd25b38a5
Author: Zack Rusin <[email protected]>
crash: Notify pre-kdump callbacks before switching kernels
Fatal x86 oopses can call crash_kexec() without reaching panic(). Run the pre-kdump chain from __crash_kexec() as well, after finding a loaded image under the kexec lock and capturing the original registers.
Quoted 1 line
the shared guard skips callbacks already invoked by
panic().
[Severity: Medium]
Is this statement accurate?
During a standard panic-triggered kdump with crash_kexec_post_notifiers=0 (the default configuration), vpanic() calls __crash_kexec(NULL) before it formats the panic message and calls its own explicit panic_notify_pre_kdump(buf).
Because __crash_kexec(NULL) runs first, won't the new panic_notify_pre_kdump(NULL) call consume the once-per-boot atomic guard, rather than being skipped by it?
Quoted 4 lines
kernel/crash_core.c +0
-0
[ ... ]
kernel/crash_core.c void __noclone __crash_kexec(struct pt_regs *regs) · line 143
Quoted 5 lines
kernel/crash_core.c +1
-0@@ -139,6 +140,7 @@ void __noclone __crash_kexec(struct pt_regs *regs)struct pt_regs fixed_regs;crash_setup_regs (&fixed_regs, regs); +panic_notify_pre_kdump (NULL );
[Severity: Medium]
Will this cause pre-kdump notifiers to receive a NULL message pointer instead of the expected panic message?
If a system panic occurs and kexec is configured with the default setting of crash_kexec_post_notifiers=0, vpanic() triggers __crash_kexec(NULL) before reaching its own explicit panic_notify_pre_kdump(buf):
kernel/panic.c:vpanic() {
...
if (!_crash_kexec_post_notifiers)
__crash_kexec(NULL);
...
panic_notify_pre_kdump(buf);
}When this happens, __crash_kexec() will invoke panic_notify_pre_kdump() with a NULL message pointer. This permanently consumes the once-per-boot guard, and any callback relying on the documented msg parameter will experience data loss or potential NULL dereferences, violating the API contract that promises the panic message during a panic.
Quoted 3 lines
kernel/crash_core.c +0
-0crash_save_vmcoreinfo ();machine_crash_shutdown (&fixed_regs);crash_cma_clear_pending_dma ();
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v2 2/6] crash: Notify pre-kdump callbacks before switching kernels
Quoted 3 lines · On Mon, Sep 28, 2026 at 2:09 PM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] panic: Pre-kdump callbacks always receive NULL message in default config
fwiw, this report seems invalid to me.
Quoted 16 lines
commit
8884313d127ae4b9734baebea7b4ba8dd25b38a5
Author: Zack Rusin <[email protected]>crash: Notify pre-kdump callbacks before switching kernels
Fatal x86 oopses can call
crash_kexec()without reachingpanic(). Run the pre-kdump chain from__crash_kexec()as well, after finding a loaded image under the kexec lock and capturing the original registers.Quoted 1 line
the shared guard skips callbacks already invoked by
panic().[Severity: Medium]
Is this statement accurate?
Quoted 8 lines
During a standard panic-triggered kdump with crash_kexec_post_notifiers=0 (the default configuration),
vpanic()calls__crash_kexec(NULL)before it formats the panic message and calls its own explicitpanic_notify_pre_kdump(buf).Because
__crash_kexec(NULL)runs first, won't the newpanic_notify_pre_kdump(NULL)call consume the once-per-boot atomic guard, rather than being skipped by it?
Yes, and that's intended. By default the crash-core call runs first and the late call in vpanic() is skipped. With crash_kexec_post_notifiers=1 the order is reversed. vpanic() runs the list with buf, and the crash-core call is skipped. The changelog sentence only describes the second case.
Quoted 27 lines
Quoted 4 lines
kernel/crash_core.c +0
-0[ ... ]
kernel/crash_core.c void __noclone __crash_kexec(struct pt_regs *regs) · line 143
Quoted 5 lines
kernel/crash_core.c +1
-0@@ -139,6 +140,7 @@ void __noclone __crash_kexec(struct pt_regs *regs)struct pt_regs fixed_regs;crash_setup_regs (&fixed_regs, regs); +panic_notify_pre_kdump (NULL );[Severity: Medium]
Will this cause pre-kdump notifiers to receive a NULL message pointer instead of the expected panic message?If a system panic occurs and kexec is configured with the default setting of crash_kexec_post_notifiers=0,
vpanic()triggers__crash_kexec(NULL)before reaching its own explicitpanic_notify_pre_kdump(buf):kernel/panic.c:vpanic() { ... if (!_crash_kexec_post_notifiers) __crash_kexec(NULL); ... panic_notify_pre_kdump(buf); }
Quoted 5 lines
When this happens,
__crash_kexec()will invokepanic_notify_pre_kdump()with a NULL message pointer. This permanently consumes the once-per-boot guard, and any callback relying on the documented msg parameter will experience data loss or potential NULL dereferences, violating the API contract that promises the panic message during a panic.
afaict Sashiko gets tripped up here by the doc from the previous email. Nothing in this series dereferences the msg. The only callback is the VMware logger in patch 4, which ignores the argument. It reads the printk buffer, where vpanic() has already written the panic line.
If there's an interest in fixing this false-positive in code for Sashiko (or if there are other issues that would make me respin v3) I'd just change the doc added in the first change in this series like this:
- * @msg: Panic message, or NULL for direct crash-kexec entry
+ * @msg: Optional panic message; callbacks must tolerate NULL which, I think, would fix Sashiko here.
z
Re: [PATCH v2 2/6] crash: Notify pre-kdump callbacks before switching kernels
Quoted 28 lines · Zack Rusin
Quoted 22 lines
kernel/crash_core.c void __noclone __crash_kexec(struct pt_regs *regs) · line 143
Quoted 5 lines
kernel/crash_core.c +1
-0@@ -139,6 +140,7 @@ void __noclone __crash_kexec(struct pt_regs *regs)struct pt_regs fixed_regs;crash_setup_regs (&fixed_regs, regs); +panic_notify_pre_kdump (NULL );[Severity: Medium]
Will this cause pre-kdump notifiers to receive a NULL message pointer instead of the expected panic message?If a system panic occurs and kexec is configured with the default setting of crash_kexec_post_notifiers=0,
vpanic()triggers__crash_kexec(NULL)before reaching its own explicitpanic_notify_pre_kdump(buf):kernel/panic.c:vpanic() { ... if (!_crash_kexec_post_notifiers) __crash_kexec(NULL); ... panic_notify_pre_kdump(buf); }Quoted 5 lines
When this happens,
__crash_kexec()will invokepanic_notify_pre_kdump()with a NULL message pointer. This permanently consumes the once-per-boot guard, and any callback relying on the documented msg parameter will experience data loss or potential NULL dereferences, violating the API contract that promises the panic message during a panic.
Quoted 4 lines
afaict Sashiko gets tripped up here by the doc from the previous email. Nothing in this series dereferences the msg. The only callback is the VMware logger in patch 4, which ignores the argument. It reads the printk buffer, where
vpanic()has already written the panic line.
If you are not using the argument, why are you providing it in your new API? Just drop the argument. If any future pre_kdump panic notifiers need additional information, they can adjust the API appropriately.
John Ogness
Re: [PATCH v2 2/6] crash: Notify pre-kdump callbacks before switching kernels
In reply to Zack RusinQuoted 29 lines · Zack Rusin
Fatal x86 oopses can call
crash_kexec()without reachingpanic(). Run the pre-kdump chain from__crash_kexec()as well, after finding a loaded image under the kexec lock and capturing the original registers.This covers direct crash entry without moving all panic notifiers ahead of kdump. A missing image or failed trylock leaves callbacks uncalled; the shared guard skips callbacks already invoked by
panic().Signed-off-by Zack Rusin <[email protected]>---
New in v2: cover direct crash-kexec entry in a separate core patch.kernel/crash_core.c | 2 ++ 1 file changed, 2 insertions(+)kernel/crash_core.c +1
-0@@ -23,6 +23,7 @@#include <linux/objtool.h> #include <linux/delay.h> #include <linux/panic.h> +#include <linux/panic_notifier.h> #include <asm/page.h> #include <asm/sections.h>
kernel/crash_core.c void __noclone __crash_kexec(struct pt_regs *regs) · line 143
Quoted 4 lines
kernel/crash_core.c +1
-0@@ -139,6 +140,7 @@ void __noclone __crash_kexec(struct pt_regs *regs)struct pt_regs fixed_regs;crash_setup_regs (&fixed_regs, regs); +panic_notify_pre_kdump (NULL );
I understand why you did this. But it makes the code really hard to follow:
+ This code path will be called also by the 1st __crash_kexec() in
vpanic() when "_crash_kexec_post_notifiers == false". It is the
default. + The panic_notify_pre_kdump(buf) in vpanic(), added by 1st patch, is called when "_crash_kexec_post_notifiers == true" or when __crash_kexec() returns from some reason.
None of this is obvious.
I am going to think more about it.
Best Regards,
Petr
Quoted 3 lines
kernel/crash_core.c +0
-0crash_save_vmcoreinfo ();machine_crash_shutdown (&fixed_regs);crash_cma_clear_pending_dma ();
PATCH v2 3/6 panic: Allow postponing pre-kdump notifiers
In reply to Zack RusinProvide an escape hatch for debugging kdump failures that may involve pre-kdump callbacks. Add panic_pre_kdump_postpone to skip their early invocation in crash core without consuming the once-only guard.
When enabled, the chain runs before kdump only when crash_kexec_post_notifiers is also enabled. Leave the late panic call unchanged so callbacks remain eligible if that path is reached. Skipping the callbacks may prevent hypervisor crash handling.
---
New in v2: optional postponement policy suggested by Guilherme.
Documentation/admin-guide/kernel-parameters.txt | 14 ++++++++++++++ include/linux/panic_notifier.h | 1 + kernel/crash_core.c | 3 ++- kernel/panic.c | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +14 -0
@@ -4904,6 +4904,20 @@ Kernel parameters This option should only be used for systems with the above constraints as it might cause the panic operation to be less reliable. + panic_pre_kdump_postpone= + [KNL] Defer pre-kdump notifiers to the late panic path. + They run before kdump only when + crash_kexec_post_notifiers is also enabled. If panic + reaches the late path without entering kdump, they + can still run there. + Intended for debugging kexec/crash-dump failures. + Skipping these callbacks may prevent correct crash + handling by the hypervisor. + Format: <bool> + Default: 0 + Writable at runtime via + /sys/module/kernel/parameters/panic_pre_kdump_postpone. + panic_print= Bitmask for printing system info when panic happens. User can chose combination of the following bits:
include/linux/panic_notifier.h +1 -0
@@ -11,5 +11,6 @@ extern struct atomic_notifier_head panic_pre_kdump_list;void panic_notify_pre_kdump (char *msg);extern bool crash_kexec_post_notifiers; +extern bool panic_pre_kdump_postpone;#endif /* _LINUX_PANIC_NOTIFIERS_H */
kernel/crash_core.c +2 -1
@@ -140,7 +140,8 @@ void __noclone __crash_kexec(struct pt_regs *regs)struct pt_regs fixed_regs;crash_setup_regs (&fixed_regs, regs); -panic_notify_pre_kdump (NULL ); +if (!READ_ONCE (panic_pre_kdump_postpone)) +panic_notify_pre_kdump (NULL );crash_save_vmcoreinfo ();machine_crash_shutdown (&fixed_regs);crash_cma_clear_pending_dma ();
kernel/panic.c +2 -0
@@ -62,6 +62,7 @@ static int pause_on_oops;static int pause_on_oops_flag;static DEFINE_SPINLOCK (pause_on_oops_lock);bool crash_kexec_post_notifiers; +bool panic_pre_kdump_postpone;int panic_on_warn__read_mostly ;unsigned long panic_on_taint;bool panic_on_taint_nousertaint = false;
@@ -1243,6 +1244,7 @@ core_param(panic, panic_timeout, int, 0644);core_param (pause_on_oops, pause_on_oops, int,0644 );core_param (panic_on_warn, panic_on_warn, int,0644 );core_param (crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool,0644 ); +core_param (panic_pre_kdump_postpone, panic_pre_kdump_postpone, bool,0644 );core_param (panic_console_replay, panic_console_replay, bool,0644 );static int panic_print_set (const char *val,const struct kernel_param *kp)
[email protected]
AI reviewRe: [PATCH v2 3/6] panic: Allow postponing pre-kdump notifiers
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
Provide an escape hatch for debugging kdump failures that may involve pre-kdump callbacks. Add
panic_pre_kdump_postponeto skip their early invocation in crash core without consuming the once-only guard.
Quoted 8 lines
When enabled, the chain runs before kdump only when
crash_kexec_post_notifiersis also enabled. Leave the late panic call unchanged so callbacks remain eligible if that path is reached. Skipping the callbacks may prevent hypervisor crash handling.Suggested-by Guilherme G. Piccoli <[email protected]>Signed-off-by Zack Rusin <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v2 3/6] panic: Allow postponing pre-kdump notifiers
In reply to Zack RusinQuoted 12 lines · Zack Rusin
Provide an escape hatch for debugging kdump failures that may involve pre-kdump callbacks. Add
panic_pre_kdump_postponeto skip their early invocation in crash core without consuming the once-only guard.When enabled, the chain runs before kdump only when
crash_kexec_post_notifiersis also enabled. Leave the late panic call unchanged so callbacks remain eligible if that path is reached. Skipping the callbacks may prevent hypervisor crash handling.Suggested-by Guilherme G. Piccoli <[email protected]>Signed-off-by Zack Rusin <[email protected]>
Quoted 9 lines
---
New in v2: optional postponement policy suggested by Guilherme.Documentation/admin-guide/kernel-parameters.txt | 14 ++++++++++++++ include/linux/panic_notifier.h | 1 + kernel/crash_core.c | 3 ++- kernel/panic.c | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-)
Thanks for implementing this! It makes sense to me...though I have some "conflicting" comments in patch #2 heh
Cheers,
Guilherme
Re: [PATCH v2 3/6] panic: Allow postponing pre-kdump notifiers
In reply to Zack RusinQuoted 62 lines · Zack Rusin
Provide an escape hatch for debugging kdump failures that may involve pre-kdump callbacks. Add
panic_pre_kdump_postponeto skip their early invocation in crash core without consuming the once-only guard.When enabled, the chain runs before kdump only when
crash_kexec_post_notifiersis also enabled. Leave the late panic call unchanged so callbacks remain eligible if that path is reached. Skipping the callbacks may prevent hypervisor crash handling.Suggested-by Guilherme G. Piccoli <[email protected]>Signed-off-by Zack Rusin <[email protected]>---
New in v2: optional postponement policy suggested by Guilherme.Documentation/admin-guide/kernel-parameters.txt | 14 ++++++++++++++ include/linux/panic_notifier.h | 1 + kernel/crash_core.c | 3 ++- kernel/panic.c | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-)Documentation/admin-guide/kernel-parameters.txt +14
-0@@ -4904,6 +4904,20 @@ Kernel parameters This option should only be used for systems with the above constraints as it might cause the panic operation to be less reliable. + panic_pre_kdump_postpone= + [KNL] Defer pre-kdump notifiers to the late panic path. + They run before kdump only when + crash_kexec_post_notifiers is also enabled. If panic + reaches the late path without entering kdump, they + can still run there. + Intended for debugging kexec/crash-dump failures. + Skipping these callbacks may prevent correct crash + handling by the hypervisor. + Format: <bool> + Default: 0 + Writable at runtime via + /sys/module/kernel/parameters/panic_pre_kdump_postpone. + panic_print= Bitmask for printing system info when panic happens. User can chose combination of the following bits:include/linux/panic_notifier.h +1
-0@@ -11,5 +11,6 @@ extern struct atomic_notifier_head panic_pre_kdump_list;void panic_notify_pre_kdump (char *msg);extern bool crash_kexec_post_notifiers; +extern bool panic_pre_kdump_postpone;#endif /* _LINUX_PANIC_NOTIFIERS_H */ kernel/crash_core.c +0
-0
kernel/crash_core.c void __noclone __crash_kexec(struct pt_regs *regs) · line 144
Quoted 6 lines
kernel/crash_core.c +2
-1@@ -140,7 +140,8 @@ void __noclone __crash_kexec(struct pt_regs *regs)struct pt_regs fixed_regs;crash_setup_regs (&fixed_regs, regs); -panic_notify_pre_kdump (NULL ); +if (!READ_ONCE (panic_pre_kdump_postpone)) +panic_notify_pre_kdump (NULL );
Honestly, it looks a bit confusing to me.
The name "postpone" suggests that they will be called later. But they likely will never be called because the crash kernel will take over the control and eventually reboot the system. The panic() path will never run.
Also there is:
void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
{
if (regs && kexec_should_crash(current))
crash_kexec(regs);where
int kexec_should_crash(struct task_struct *p)
{
/*
* If crash_kexec_post_notifiers is enabled, don't run
* crash_kexec() here yet, which must be run after panic
* notifiers in panic().
*/
if (crash_kexec_post_notifiers)
return 0;So, when: "crash_kexec_post_notifiers == true" then kexec_should_crash() returns "0" thencrash_exec() is not called. The system might still call panic() but remember "crash_kexec_post_notifiers == true" so the notifiers are called before __crash_kexec(). So panic_notify_pre_kdump() will still get called before __crash_exec().
Is this intended, please?
What is use case, please?
Maybe, it would make sense to add "panic_pre_kdump_disable" which would completely disable the notifiers when they cause problems.
Best Regards,
Petr
PATCH v2 4/6 x86/vmware: Add a bounded pre-kdump log sender
In reply to Zack RusinPreserve the newest kernel log tail in the host's vmware.log, which can outlive a guest with no working userspace or persistent storage.
Allocate an 8 KiB buffer during early init and register on panic_pre_kdump_list. A 4 KiB buffer can omit useful stack-trace context. Use a fixed byte budget so transfer work does not scale with PAGE_SIZE.
Copy the newest records, prefix them with "log ", and send one RPC over the low-bandwidth register interface. Bound the transfer to 8 KiB and at most three checkpoint attempts; zero-fill a partial payload word and close the channel after every successful open.
The callback allocates nothing and emits no printk messages. Enable it for ordinary guests, leaving encrypted guests disabled until explicitly enabled by the sysctl. Skip initialization without printk support, and leave logging disabled after allocation or registration failure.
---
v2: use the pre-kdump notifier, establish safe guest defaults, and increase the fixed buffer to 8 KiB as Michael suggested. Maaz's v1 Reviewed-by is omitted for renewed review of the new callback.
arch/x86/include/asm/vmware.h | 1 + arch/x86/kernel/cpu/vmware.c | 173 ++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+)
arch/x86/include/asm/vmware.h +1 -0
@@ -57,6 +57,7 @@#define VMWARE_HYPERVISOR_MAGIC 0x564d5868U#define VMWARE_CMD_GETVERSION 10 +#define VMWARE_CMD_MESSAGE 30#define VMWARE_CMD_GETHZ 45#define VMWARE_CMD_GETVCPU_INFO 68#define VMWARE_CMD_STEALCLOCK 91
arch/x86/kernel/cpu/vmware.c +173 -0
202 lines not on this page · raw message
[email protected]
AI reviewRe: [PATCH v2 4/6] x86/vmware: Add a bounded pre-kdump log sender
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 18 lines
Preserve the newest kernel log tail in the host's vmware.log, which can outlive a guest with no working userspace or persistent storage.
Allocate an 8 KiB buffer during early init and register on
panic_pre_kdump_list. A 4 KiB buffer can omit useful stack-trace context. Use a fixed byte budget so transfer work does not scale withPAGE_SIZE.Copy the newest records, prefix them with "log ", and send one RPC over the low-bandwidth register interface. Bound the transfer to 8 KiB and at most three checkpoint attempts; zero-fill a partial payload word and close the channel after every successful open.
The callback allocates nothing and emits no printk messages. Enable it for ordinary guests, leaving encrypted guests disabled until explicitly enabled by the sysctl. Skip initialization without printk support, and leave logging disabled after allocation or registration failure.
Quoted 8 lines
Suggested-by Michael Kelley <[email protected]>Link https://lore.kernel.org/r/SN6PR02MB41574A11D309A0530C63E0FED4842@SN6PR02MB4157.namprd02.prod.outlook.com open hereCo-developed-by Bo Gan <[email protected]>Signed-off-by Bo Gan <[email protected]>Co-developed-by Alexey Makhalov <[email protected]>Signed-off-by Alexey Makhalov <[email protected]>Signed-off-by Zack Rusin <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH v2 5/6 x86/vmware: Add the vmware_record_panic_msg sysctl
In reply to Zack RusinAllow administrators to disable host log transfer on ordinary guests or opt in on encrypted guests. Expose the boolean recording policy through kernel.vmware_record_panic_msg using proc_dobool(), as Joel suggested. Zero disables recording, nonzero integers enable it, and reads return 0 or 1.
Register the sysctl only after the logger is ready. A registration failure leaves the internal default in force. Document that disabling the old post-notifier ordering does not disable this independent logger.
---
v2: use bool/proc_dobool as Joel requested; document direct crash entry. Maaz's v1 Reviewed-by is omitted for renewed review of the changed sysctl.
Documentation/admin-guide/sysctl/kernel.rst | 20 ++++++++++++++++++++ arch/x86/kernel/cpu/vmware.c | 15 +++++++++++++++ 2 files changed, 35 insertions(+)
Documentation/admin-guide/sysctl/kernel.rst +20 -0
@@ -1690,6 +1690,26 @@ entry will default to 2 instead of 0. = ============================================================= +vmware_record_panic_msg +====================== + +Controls whether panic or fatal-oops kmsg data is written to the host's +``vmware.log`` before kdump. This setting does not control the separate +VMware guest-crash event. Writing zero disables recording; writing a +nonzero integer enables it. Reads return 0 or 1. + += ============================================================== +0 Do not write kmsg data to ``vmware.log``. This is the default + for encrypted guests. +1 Write kmsg data to ``vmware.log``. This is the default for + ordinary guests. += ============================================================== + +``crash_kexec_post_notifiers=0`` alone does not disable this logger. +``panic_pre_kdump_postpone=1`` skips early logging but leaves late panic +logging eligible; set this sysctl to 0 to disable both. + + warn_limit ==========
arch/x86/kernel/cpu/vmware.c +15 -0
@@ -33,6 +33,7 @@#include <linux/reboot.h> #include <linux/sizes.h> #include <linux/static_call.h> +#include <linux/sysctl.h> #include <linux/wordpart.h> #include <linux/sched/cputime.h> #include <asm/div64.h>
@@ -260,6 +261,16 @@ static int vmware_log_rpc(const char *buffer, size_t length)static struct page *vmware_panic_page;static bool vmware_record_panic_msg; +static const struct ctl_table vmware_panic_sysctls[] = { + { + .procname ="vmware_record_panic_msg" , + .data = &vmware_record_panic_msg, + .maxlen =sizeof (vmware_record_panic_msg), + .mode =0644 , + .proc_handler = proc_dobool, + }, +}; +static int vmware_panic_log_notify (struct notifier_block *nb,unsigned long action,void *data) {
@@ -311,6 +322,10 @@ static int __init vmware_panic_log_init(void) vmware_panic_page =NULL ; } +if (vmware_panic_page &&IS_ENABLED (CONFIG_SYSCTL ) && + !register_sysctl ("kernel" , vmware_panic_sysctls)) +pr_err ("failed to register panic log sysctl\n" ); +return 0 ; }early_initcall (vmware_panic_log_init);
[email protected]
AI reviewRe: [PATCH v2 5/6] x86/vmware: Add the vmware_record_panic_msg sysctl
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] doc: rST title underline too short for vmware_record_panic_msg --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] doc: rST title underline too short for vmware_record_panic_msg
--
commit c541f42ddd949c322e4b6facb84fc17737ed184a
Author: Zack Rusin <[email protected]>
x86/vmware: Add the vmware_record_panic_msg sysctl
This commit adds a new sysctl kernel.vmware_record_panic_msg to control whether panic or fatal-oops data is written to the host log before kdump. It allows administrators to configure this logging behavior depending on guest encryption, and defers sysctl registration until the logger is ready.
Quoted 4 lines
Documentation/admin-guide/sysctl/kernel.rst +0
-0
[ ... ]
Documentation/admin-guide/sysctl/kernel.rst entry will default to 2 instead of 0. · line 1694
Quoted 6 lines
Documentation/admin-guide/sysctl/kernel.rst +2
-0@@ -1690,6 +1690,26 @@ entry will default to 2 instead of 0. = ============================================================= +vmware_record_panic_msg +======================
[Severity: Low]
Is the underline for this section title one character too short?
The title vmware_record_panic_msg is 23 characters long, but the underline is only 22 characters long. In reStructuredText, the underline must be at least as long as the text it underlines, so this regression will trigger a warning during Sphinx documentation builds.
Quoted 3 lines
Documentation/admin-guide/sysctl/kernel.rst +3
-0+ +Controls whether panic or fatal-oops kmsg data is written to the host's +``vmware.log`` before kdump. This setting does not control the separate
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH v2 6/6 x86/vmware: Report guest crashes after kmsg dumpers
In reply to Zack RusinVMware accepts a structured guest-crash event, but a host configured with backdoor.coredumpOnCrash may terminate the VM before the hypercall returns. Keep this event separate from the pre-kdump log sender.
Register a panic-only kmsg dumper with late_initcall_sync(), after built-in dumpers registered by then. Skip the event while a crash kernel is loaded so the host cannot terminate the guest before kdump saves its vmcore.
Issue the event at most once. With CONFIG_PRINTK=n, use a late INT_MIN panic notifier. An unexpected dumper registration failure with printk enabled leaves reporting disabled rather than overtaking working dumpers.
---
v2: keep the terminating event separate from the pre-kdump logger. Maaz's v1 Reviewed-by is omitted for renewed review of the new ordering.
arch/x86/include/asm/vmware.h | 1 + arch/x86/kernel/cpu/vmware.c | 62 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
arch/x86/include/asm/vmware.h +1 -0
@@ -61,6 +61,7 @@#define VMWARE_CMD_GETHZ 45#define VMWARE_CMD_GETVCPU_INFO 68#define VMWARE_CMD_STEALCLOCK 91 +#define VMWARE_CMD_REPORTGUESTCRASH 102/* * Hypercall command mask: * bits [6:0] command, range [0, 127]
arch/x86/kernel/cpu/vmware.c +62 -0
77 lines not on this page · raw message
[email protected]
AI reviewRe: [PATCH v2 6/6] x86/vmware: Report guest crashes after kmsg dumpers
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 12 lines
VMware accepts a structured guest-crash event, but a host configured with backdoor.coredumpOnCrash may terminate the VM before the hypercall returns. Keep this event separate from the pre-kdump log sender.
Register a panic-only kmsg dumper with
late_initcall_sync(), after built-in dumpers registered by then. Skip the event while a crash kernel is loaded so the host cannot terminate the guest before kdump saves its vmcore.Issue the event at most once. With
CONFIG_PRINTK=n, use a lateINT_MINpanic notifier. An unexpected dumper registration failure with printk enabled leaves reporting disabled rather than overtaking working dumpers.
Quoted 6 lines
Co-developed-by Brennan Lamoreaux <[email protected]>Signed-off-by Brennan Lamoreaux <[email protected]>Co-developed-by Alexey Makhalov <[email protected]>Signed-off-by Alexey Makhalov <[email protected]>Signed-off-by Zack Rusin <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Quoted 41 lines · Zack Rusin
A VMware guest may have no persistent storage or working userspace after a crash. Preserve its newest kernel log tail in the host's vmware.log before entering kdump, without enabling every panic notifier by default.
Following Petr's suggestion, add one generic
panic_pre_kdump_listwith VMware as its first client. A set-once helper coverspanic()and direct crash-kexec entry. Fatal oopses can reach kdump without callingpanic(), so patch 2 adds that call after capturing the original registers under the existing kexec lock. The late panic call followssys_info()and precedes the kmsg dumpers.Patch 3 adds Guilherme's suggested escape hatch for debugging kdump failures involving early callbacks. With
panic_pre_kdump_postponeset, the list runs before kdump only whencrash_kexec_post_notifiersis also set. This can omit hypervisor crash handling as well as diagnostics. The late panic call remains eligible. This policy is a separate patch; I can omit patch 3 if it is not wanted.The logger preallocates an 8 KiB buffer and bounds its register-based RPC transfer and retries. Michael suggested increasing the buffer because 4 KiB can omit useful stack-trace context. Ordinary guests enable logging by default; encrypted guests must opt in. Use bool/proc_dobool for the sysctl as Joel requested. The potentially terminating REPORTGUESTCRASH event remains a separate late dumper, suppressed whenever a crash image is loaded. The v1 assignment to
crash_kexec_post_notifiersis dropped.Tested on VMware Workstation and ESXi with ordinary guests, and on ESXi with SEV-SNP and TDX guests.
v1:
https://lore.kernel.org/r/[email protected]Zack Rusin (6):
panic: Add a notifier chain for pre-kdump callbacks
crash: Notify pre-kdump callbacks before switching kernels
panic: Allow postponing pre-kdump notifiers x86/vmware: Add a bounded pre-kdump log sender x86/vmware: Add thevmware_record_panic_msgsysctl x86/vmware: Report guest crashes after kmsg dumpers
Quoted 9 lines
.../admin-guide/kernel-parameters.txt | 14 + Documentation/admin-guide/sysctl/kernel.rst | 20 ++ arch/x86/include/asm/vmware.h | 2 + arch/x86/kernel/cpu/vmware.c | 250 ++++++++++++++++++ include/linux/panic_notifier.h | 4 + kernel/crash_core.c | 3 + kernel/panic.c | 28 ++ 7 files changed, 321 insertions(+)
All the panic changes and crash_core changes looks good to me!
Tested basic panic calls with Power10, in courtesy of osuosl:
Quoted 181 lines
base-commit:
fd73f4a6659897191fa0d40695fe370925dd3780From mboxrd@z Thu Jan 1 00:00:00 1970
Received: from mail-pj1-f100.google.com (mail-pj1-f100.google.com [209.85.216.100])(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83AF64E3243 for <[email protected]>; Mon, 28 Sep 2026 17:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790618169; cv=none; b=b4BojE7kyzKnMqCq3yQBsgTjfamCuHeSPBiM3mTeE4v6X5jd8GsgUy8HFjfb6vnu2FsurVAocpFTMaJi8sVvzC7bBtKNDJpFDvZCNqdO4XHY7wznbp2hC1z0LbTBYGMbRHtCk4LvgNFrpWDHzU9DrGZf+1d8PQJtrrUWMR3fWB8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790618169; c=relaxed/simple; bh=qHuvSTbzKTQ99mPQxhPgubTCtOl/pceEwTRUqIC9LiU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FTXEgGo9/aZOjjBWf/3/aJE9bzE1CX9s/OSrb2hi9L/KTuxvuIv8F7B18Mj6GgYbZIaXobZhtwozeHdFf9pWY4NmLIXIxMlQiB06cvRkp4UYghm/h3KZ3r3B3EPB6W4Zm/qFIUpvsrOcMQBhLX0ulM1Nh7jAkRnR5+Dr4TccEps=ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass
(p=reject dis=none) header.from=broadcom.com; spf=fail
smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com [email protected] header.b=AMSyqTvg; arc=none
smtp.client-ip=209.85.216.100
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com
Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (1024-bit key) header.d=broadcom.com [email protected] header.b="AMSyqTvg"
Received: by mail-pj1-f100.google.com with SMTP id 98e67ed59e1d1-39647aa9d52so87593a91.0for <[email protected]>; Mon, 28 Sep 2026 10:56:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790618168; x=1791222968; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=KmmJxySPwG38CbqK+KUDBFApZhpWarF4JpRDp51PqIc=; b=Jpd/MIj5ewElR34jOfbzVz6y0phWWOuuetH2AMAqSfkw9wo88gnxd8iiGSrwGXb/K8 LxiFGW7Gk1/qfXeNKTtiT3pDkujiBk8rYb2hZ9gxVSorRYSYgPAO2EL16XTvbxLgG6YK 3FeqkS0hVSU1tdYNfgmZnbEIc2b/RyU4JI14RYidz/e/0W5GCoeMbf3A5MEjESY87AVb Nmwd7ohydW1mz6nApfHFyC6Dnyk8weLtbSVES1jsgb3+ivuTwzujcnvHLoxLcTveo38M /QCQT4LKda0z3bTRNmSUIPrz9XLziXq3W4D3R+fZgS7Ae1bSJihAy/CQ8TsXISh1sea3 /Y5g==X-Forwarded-Encrypted: i=1; AKwUvBz1cco3gfH83tEf5iTZWgGV7lvOGVAz8sAyGJ4O8VTok46+5cEwqveCnVBIA8QHt65rA8D83p9YKyk=@vger.kernel.org
X-Gm-Message-State: AFq9FYJJ9fgQVETjiY5fbRpzunCNQ3yHlKk8Ilzj81eoAlnuoS+Dn0Ka
McHcsKEBsXysl0ErYrd3UsPTH5PvX2dq9oZLqcmv4M1H2ZZYdezUd/B+B5ApLoXVYyVqwwaKkn1 WhxVmBuVCVdWdMiAn3Vi6H3YMgDwkYBQIrAbekUmKYvA8WvWr8eMC191fp1XiUxJ6rhpIfeSsVp NTAsl3Yon3avlK5XQfKHI5gtnaNCTFriKugUOmHPEPXyu8F41SwzaOR5uWzC+zjBz4Vodbmgspr
ROsqbvKBTG0
X-Gm-Gg: AYBFou2P8ZN7jxBSC+9O6FmDIlcBFoArokAtaD0KOTfPh/dbNfovO55NTXigG/qTx0i
zW8kFxJ9y8047OYcs7z6GR/iFk/FwAFBB5zgqFHnosJpMNBIX2v+4Kwpu9gjKkmULOJP4mIajIu dJfq/+pAXglXwFTJ+9jxVi8wPktojt/Kb99zzSZdC2pJZ1qGv0VNdQR3aD5YFUJSBFcy3BkabjL sk1IZGxFfeKEGoAO9jrL5qKeIm3f6Ql5otkpaV9x52hh1iOyQ0Xd1UFFrUB+dYPtR6W5bYD0hSO 5TbTBiupR7Fk/TU3eH1D3LCTwxJdUmWXGODfhDogaAZUtfuQraIYelR1Lue5OSP5fGKHMw5FPyo iFEAWZ+eQ1MJmXkr4N/LcVUr5vNjYToRFimPtfJQ430PQig2taOVcTvxn7B2m7O6JMTg8qajAW3 a/HyZmBnzcwByWASw8uS+bX2LuCwxtV9OOX-Received: by 2002:a17:90b:28c6:b0:3a0:34a4:187e with SMTP id 98e67ed59e1d1-3a49c120f78mr7983a91.15.1790618167517; Mon, 28 Sep 2026 10:56:07 -0700 (PDT) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-18.dlp.protect.broadcom.com. [144.49.247.18]) by smtp-relay.gmail.com with ESMTPS id 98e67ed59e1d1-3a498e35c74sm34226a91.3.2026.09.28.10.56.00 for <[email protected]> (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Sep 2026 10:56:07 -0700 (PDT) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-3282d5302ffso156936eec.1 for <[email protected]>; Mon, 28 Sep 2026 10:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1790618159; x=1791222959; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=KmmJxySPwG38CbqK+KUDBFApZhpWarF4JpRDp51PqIc=; b=AMSyqTvg7YOAaOo4sIAY0pcRYwHSW0cH09GjKbqzO4apiMMUre94O+4j1U12+P2RKc thNFz4BDgQu1JWPb2Prmfj0x/3+gp1f5TNhwJdRBccsEH9Kg8d61iKzddQPkLXzvvA2Y czPVjFz5/L4SBh9PoEC0hHpQAKBZzbU0jsBOo= X-Forwarded-Encrypted: i=1; AKwUvBzwJDvlo2QB15OMSgAG9uvXCCuZffODLbFe+C46K/[email protected] X-Received: by 2002:a05:7022:ff49:b0:13c:e1e2:fc86 with SMTP id a92af1059eb24-14b2d993e47mr201594c88.4.1790618159182; Mon, 28 Sep 2026 10:55:59 -0700 (PDT) X-Received: by 2002:a05:7022:ff49:b0:13c:e1e2:fc86 with SMTP id a92af1059eb24-14b2d993e47mr201547c88.4.1790618158548; Mon, 28 Sep 2026 10:55:58 -0700 (PDT) Received: from vertex.localdomain ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3421dbb2971sm26076069eec.10.2026.09.28.10.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 10:55:57 -0700 (PDT)From: Zack Rusin <[email protected]>
To: Andrew Morton <[email protected]>,
Petr Mladek <[email protected]>,
Baoquan He <[email protected]>,
Mike Rapoport <[email protected]>,
Pasha Tatashin <[email protected]>,
Pratyush Yadav <[email protected]>,
Dave Young <[email protected]>
Cc: Borislav Petkov <[email protected]>,
Ajay Kaher <[email protected]>,
Alexey Makhalov <[email protected]>, [email protected],
Joel Granados <[email protected]>,
Thomas Gleixner <[email protected]>,
Ingo Molnar <[email protected]>,
Dave Hansen <[email protected]>,
"H. Peter Anvin" <[email protected]>, [email protected], [email protected], [email protected],
John Ogness <[email protected]>,
Steven Rostedt <[email protected]>,
Sergey Senozhatsky <[email protected]>,
Kees Cook <[email protected]>,
Jonathan Corbet <[email protected]>,
Bo Gan <[email protected]>,
Brennan Lamoreaux <[email protected]>, [email protected],
[email protected],
"Guilherme G. Piccoli" <[email protected]>,
Maaz Mombasawala <[email protected]>,
Shuah Khan <[email protected]>,
Randy Dunlap <[email protected]>,
Stephen Brennan <[email protected]>,
Michael Kelley <[email protected]>,
Ian Forbes <[email protected]>
Subject: [PATCH v2 0/6] panic, x86/vmware: Preserve crash logs before kdump
Date: Mon, 28 Sep 2026 13:55:34 -0400
Message-ID: <[email protected]>
X-Mailer: git-send-email 2.53.0
Precedence: bulk
X-Mailing-List: [email protected]
List-Id: <linux-doc.vger.kernel.org>
List-Subscribe: <mailto:[email protected]>
List-Unsubscribe: <mailto:[email protected]>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5eA VMware guest may have no persistent storage or working userspace after a crash. Preserve its newest kernel log tail in the host's vmware.log before entering kdump, without enabling every panic notifier by default.
Following Petr's suggestion, add one generic
panic_pre_kdump_listwith VMware as its first client. A set-once helper coverspanic()and direct crash-kexec entry. Fatal oopses can reach kdump without callingpanic(), so patch 2 adds that call after capturing the original registers under the existing kexec lock. The late panic call followssys_info()and precedes the kmsg dumpers.Patch 3 adds Guilherme's suggested escape hatch for debugging kdump failures involving early callbacks. With
panic_pre_kdump_postponeset, the list runs before kdump only whencrash_kexec_post_notifiersis also set. This can omit hypervisor crash handling as well as diagnostics. The late panic call remains eligible. This policy is a separate patch; I can omit patch 3 if it is not wanted.The logger preallocates an 8 KiB buffer and bounds its register-based RPC transfer and retries. Michael suggested increasing the buffer because 4 KiB can omit useful stack-trace context. Ordinary guests enable logging by default; encrypted guests must opt in. Use bool/proc_dobool for the sysctl as Joel requested. The potentially terminating REPORTGUESTCRASH event remains a separate late dumper, suppressed whenever a crash image is loaded. The v1 assignment to
crash_kexec_post_notifiersis dropped.Tested on VMware Workstation and ESXi with ordinary guests, and on ESXi with SEV-SNP and TDX guests.
v1:
https://lore.kernel.org/r/[email protected]Zack Rusin (6):
panic: Add a notifier chain for pre-kdump callbacks
crash: Notify pre-kdump callbacks before switching kernels
panic: Allow postponing pre-kdump notifiers x86/vmware: Add a bounded pre-kdump log sender x86/vmware: Add thevmware_record_panic_msgsysctl x86/vmware: Report guest crashes after kmsg dumpers.../admin-guide/kernel-parameters.txt | 14 + Documentation/admin-guide/sysctl/kernel.rst | 20 ++ arch/x86/include/asm/vmware.h | 2 + arch/x86/kernel/cpu/vmware.c | 250 ++++++++++++++++++ include/linux/panic_notifier.h | 4 + kernel/crash_core.c | 3 + kernel/panic.c | 28 ++ 7 files changed, 321 insertions(+)
Quoted 3 lines
base-commit:
fd73f4a6659897191fa0d40695fe370925dd3780
--- Thanks!
"I'm not a very positive person" - Linus torvalds
Quoted 54 lines · Bradley Morgan
Quoted 41 lines · Zack Rusin
A VMware guest may have no persistent storage or working userspace after a crash. Preserve its newest kernel log tail in the host's vmware.log before entering kdump, without enabling every panic notifier by default.
Following Petr's suggestion, add one generic
panic_pre_kdump_listwith VMware as its first client. A set-once helper coverspanic()and direct crash-kexec entry. Fatal oopses can reach kdump without callingpanic(), so patch 2 adds that call after capturing the original registers under the existing kexec lock. The late panic call followssys_info()and precedes the kmsg dumpers.Patch 3 adds Guilherme's suggested escape hatch for debugging kdump failures involving early callbacks. With
panic_pre_kdump_postponeset, the list runs before kdump only whencrash_kexec_post_notifiersis also set. This can omit hypervisor crash handling as well as diagnostics. The late panic call remains eligible. This policy is a separate patch; I can omit patch 3 if it is not wanted.The logger preallocates an 8 KiB buffer and bounds its register-based RPC transfer and retries. Michael suggested increasing the buffer because 4 KiB can omit useful stack-trace context. Ordinary guests enable logging by default; encrypted guests must opt in. Use bool/proc_dobool for the sysctl as Joel requested. The potentially terminating REPORTGUESTCRASH event remains a separate late dumper, suppressed whenever a crash image is loaded. The v1 assignment to
crash_kexec_post_notifiersis dropped.Tested on VMware Workstation and ESXi with ordinary guests, and on ESXi with SEV-SNP and TDX guests.
v1:
https://lore.kernel.org/r/[email protected]Zack Rusin (6):
panic: Add a notifier chain for pre-kdump callbacks
crash: Notify pre-kdump callbacks before switching kernels
panic: Allow postponing pre-kdump notifiers x86/vmware: Add a bounded pre-kdump log sender x86/vmware: Add thevmware_record_panic_msgsysctl x86/vmware: Report guest crashes after kmsg dumpersQuoted 9 lines
.../admin-guide/kernel-parameters.txt | 14 + Documentation/admin-guide/sysctl/kernel.rst | 20 ++ arch/x86/include/asm/vmware.h | 2 + arch/x86/kernel/cpu/vmware.c | 250 ++++++++++++++++++ include/linux/panic_notifier.h | 4 + kernel/crash_core.c | 3 + kernel/panic.c | 28 ++ 7 files changed, 321 insertions(+)
Quoted 7 lines
All the panic changes and
crash_corechanges looks good to me!Reviewed-by Bradley Morgan <[email protected]>Tested basic panic calls with Power10, in courtesy of osuosl:
Thank you for testing!
Petr, do you have any thoughts? I think this version addresses all of your concerns/suggestions from v1.
z