ras_event.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM ras
  4. #define TRACE_INCLUDE_FILE ras_event
  5. #if !defined(_TRACE_HW_EVENT_MC_H) || defined(TRACE_HEADER_MULTI_READ)
  6. #define _TRACE_HW_EVENT_MC_H
  7. #include <linux/tracepoint.h>
  8. #include <linux/edac.h>
  9. #include <linux/ktime.h>
  10. #include <linux/pci.h>
  11. #include <linux/aer.h>
  12. #include <linux/cper.h>
  13. #include <linux/mm.h>
  14. /*
  15. * MCE Extended Error Log trace event
  16. *
  17. * These events are generated when hardware detects a corrected or
  18. * uncorrected event.
  19. */
  20. /* memory trace event */
  21. #if defined(CONFIG_ACPI_EXTLOG) || defined(CONFIG_ACPI_EXTLOG_MODULE)
  22. TRACE_EVENT(extlog_mem_event,
  23. TP_PROTO(struct cper_sec_mem_err *mem,
  24. u32 err_seq,
  25. const uuid_le *fru_id,
  26. const char *fru_text,
  27. u8 sev),
  28. TP_ARGS(mem, err_seq, fru_id, fru_text, sev),
  29. TP_STRUCT__entry(
  30. __field(u32, err_seq)
  31. __field(u8, etype)
  32. __field(u8, sev)
  33. __field(u64, pa)
  34. __field(u8, pa_mask_lsb)
  35. __field_struct(uuid_le, fru_id)
  36. __string(fru_text, fru_text)
  37. __field_struct(struct cper_mem_err_compact, data)
  38. ),
  39. TP_fast_assign(
  40. __entry->err_seq = err_seq;
  41. if (mem->validation_bits & CPER_MEM_VALID_ERROR_TYPE)
  42. __entry->etype = mem->error_type;
  43. else
  44. __entry->etype = ~0;
  45. __entry->sev = sev;
  46. if (mem->validation_bits & CPER_MEM_VALID_PA)
  47. __entry->pa = mem->physical_addr;
  48. else
  49. __entry->pa = ~0ull;
  50. if (mem->validation_bits & CPER_MEM_VALID_PA_MASK)
  51. __entry->pa_mask_lsb = (u8)__ffs64(mem->physical_addr_mask);
  52. else
  53. __entry->pa_mask_lsb = ~0;
  54. __entry->fru_id = *fru_id;
  55. __assign_str(fru_text, fru_text);
  56. cper_mem_err_pack(mem, &__entry->data);
  57. ),
  58. TP_printk("{%d} %s error: %s physical addr: %016llx (mask lsb: %x) %sFRU: %pUl %.20s",
  59. __entry->err_seq,
  60. cper_severity_str(__entry->sev),
  61. cper_mem_err_type_str(__entry->etype),
  62. __entry->pa,
  63. __entry->pa_mask_lsb,
  64. cper_mem_err_unpack(p, &__entry->data),
  65. &__entry->fru_id,
  66. __get_str(fru_text))
  67. );
  68. #endif
  69. /*
  70. * Hardware Events Report
  71. *
  72. * Those events are generated when hardware detected a corrected or
  73. * uncorrected event, and are meant to replace the current API to report
  74. * errors defined on both EDAC and MCE subsystems.
  75. *
  76. * FIXME: Add events for handling memory errors originated from the
  77. * MCE subsystem.
  78. */
  79. /*
  80. * Hardware-independent Memory Controller specific events
  81. */
  82. /*
  83. * Default error mechanisms for Memory Controller errors (CE and UE)
  84. */
  85. TRACE_EVENT(mc_event,
  86. TP_PROTO(const unsigned int err_type,
  87. const char *error_msg,
  88. const char *label,
  89. const int error_count,
  90. const u8 mc_index,
  91. const s8 top_layer,
  92. const s8 mid_layer,
  93. const s8 low_layer,
  94. unsigned long address,
  95. const u8 grain_bits,
  96. unsigned long syndrome,
  97. const char *driver_detail),
  98. TP_ARGS(err_type, error_msg, label, error_count, mc_index,
  99. top_layer, mid_layer, low_layer, address, grain_bits,
  100. syndrome, driver_detail),
  101. TP_STRUCT__entry(
  102. __field( unsigned int, error_type )
  103. __string( msg, error_msg )
  104. __string( label, label )
  105. __field( u16, error_count )
  106. __field( u8, mc_index )
  107. __field( s8, top_layer )
  108. __field( s8, middle_layer )
  109. __field( s8, lower_layer )
  110. __field( long, address )
  111. __field( u8, grain_bits )
  112. __field( long, syndrome )
  113. __string( driver_detail, driver_detail )
  114. ),
  115. TP_fast_assign(
  116. __entry->error_type = err_type;
  117. __assign_str(msg, error_msg);
  118. __assign_str(label, label);
  119. __entry->error_count = error_count;
  120. __entry->mc_index = mc_index;
  121. __entry->top_layer = top_layer;
  122. __entry->middle_layer = mid_layer;
  123. __entry->lower_layer = low_layer;
  124. __entry->address = address;
  125. __entry->grain_bits = grain_bits;
  126. __entry->syndrome = syndrome;
  127. __assign_str(driver_detail, driver_detail);
  128. ),
  129. TP_printk("%d %s error%s:%s%s on %s (mc:%d location:%d:%d:%d address:0x%08lx grain:%d syndrome:0x%08lx%s%s)",
  130. __entry->error_count,
  131. mc_event_error_type(__entry->error_type),
  132. __entry->error_count > 1 ? "s" : "",
  133. __get_str(msg)[0] ? " " : "",
  134. __get_str(msg),
  135. __get_str(label),
  136. __entry->mc_index,
  137. __entry->top_layer,
  138. __entry->middle_layer,
  139. __entry->lower_layer,
  140. __entry->address,
  141. 1 << __entry->grain_bits,
  142. __entry->syndrome,
  143. __get_str(driver_detail)[0] ? " " : "",
  144. __get_str(driver_detail))
  145. );
  146. /*
  147. * ARM Processor Events Report
  148. *
  149. * This event is generated when hardware detects an ARM processor error
  150. * has occurred. UEFI 2.6 spec section N.2.4.4.
  151. */
  152. TRACE_EVENT(arm_event,
  153. TP_PROTO(const struct cper_sec_proc_arm *proc),
  154. TP_ARGS(proc),
  155. TP_STRUCT__entry(
  156. __field(u64, mpidr)
  157. __field(u64, midr)
  158. __field(u32, running_state)
  159. __field(u32, psci_state)
  160. __field(u8, affinity)
  161. ),
  162. TP_fast_assign(
  163. if (proc->validation_bits & CPER_ARM_VALID_AFFINITY_LEVEL)
  164. __entry->affinity = proc->affinity_level;
  165. else
  166. __entry->affinity = ~0;
  167. if (proc->validation_bits & CPER_ARM_VALID_MPIDR)
  168. __entry->mpidr = proc->mpidr;
  169. else
  170. __entry->mpidr = 0ULL;
  171. __entry->midr = proc->midr;
  172. if (proc->validation_bits & CPER_ARM_VALID_RUNNING_STATE) {
  173. __entry->running_state = proc->running_state;
  174. __entry->psci_state = proc->psci_state;
  175. } else {
  176. __entry->running_state = ~0;
  177. __entry->psci_state = ~0;
  178. }
  179. ),
  180. TP_printk("affinity level: %d; MPIDR: %016llx; MIDR: %016llx; "
  181. "running state: %d; PSCI state: %d",
  182. __entry->affinity, __entry->mpidr, __entry->midr,
  183. __entry->running_state, __entry->psci_state)
  184. );
  185. /*
  186. * Non-Standard Section Report
  187. *
  188. * This event is generated when hardware detected a hardware
  189. * error event, which may be of non-standard section as defined
  190. * in UEFI spec appendix "Common Platform Error Record", or may
  191. * be of sections for which TRACE_EVENT is not defined.
  192. *
  193. */
  194. TRACE_EVENT(non_standard_event,
  195. TP_PROTO(const uuid_le *sec_type,
  196. const uuid_le *fru_id,
  197. const char *fru_text,
  198. const u8 sev,
  199. const u8 *err,
  200. const u32 len),
  201. TP_ARGS(sec_type, fru_id, fru_text, sev, err, len),
  202. TP_STRUCT__entry(
  203. __array(char, sec_type, UUID_SIZE)
  204. __array(char, fru_id, UUID_SIZE)
  205. __string(fru_text, fru_text)
  206. __field(u8, sev)
  207. __field(u32, len)
  208. __dynamic_array(u8, buf, len)
  209. ),
  210. TP_fast_assign(
  211. memcpy(__entry->sec_type, sec_type, UUID_SIZE);
  212. memcpy(__entry->fru_id, fru_id, UUID_SIZE);
  213. __assign_str(fru_text, fru_text);
  214. __entry->sev = sev;
  215. __entry->len = len;
  216. memcpy(__get_dynamic_array(buf), err, len);
  217. ),
  218. TP_printk("severity: %d; sec type:%pU; FRU: %pU %s; data len:%d; raw data:%s",
  219. __entry->sev, __entry->sec_type,
  220. __entry->fru_id, __get_str(fru_text),
  221. __entry->len,
  222. __print_hex(__get_dynamic_array(buf), __entry->len))
  223. );
  224. /*
  225. * PCIe AER Trace event
  226. *
  227. * These events are generated when hardware detects a corrected or
  228. * uncorrected event on a PCIe device. The event report has
  229. * the following structure:
  230. *
  231. * char * dev_name - The name of the slot where the device resides
  232. * ([domain:]bus:device.function).
  233. * u32 status - Either the correctable or uncorrectable register
  234. * indicating what error or errors have been seen
  235. * u8 severity - error severity 0:NONFATAL 1:FATAL 2:CORRECTED
  236. */
  237. #define aer_correctable_errors \
  238. {PCI_ERR_COR_RCVR, "Receiver Error"}, \
  239. {PCI_ERR_COR_BAD_TLP, "Bad TLP"}, \
  240. {PCI_ERR_COR_BAD_DLLP, "Bad DLLP"}, \
  241. {PCI_ERR_COR_REP_ROLL, "RELAY_NUM Rollover"}, \
  242. {PCI_ERR_COR_REP_TIMER, "Replay Timer Timeout"}, \
  243. {PCI_ERR_COR_ADV_NFAT, "Advisory Non-Fatal Error"}, \
  244. {PCI_ERR_COR_INTERNAL, "Corrected Internal Error"}, \
  245. {PCI_ERR_COR_LOG_OVER, "Header Log Overflow"}
  246. #define aer_uncorrectable_errors \
  247. {PCI_ERR_UNC_UND, "Undefined"}, \
  248. {PCI_ERR_UNC_DLP, "Data Link Protocol Error"}, \
  249. {PCI_ERR_UNC_SURPDN, "Surprise Down Error"}, \
  250. {PCI_ERR_UNC_POISON_TLP,"Poisoned TLP"}, \
  251. {PCI_ERR_UNC_FCP, "Flow Control Protocol Error"}, \
  252. {PCI_ERR_UNC_COMP_TIME, "Completion Timeout"}, \
  253. {PCI_ERR_UNC_COMP_ABORT,"Completer Abort"}, \
  254. {PCI_ERR_UNC_UNX_COMP, "Unexpected Completion"}, \
  255. {PCI_ERR_UNC_RX_OVER, "Receiver Overflow"}, \
  256. {PCI_ERR_UNC_MALF_TLP, "Malformed TLP"}, \
  257. {PCI_ERR_UNC_ECRC, "ECRC Error"}, \
  258. {PCI_ERR_UNC_UNSUP, "Unsupported Request Error"}, \
  259. {PCI_ERR_UNC_ACSV, "ACS Violation"}, \
  260. {PCI_ERR_UNC_INTN, "Uncorrectable Internal Error"},\
  261. {PCI_ERR_UNC_MCBTLP, "MC Blocked TLP"}, \
  262. {PCI_ERR_UNC_ATOMEG, "AtomicOp Egress Blocked"}, \
  263. {PCI_ERR_UNC_TLPPRE, "TLP Prefix Blocked Error"}
  264. TRACE_EVENT(aer_event,
  265. TP_PROTO(const char *dev_name,
  266. const u32 status,
  267. const u8 severity,
  268. const u8 tlp_header_valid,
  269. struct aer_header_log_regs *tlp),
  270. TP_ARGS(dev_name, status, severity, tlp_header_valid, tlp),
  271. TP_STRUCT__entry(
  272. __string( dev_name, dev_name )
  273. __field( u32, status )
  274. __field( u8, severity )
  275. __field( u8, tlp_header_valid)
  276. __array( u32, tlp_header, 4 )
  277. ),
  278. TP_fast_assign(
  279. __assign_str(dev_name, dev_name);
  280. __entry->status = status;
  281. __entry->severity = severity;
  282. __entry->tlp_header_valid = tlp_header_valid;
  283. if (tlp_header_valid) {
  284. __entry->tlp_header[0] = tlp->dw0;
  285. __entry->tlp_header[1] = tlp->dw1;
  286. __entry->tlp_header[2] = tlp->dw2;
  287. __entry->tlp_header[3] = tlp->dw3;
  288. }
  289. ),
  290. TP_printk("%s PCIe Bus Error: severity=%s, %s, TLP Header=%s\n",
  291. __get_str(dev_name),
  292. __entry->severity == AER_CORRECTABLE ? "Corrected" :
  293. __entry->severity == AER_FATAL ?
  294. "Fatal" : "Uncorrected, non-fatal",
  295. __entry->severity == AER_CORRECTABLE ?
  296. __print_flags(__entry->status, "|", aer_correctable_errors) :
  297. __print_flags(__entry->status, "|", aer_uncorrectable_errors),
  298. __entry->tlp_header_valid ?
  299. __print_array(__entry->tlp_header, 4, 4) :
  300. "Not available")
  301. );
  302. /*
  303. * memory-failure recovery action result event
  304. *
  305. * unsigned long pfn - Page Frame Number of the corrupted page
  306. * int type - Page types of the corrupted page
  307. * int result - Result of recovery action
  308. */
  309. #ifdef CONFIG_MEMORY_FAILURE
  310. #define MF_ACTION_RESULT \
  311. EM ( MF_IGNORED, "Ignored" ) \
  312. EM ( MF_FAILED, "Failed" ) \
  313. EM ( MF_DELAYED, "Delayed" ) \
  314. EMe ( MF_RECOVERED, "Recovered" )
  315. #define MF_PAGE_TYPE \
  316. EM ( MF_MSG_KERNEL, "reserved kernel page" ) \
  317. EM ( MF_MSG_KERNEL_HIGH_ORDER, "high-order kernel page" ) \
  318. EM ( MF_MSG_SLAB, "kernel slab page" ) \
  319. EM ( MF_MSG_DIFFERENT_COMPOUND, "different compound page after locking" ) \
  320. EM ( MF_MSG_POISONED_HUGE, "huge page already hardware poisoned" ) \
  321. EM ( MF_MSG_HUGE, "huge page" ) \
  322. EM ( MF_MSG_FREE_HUGE, "free huge page" ) \
  323. EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" ) \
  324. EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" ) \
  325. EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" ) \
  326. EM ( MF_MSG_DIRTY_MLOCKED_LRU, "dirty mlocked LRU page" ) \
  327. EM ( MF_MSG_CLEAN_MLOCKED_LRU, "clean mlocked LRU page" ) \
  328. EM ( MF_MSG_DIRTY_UNEVICTABLE_LRU, "dirty unevictable LRU page" ) \
  329. EM ( MF_MSG_CLEAN_UNEVICTABLE_LRU, "clean unevictable LRU page" ) \
  330. EM ( MF_MSG_DIRTY_LRU, "dirty LRU page" ) \
  331. EM ( MF_MSG_CLEAN_LRU, "clean LRU page" ) \
  332. EM ( MF_MSG_TRUNCATED_LRU, "already truncated LRU page" ) \
  333. EM ( MF_MSG_BUDDY, "free buddy page" ) \
  334. EM ( MF_MSG_BUDDY_2ND, "free buddy page (2nd try)" ) \
  335. EMe ( MF_MSG_UNKNOWN, "unknown page" )
  336. /*
  337. * First define the enums in MM_ACTION_RESULT to be exported to userspace
  338. * via TRACE_DEFINE_ENUM().
  339. */
  340. #undef EM
  341. #undef EMe
  342. #define EM(a, b) TRACE_DEFINE_ENUM(a);
  343. #define EMe(a, b) TRACE_DEFINE_ENUM(a);
  344. MF_ACTION_RESULT
  345. MF_PAGE_TYPE
  346. /*
  347. * Now redefine the EM() and EMe() macros to map the enums to the strings
  348. * that will be printed in the output.
  349. */
  350. #undef EM
  351. #undef EMe
  352. #define EM(a, b) { a, b },
  353. #define EMe(a, b) { a, b }
  354. TRACE_EVENT(memory_failure_event,
  355. TP_PROTO(unsigned long pfn,
  356. int type,
  357. int result),
  358. TP_ARGS(pfn, type, result),
  359. TP_STRUCT__entry(
  360. __field(unsigned long, pfn)
  361. __field(int, type)
  362. __field(int, result)
  363. ),
  364. TP_fast_assign(
  365. __entry->pfn = pfn;
  366. __entry->type = type;
  367. __entry->result = result;
  368. ),
  369. TP_printk("pfn %#lx: recovery action for %s: %s",
  370. __entry->pfn,
  371. __print_symbolic(__entry->type, MF_PAGE_TYPE),
  372. __print_symbolic(__entry->result, MF_ACTION_RESULT)
  373. )
  374. );
  375. #endif /* CONFIG_MEMORY_FAILURE */
  376. #endif /* _TRACE_HW_EVENT_MC_H */
  377. /* This part must be outside protection */
  378. #include <trace/define_trace.h>