Skip to contentSkip to conversation

misc: pvpanic: add crash loaded event

PATCH New zhenwei pi 1 participant 3 messages Jan 2, 2020 Char and misc drivers

lore
Share & tools
lore

zhenwei pi

author
#0 lore raw

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
author
#1 lore raw

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
index 95ff7c5a1dfb..3f0de3be0a19 100644
@@ -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
new file mode 100644
index 000000000000..cae69a822b25
@@ -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
author
#2 lore raw

PATCH v2 2/2 misc: pvpanic: add crash loaded event

In reply to zhenwei pi

Some 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
index 3f0de3be0a19..a6e1a8983e1f 100644
@@ -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
index cae69a822b25..54b7485390d3 100644
@@ -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