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