mce.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef _ASM_X86_MCE_H
  2. #define _ASM_X86_MCE_H
  3. #include <uapi/asm/mce.h>
  4. struct mca_config {
  5. bool dont_log_ce;
  6. bool cmci_disabled;
  7. bool ignore_ce;
  8. bool disabled;
  9. bool ser;
  10. bool bios_cmci_threshold;
  11. u8 banks;
  12. s8 bootlog;
  13. int tolerant;
  14. int monarch_timeout;
  15. int panic_timeout;
  16. u32 rip_msr;
  17. };
  18. extern struct mca_config mca_cfg;
  19. extern void mce_register_decode_chain(struct notifier_block *nb);
  20. extern void mce_unregister_decode_chain(struct notifier_block *nb);
  21. #include <linux/percpu.h>
  22. #include <linux/init.h>
  23. #include <linux/atomic.h>
  24. extern int mce_p5_enabled;
  25. #ifdef CONFIG_X86_MCE
  26. int mcheck_init(void);
  27. void mcheck_cpu_init(struct cpuinfo_x86 *c);
  28. #else
  29. static inline int mcheck_init(void) { return 0; }
  30. static inline void mcheck_cpu_init(struct cpuinfo_x86 *c) {}
  31. #endif
  32. #ifdef CONFIG_X86_ANCIENT_MCE
  33. void intel_p5_mcheck_init(struct cpuinfo_x86 *c);
  34. void winchip_mcheck_init(struct cpuinfo_x86 *c);
  35. static inline void enable_p5_mce(void) { mce_p5_enabled = 1; }
  36. #else
  37. static inline void intel_p5_mcheck_init(struct cpuinfo_x86 *c) {}
  38. static inline void winchip_mcheck_init(struct cpuinfo_x86 *c) {}
  39. static inline void enable_p5_mce(void) {}
  40. #endif
  41. void mce_setup(struct mce *m);
  42. void mce_log(struct mce *m);
  43. DECLARE_PER_CPU(struct device *, mce_device);
  44. /*
  45. * Maximum banks number.
  46. * This is the limit of the current register layout on
  47. * Intel CPUs.
  48. */
  49. #define MAX_NR_BANKS 32
  50. #ifdef CONFIG_X86_MCE_INTEL
  51. void mce_intel_feature_init(struct cpuinfo_x86 *c);
  52. void cmci_clear(void);
  53. void cmci_reenable(void);
  54. void cmci_rediscover(int dying);
  55. void cmci_recheck(void);
  56. #else
  57. static inline void mce_intel_feature_init(struct cpuinfo_x86 *c) { }
  58. static inline void cmci_clear(void) {}
  59. static inline void cmci_reenable(void) {}
  60. static inline void cmci_rediscover(int dying) {}
  61. static inline void cmci_recheck(void) {}
  62. #endif
  63. #ifdef CONFIG_X86_MCE_AMD
  64. void mce_amd_feature_init(struct cpuinfo_x86 *c);
  65. #else
  66. static inline void mce_amd_feature_init(struct cpuinfo_x86 *c) { }
  67. #endif
  68. int mce_available(struct cpuinfo_x86 *c);
  69. DECLARE_PER_CPU(unsigned, mce_exception_count);
  70. DECLARE_PER_CPU(unsigned, mce_poll_count);
  71. extern atomic_t mce_entry;
  72. typedef DECLARE_BITMAP(mce_banks_t, MAX_NR_BANKS);
  73. DECLARE_PER_CPU(mce_banks_t, mce_poll_banks);
  74. enum mcp_flags {
  75. MCP_TIMESTAMP = (1 << 0), /* log time stamp */
  76. MCP_UC = (1 << 1), /* log uncorrected errors */
  77. MCP_DONTLOG = (1 << 2), /* only clear, don't log */
  78. };
  79. void machine_check_poll(enum mcp_flags flags, mce_banks_t *b);
  80. int mce_notify_irq(void);
  81. void mce_notify_process(void);
  82. DECLARE_PER_CPU(struct mce, injectm);
  83. extern void register_mce_write_callback(ssize_t (*)(struct file *filp,
  84. const char __user *ubuf,
  85. size_t usize, loff_t *off));
  86. /*
  87. * Exception handler
  88. */
  89. /* Call the installed machine check handler for this CPU setup. */
  90. extern void (*machine_check_vector)(struct pt_regs *, long error_code);
  91. void do_machine_check(struct pt_regs *, long);
  92. /*
  93. * Threshold handler
  94. */
  95. extern void (*mce_threshold_vector)(void);
  96. extern void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
  97. /*
  98. * Thermal handler
  99. */
  100. void intel_init_thermal(struct cpuinfo_x86 *c);
  101. void mce_log_therm_throt_event(__u64 status);
  102. /* Interrupt Handler for core thermal thresholds */
  103. extern int (*platform_thermal_notify)(__u64 msr_val);
  104. #ifdef CONFIG_X86_THERMAL_VECTOR
  105. extern void mcheck_intel_therm_init(void);
  106. #else
  107. static inline void mcheck_intel_therm_init(void) { }
  108. #endif
  109. /*
  110. * Used by APEI to report memory error via /dev/mcelog
  111. */
  112. struct cper_sec_mem_err;
  113. extern void apei_mce_report_mem_error(int corrected,
  114. struct cper_sec_mem_err *mem_err);
  115. #endif /* _ASM_X86_MCE_H */