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