Skip to content

Commit e88043c

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
rv/reactor: Add the panic reactor
Sample reactor that panics the system when an exception is found. This is useful both to capture a vmcore, or to fail-safe a critical system. Link: https://lkml.kernel.org/r/729aae3aba95f35738b8f8180e626d747d1d9da2.1659052063.git.bristot@kernel.org Cc: Wim Van Sebroeck <[email protected]> Cc: Guenter Roeck <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Will Deacon <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Marco Elver <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Gabriele Paoloni <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Clark Williams <[email protected]> Cc: Tao Zhou <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 135b881 commit e88043c

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

kernel/trace/rv/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,11 @@ config RV_REACT_PRINTK
6868
help
6969
Enables the printk reactor. The printk reactor emits a printk()
7070
message if an exception is found.
71+
72+
config RV_REACT_PANIC
73+
bool "Panic reactor"
74+
depends on RV_REACTORS
75+
default y
76+
help
77+
Enables the panic reactor. The panic reactor emits a printk()
78+
message if an exception is found and panic()s the system.

kernel/trace/rv/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ obj-$(CONFIG_RV_MON_WIP) += monitors/wip/wip.o
55
obj-$(CONFIG_RV_MON_WWNR) += monitors/wwnr/wwnr.o
66
obj-$(CONFIG_RV_REACTORS) += rv_reactors.o
77
obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o
8+
obj-$(CONFIG_RV_REACT_PANIC) += reactor_panic.o

kernel/trace/rv/reactor_panic.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (C) 2019-2022 Red Hat, Inc. Daniel Bristot de Oliveira <[email protected]>
4+
*
5+
* Panic RV reactor:
6+
* Prints the exception msg to the kernel message log and panic().
7+
*/
8+
9+
#include <linux/ftrace.h>
10+
#include <linux/tracepoint.h>
11+
#include <linux/kernel.h>
12+
#include <linux/module.h>
13+
#include <linux/init.h>
14+
#include <linux/rv.h>
15+
16+
static void rv_panic_reaction(char *msg)
17+
{
18+
panic(msg);
19+
}
20+
21+
static struct rv_reactor rv_panic = {
22+
.name = "panic",
23+
.description = "panic the system if an exception is found.",
24+
.react = rv_panic_reaction
25+
};
26+
27+
static int register_react_panic(void)
28+
{
29+
rv_register_reactor(&rv_panic);
30+
return 0;
31+
}
32+
33+
static void unregister_react_panic(void)
34+
{
35+
rv_unregister_reactor(&rv_panic);
36+
}
37+
38+
module_init(register_react_panic);
39+
module_exit(unregister_react_panic);
40+
41+
MODULE_LICENSE("GPL");
42+
MODULE_AUTHOR("Daniel Bristot de Oliveira");
43+
MODULE_DESCRIPTION("panic rv reactor: panic if an exception is found.");

0 commit comments

Comments
 (0)