panic.h 2.6 KB

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