mce.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef _ASM_MCE_H
  2. #define _ASM_MCE_H 1
  3. #include <asm/ioctls.h>
  4. #include <asm/types.h>
  5. /*
  6. * Machine Check support for x86
  7. */
  8. #define MCG_CTL_P (1UL<<8) /* MCG_CAP register available */
  9. #define MCG_STATUS_RIPV (1UL<<0) /* restart ip valid */
  10. #define MCG_STATUS_EIPV (1UL<<1) /* eip points to correct instruction */
  11. #define MCG_STATUS_MCIP (1UL<<2) /* machine check in progress */
  12. #define MCI_STATUS_VAL (1UL<<63) /* valid error */
  13. #define MCI_STATUS_OVER (1UL<<62) /* previous errors lost */
  14. #define MCI_STATUS_UC (1UL<<61) /* uncorrected error */
  15. #define MCI_STATUS_EN (1UL<<60) /* error enabled */
  16. #define MCI_STATUS_MISCV (1UL<<59) /* misc error reg. valid */
  17. #define MCI_STATUS_ADDRV (1UL<<58) /* addr reg. valid */
  18. #define MCI_STATUS_PCC (1UL<<57) /* processor context corrupt */
  19. /* Fields are zero when not available */
  20. struct mce {
  21. __u64 status;
  22. __u64 misc;
  23. __u64 addr;
  24. __u64 mcgstatus;
  25. __u64 rip;
  26. __u64 tsc; /* cpu time stamp counter */
  27. __u64 res1; /* for future extension */
  28. __u64 res2; /* dito. */
  29. __u8 cs; /* code segment */
  30. __u8 bank; /* machine check bank */
  31. __u8 cpu; /* cpu that raised the error */
  32. __u8 finished; /* entry is valid */
  33. __u32 pad;
  34. };
  35. /*
  36. * This structure contains all data related to the MCE log.
  37. * Also carries a signature to make it easier to find from external debugging tools.
  38. * Each entry is only valid when its finished flag is set.
  39. */
  40. #define MCE_LOG_LEN 32
  41. struct mce_log {
  42. char signature[12]; /* "MACHINECHECK" */
  43. unsigned len; /* = MCE_LOG_LEN */
  44. unsigned next;
  45. unsigned flags;
  46. unsigned pad0;
  47. struct mce entry[MCE_LOG_LEN];
  48. };
  49. #define MCE_OVERFLOW 0 /* bit 0 in flags means overflow */
  50. #define MCE_LOG_SIGNATURE "MACHINECHECK"
  51. #define MCE_GET_RECORD_LEN _IOR('M', 1, int)
  52. #define MCE_GET_LOG_LEN _IOR('M', 2, int)
  53. #define MCE_GETCLEAR_FLAGS _IOR('M', 3, int)
  54. /* Software defined banks */
  55. #define MCE_EXTENDED_BANK 128
  56. #define MCE_THERMAL_BANK MCE_EXTENDED_BANK + 0
  57. #define MCE_THRESHOLD_BASE MCE_EXTENDED_BANK + 1 /* MCE_AMD */
  58. #define MCE_THRESHOLD_DRAM_ECC MCE_THRESHOLD_BASE + 4
  59. #ifdef __KERNEL__
  60. #include <asm/atomic.h>
  61. void mce_log(struct mce *m);
  62. DECLARE_PER_CPU(struct sys_device, device_mce);
  63. #ifdef CONFIG_X86_MCE_INTEL
  64. void mce_intel_feature_init(struct cpuinfo_x86 *c);
  65. #else
  66. static inline void mce_intel_feature_init(struct cpuinfo_x86 *c)
  67. {
  68. }
  69. #endif
  70. #ifdef CONFIG_X86_MCE_AMD
  71. void mce_amd_feature_init(struct cpuinfo_x86 *c);
  72. #else
  73. static inline void mce_amd_feature_init(struct cpuinfo_x86 *c)
  74. {
  75. }
  76. #endif
  77. extern atomic_t mce_entry;
  78. #endif
  79. #endif