1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_PANIC_H
3 #define _LINUX_PANIC_H
4 
5 #include <linux/compiler_attributes.h>
6 #include <linux/types.h>
7 
8 struct pt_regs;
9 
10 extern long (*panic_blink)(int state);
11 __printf(1, 2)
12 void panic(const char *fmt, ...) __noreturn __cold;
13 void nmi_panic(struct pt_regs *regs, const char *msg);
14 extern void oops_enter(void);
15 extern void oops_exit(void);
16 extern bool oops_may_print(void);
17 
18 extern int panic_timeout;
19 extern unsigned long panic_print;
20 extern int panic_on_oops;
21 extern int panic_on_unrecovered_nmi;
22 extern int panic_on_io_nmi;
23 extern int panic_on_warn;
24 
25 extern unsigned long panic_on_taint;
26 extern bool panic_on_taint_nousertaint;
27 
28 extern int sysctl_panic_on_rcu_stall;
29 extern int sysctl_max_rcu_stall_to_panic;
30 extern int sysctl_panic_on_stackoverflow;
31 
32 extern bool crash_kexec_post_notifiers;
33 
34 /*
35  * panic_cpu is used for synchronizing panic() and crash_kexec() execution. It
36  * holds a CPU number which is executing panic() currently. A value of
37  * PANIC_CPU_INVALID means no CPU has entered panic() or crash_kexec().
38  */
39 extern atomic_t panic_cpu;
40 #define PANIC_CPU_INVALID	-1
41 
42 /*
43  * Only to be used by arch init code. If the user over-wrote the default
44  * CONFIG_PANIC_TIMEOUT, honor it.
45  */
set_arch_panic_timeout(int timeout,int arch_default_timeout)46 static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout)
47 {
48 	if (panic_timeout == arch_default_timeout)
49 		panic_timeout = timeout;
50 }
51 
52 /* This cannot be an enum because some may be used in assembly source. */
53 #define TAINT_PROPRIETARY_MODULE	0
54 #define TAINT_FORCED_MODULE		1
55 #define TAINT_CPU_OUT_OF_SPEC		2
56 #define TAINT_FORCED_RMMOD		3
57 #define TAINT_MACHINE_CHECK		4
58 #define TAINT_BAD_PAGE			5
59 #define TAINT_USER			6
60 #define TAINT_DIE			7
61 #define TAINT_OVERRIDDEN_ACPI_TABLE	8
62 #define TAINT_WARN			9
63 #define TAINT_CRAP			10
64 #define TAINT_FIRMWARE_WORKAROUND	11
65 #define TAINT_OOT_MODULE		12
66 #define TAINT_UNSIGNED_MODULE		13
67 #define TAINT_SOFTLOCKUP		14
68 #define TAINT_LIVEPATCH			15
69 #define TAINT_AUX			16
70 #define TAINT_RANDSTRUCT		17
71 #define TAINT_FLAGS_COUNT		18
72 #define TAINT_FLAGS_MAX			((1UL << TAINT_FLAGS_COUNT) - 1)
73 
74 struct taint_flag {
75 	char c_true;	/* character printed when tainted */
76 	char c_false;	/* character printed when not tainted */
77 	bool module;	/* also show as a per-module taint flag */
78 };
79 
80 extern const struct taint_flag taint_flags[TAINT_FLAGS_COUNT];
81 
82 enum lockdep_ok {
83 	LOCKDEP_STILL_OK,
84 	LOCKDEP_NOW_UNRELIABLE,
85 };
86 
87 extern const char *print_tainted(void);
88 extern void add_taint(unsigned flag, enum lockdep_ok);
89 extern int test_taint(unsigned flag);
90 extern unsigned long get_taint(void);
91 
92 #endif	/* _LINUX_PANIC_H */
93