mce-internal.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. extern struct mca_config mca_cfg;
  100. #ifndef CONFIG_X86_64
  101. /*
  102. * On 32-bit systems it would be difficult to safely unmap a poison page
  103. * from the kernel 1:1 map because there are no non-canonical addresses that
  104. * we can use to refer to the address without risking a speculative access.
  105. * However, this isn't much of an issue because:
  106. * 1) Few unmappable pages are in the 1:1 map. Most are in HIGHMEM which
  107. * are only mapped into the kernel as needed
  108. * 2) Few people would run a 32-bit kernel on a machine that supports
  109. * recoverable errors because they have too much memory to boot 32-bit.
  110. */
  111. static inline void mce_unmap_kpfn(unsigned long pfn) {}
  112. #define mce_unmap_kpfn mce_unmap_kpfn
  113. #endif
  114. #endif /* __X86_MCE_INTERNAL_H__ */