mce-internal.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __X86_MCE_INTERNAL_H__
  3. #define __X86_MCE_INTERNAL_H__
  4. #include <linux/device.h>
  5. #include <asm/mce.h>
  6. enum severity_level {
  7. MCE_NO_SEVERITY,
  8. MCE_DEFERRED_SEVERITY,
  9. MCE_UCNA_SEVERITY = MCE_DEFERRED_SEVERITY,
  10. MCE_KEEP_SEVERITY,
  11. MCE_SOME_SEVERITY,
  12. MCE_AO_SEVERITY,
  13. MCE_UC_SEVERITY,
  14. MCE_AR_SEVERITY,
  15. MCE_PANIC_SEVERITY,
  16. };
  17. extern struct blocking_notifier_head x86_mce_decoder_chain;
  18. #define ATTR_LEN 16
  19. #define INITIAL_CHECK_INTERVAL 5 * 60 /* 5 minutes */
  20. /* One object for each MCE bank, shared by all CPUs */
  21. struct mce_bank {
  22. u64 ctl; /* subevents to enable */
  23. unsigned char init; /* initialise bank? */
  24. struct device_attribute attr; /* device attribute */
  25. char attrname[ATTR_LEN]; /* attribute name */
  26. };
  27. struct mce_evt_llist {
  28. struct llist_node llnode;
  29. struct mce mce;
  30. };
  31. void mce_gen_pool_process(struct work_struct *__unused);
  32. bool mce_gen_pool_empty(void);
  33. int mce_gen_pool_add(struct mce *mce);
  34. int mce_gen_pool_init(void);
  35. struct llist_node *mce_gen_pool_prepare_records(void);
  36. extern int (*mce_severity)(struct mce *a, int tolerant, char **msg, bool is_excp);
  37. struct dentry *mce_get_debugfs_dir(void);
  38. extern struct mce_bank *mce_banks;
  39. extern mce_banks_t mce_banks_ce_disabled;
  40. #ifdef CONFIG_X86_MCE_INTEL
  41. unsigned long cmci_intel_adjust_timer(unsigned long interval);
  42. bool mce_intel_cmci_poll(void);
  43. void mce_intel_hcpu_update(unsigned long cpu);
  44. void cmci_disable_bank(int bank);
  45. #else
  46. # define cmci_intel_adjust_timer mce_adjust_timer_default
  47. static inline bool mce_intel_cmci_poll(void) { return false; }
  48. static inline void mce_intel_hcpu_update(unsigned long cpu) { }
  49. static inline void cmci_disable_bank(int bank) { }
  50. #endif
  51. void mce_timer_kick(unsigned long interval);
  52. #ifdef CONFIG_ACPI_APEI
  53. int apei_write_mce(struct mce *m);
  54. ssize_t apei_read_mce(struct mce *m, u64 *record_id);
  55. int apei_check_mce(void);
  56. int apei_clear_mce(u64 record_id);
  57. #else
  58. static inline int apei_write_mce(struct mce *m)
  59. {
  60. return -EINVAL;
  61. }
  62. static inline ssize_t apei_read_mce(struct mce *m, u64 *record_id)
  63. {
  64. return 0;
  65. }
  66. static inline int apei_check_mce(void)
  67. {
  68. return 0;
  69. }
  70. static inline int apei_clear_mce(u64 record_id)
  71. {
  72. return -EINVAL;
  73. }
  74. #endif
  75. void mce_inject_log(struct mce *m);
  76. /*
  77. * We consider records to be equivalent if bank+status+addr+misc all match.
  78. * This is only used when the system is going down because of a fatal error
  79. * to avoid cluttering the console log with essentially repeated information.
  80. * In normal processing all errors seen are logged.
  81. */
  82. static inline bool mce_cmp(struct mce *m1, struct mce *m2)
  83. {
  84. return m1->bank != m2->bank ||
  85. m1->status != m2->status ||
  86. m1->addr != m2->addr ||
  87. m1->misc != m2->misc;
  88. }
  89. extern struct device_attribute dev_attr_trigger;
  90. #ifdef CONFIG_X86_MCELOG_LEGACY
  91. void mce_work_trigger(void);
  92. void mce_register_injector_chain(struct notifier_block *nb);
  93. void mce_unregister_injector_chain(struct notifier_block *nb);
  94. #else
  95. static inline void mce_work_trigger(void) { }
  96. static inline void mce_register_injector_chain(struct notifier_block *nb) { }
  97. static inline void mce_unregister_injector_chain(struct notifier_block *nb) { }
  98. #endif
  99. struct mca_config {
  100. bool dont_log_ce;
  101. bool cmci_disabled;
  102. bool ignore_ce;
  103. __u64 lmce_disabled : 1,
  104. disabled : 1,
  105. ser : 1,
  106. recovery : 1,
  107. bios_cmci_threshold : 1,
  108. __reserved : 59;
  109. u8 banks;
  110. s8 bootlog;
  111. int tolerant;
  112. int monarch_timeout;
  113. int panic_timeout;
  114. u32 rip_msr;
  115. };
  116. extern struct mca_config mca_cfg;
  117. struct mce_vendor_flags {
  118. /*
  119. * Indicates that overflow conditions are not fatal, when set.
  120. */
  121. __u64 overflow_recov : 1,
  122. /*
  123. * (AMD) SUCCOR stands for S/W UnCorrectable error COntainment and
  124. * Recovery. It indicates support for data poisoning in HW and deferred
  125. * error interrupts.
  126. */
  127. succor : 1,
  128. /*
  129. * (AMD) SMCA: This bit indicates support for Scalable MCA which expands
  130. * the register space for each MCA bank and also increases number of
  131. * banks. Also, to accommodate the new banks and registers, the MCA
  132. * register space is moved to a new MSR range.
  133. */
  134. smca : 1,
  135. __reserved_0 : 61;
  136. };
  137. extern struct mce_vendor_flags mce_flags;
  138. struct mca_msr_regs {
  139. u32 (*ctl) (int bank);
  140. u32 (*status) (int bank);
  141. u32 (*addr) (int bank);
  142. u32 (*misc) (int bank);
  143. };
  144. extern struct mca_msr_regs msr_ops;
  145. #endif /* __X86_MCE_INTERNAL_H__ */