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