misc: pvpanic: add crash loaded event
v2 cover misc: pvpanic: add crash loaded event
Add PVPANIC_CRASH_LOADED bit for pvpanic event, it means that guest kernel actually hit a kernel panic, but the guest kernel wants to handle by itself.
Suggested by Greg KH, move the bit definition to uapi header file for the programs outside of kernel.
zhenwei pi (2):
misc: pvpanic: move bit definition to uapi header file
misc: pvpanic: add crash loaded event
drivers/misc/pvpanic.c | 12 +++++++++--- include/uapi/misc/pvpanic.h | 9 +++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 include/uapi/misc/pvpanic.h
Signature · 1 line
2.11.0
PATCH v2 1/2 misc: pvpanic: move bit definition to uapi header file
Some processes outside of the kernel(Ex, QEMU) should know what the value really is for, so move the bit definition to a uapi file.
--- drivers/misc/pvpanic.c | 3 +-- include/uapi/misc/pvpanic.h | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 include/uapi/misc/pvpanic.h
drivers/misc/pvpanic.c +1 -2
@@ -15,11 +15,10 @@#include <linux/of_address.h> #include <linux/platform_device.h> #include <linux/types.h> +#include <uapi/misc/pvpanic.h> static void __iomem *base; -#define PVPANIC_PANICKED (1 << 0) -MODULE_AUTHOR ("Hu Tao <[email protected]>" );MODULE_DESCRIPTION ("pvpanic device driver" );MODULE_LICENSE ("GPL" );
include/uapi/misc/pvpanic.h new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ + +#ifndef __PVPANIC_H__ +#define __PVPANIC_H__ + +#define PVPANIC_PANICKED (1 << 0) + +#endif /* __PVPANIC_H__ */
Signature · 1 line
2.11.0
PATCH v2 2/2 misc: pvpanic: add crash loaded event
In reply to zhenwei piSome users prefer kdump tools to generate guest kernel dumpfile, at the same time, need a out-of-band kernel panic event.
Currently if booting guest kernel with 'crash_kexec_post_notifiers', QEMU will receive PVPANIC_PANICKED event and stop VM. If booting guest kernel without 'crash_kexec_post_notifiers', guest will not call notifier chain.
Add PVPANIC_CRASH_LOADED bit for pvpanic event, it means that guest kernel actually hit a kernel panic, but the guest kernel wants to handle by itself.
--- drivers/misc/pvpanic.c | 9 ++++++++- include/uapi/misc/pvpanic.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/misc/pvpanic.c +8 -1
@@ -10,6 +10,7 @@#include <linux/acpi.h> #include <linux/kernel.h> +#include <linux/kexec.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_address.h>
@@ -33,7 +34,13 @@ static int pvpanic_panic_notify(struct notifier_block *nb, unsigned long code, void *unused) { -pvpanic_send_event (PVPANIC_PANICKED); + unsigned int event = PVPANIC_PANICKED; + +if (kexec_crash_loaded ()) + event =PVPANIC_CRASH_LOADED ; + +pvpanic_send_event (event); +return NOTIFY_DONE ; }
include/uapi/misc/pvpanic.h +1 -0
@@ -4,5 +4,6 @@#define __PVPANIC_H__#define PVPANIC_PANICKED (1 << 0) +#define PVPANIC_CRASH_LOADED (1 << 1)#endif /* __PVPANIC_H__ */
Signature · 1 line
2.11.0