2 #define TRACE_SYSTEM ras
3 #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
8 #include <linux/tracepoint.h>
9 #include <linux/edac.h>
10 #include <linux/ktime.h>
11 #include <linux/pci.h>
12 #include <linux/aer.h>
13 #include <linux/cper.h>
17 * MCE Extended Error Log trace event
19 * These events are generated when hardware detects a corrected or
23 /* memory trace event */
25 #if defined(CONFIG_ACPI_EXTLOG) || defined(CONFIG_ACPI_EXTLOG_MODULE)
26 TRACE_EVENT(extlog_mem_event
,
27 TP_PROTO(struct cper_sec_mem_err
*mem
,
29 const uuid_le
*fru_id
,
33 TP_ARGS(mem
, err_seq
, fru_id
, fru_text
, sev
),
40 __field(u8
, pa_mask_lsb
)
41 __field_struct(uuid_le
, fru_id
)
42 __string(fru_text
, fru_text
)
43 __field_struct(struct cper_mem_err_compact
, data
)
47 __entry
->err_seq
= err_seq
;
48 if (mem
->validation_bits
& CPER_MEM_VALID_ERROR_TYPE
)
49 __entry
->etype
= mem
->error_type
;
53 if (mem
->validation_bits
& CPER_MEM_VALID_PA
)
54 __entry
->pa
= mem
->physical_addr
;
58 if (mem
->validation_bits
& CPER_MEM_VALID_PA_MASK
)
59 __entry
->pa_mask_lsb
= (u8
)__ffs64(mem
->physical_addr_mask
);
61 __entry
->pa_mask_lsb
= ~0;
62 __entry
->fru_id
= *fru_id
;
63 __assign_str(fru_text
, fru_text
);
64 cper_mem_err_pack(mem
, &__entry
->data
);
67 TP_printk("{%d} %s error: %s physical addr: %016llx (mask lsb: %x) %sFRU: %pUl %.20s",
69 cper_severity_str(__entry
->sev
),
70 cper_mem_err_type_str(__entry
->etype
),
73 cper_mem_err_unpack(p
, &__entry
->data
),
80 * Hardware Events Report
82 * Those events are generated when hardware detected a corrected or
83 * uncorrected event, and are meant to replace the current API to report
84 * errors defined on both EDAC and MCE subsystems.
86 * FIXME: Add events for handling memory errors originated from the
91 * Hardware-independent Memory Controller specific events
95 * Default error mechanisms for Memory Controller errors (CE and UE)
99 TP_PROTO(const unsigned int err_type
,
100 const char *error_msg
,
102 const int error_count
,
107 unsigned long address
,
109 unsigned long syndrome
,
110 const char *driver_detail
),
112 TP_ARGS(err_type
, error_msg
, label
, error_count
, mc_index
,
113 top_layer
, mid_layer
, low_layer
, address
, grain_bits
,
114 syndrome
, driver_detail
),
117 __field( unsigned int, error_type
)
118 __string( msg
, error_msg
)
119 __string( label
, label
)
120 __field( u16
, error_count
)
121 __field( u8
, mc_index
)
122 __field( s8
, top_layer
)
123 __field( s8
, middle_layer
)
124 __field( s8
, lower_layer
)
125 __field( long, address
)
126 __field( u8
, grain_bits
)
127 __field( long, syndrome
)
128 __string( driver_detail
, driver_detail
)
132 __entry
->error_type
= err_type
;
133 __assign_str(msg
, error_msg
);
134 __assign_str(label
, label
);
135 __entry
->error_count
= error_count
;
136 __entry
->mc_index
= mc_index
;
137 __entry
->top_layer
= top_layer
;
138 __entry
->middle_layer
= mid_layer
;
139 __entry
->lower_layer
= low_layer
;
140 __entry
->address
= address
;
141 __entry
->grain_bits
= grain_bits
;
142 __entry
->syndrome
= syndrome
;
143 __assign_str(driver_detail
, driver_detail
);
146 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)",
147 __entry
->error_count
,
148 mc_event_error_type(__entry
->error_type
),
149 __entry
->error_count
> 1 ? "s" : "",
150 __get_str(msg
)[0] ? " " : "",
155 __entry
->middle_layer
,
156 __entry
->lower_layer
,
158 1 << __entry
->grain_bits
,
160 __get_str(driver_detail
)[0] ? " " : "",
161 __get_str(driver_detail
))
165 * ARM Processor Events Report
167 * This event is generated when hardware detects an ARM processor error
168 * has occurred. UEFI 2.6 spec section N.2.4.4.
170 TRACE_EVENT(arm_event
,
172 TP_PROTO(const struct cper_sec_proc_arm
*proc
),
179 __field(u32
, running_state
)
180 __field(u32
, psci_state
)
181 __field(u8
, affinity
)
185 if (proc
->validation_bits
& CPER_ARM_VALID_AFFINITY_LEVEL
)
186 __entry
->affinity
= proc
->affinity_level
;
188 __entry
->affinity
= ~0;
189 if (proc
->validation_bits
& CPER_ARM_VALID_MPIDR
)
190 __entry
->mpidr
= proc
->mpidr
;
192 __entry
->mpidr
= 0ULL;
193 __entry
->midr
= proc
->midr
;
194 if (proc
->validation_bits
& CPER_ARM_VALID_RUNNING_STATE
) {
195 __entry
->running_state
= proc
->running_state
;
196 __entry
->psci_state
= proc
->psci_state
;
198 __entry
->running_state
= ~0;
199 __entry
->psci_state
= ~0;
203 TP_printk("affinity level: %d; MPIDR: %016llx; MIDR: %016llx; "
204 "running state: %d; PSCI state: %d",
205 __entry
->affinity
, __entry
->mpidr
, __entry
->midr
,
206 __entry
->running_state
, __entry
->psci_state
)
210 * Non-Standard Section Report
212 * This event is generated when hardware detected a hardware
213 * error event, which may be of non-standard section as defined
214 * in UEFI spec appendix "Common Platform Error Record", or may
215 * be of sections for which TRACE_EVENT is not defined.
218 TRACE_EVENT(non_standard_event
,
220 TP_PROTO(const uuid_le
*sec_type
,
221 const uuid_le
*fru_id
,
222 const char *fru_text
,
227 TP_ARGS(sec_type
, fru_id
, fru_text
, sev
, err
, len
),
230 __array(char, sec_type
, UUID_SIZE
)
231 __array(char, fru_id
, UUID_SIZE
)
232 __string(fru_text
, fru_text
)
235 __dynamic_array(u8
, buf
, len
)
239 memcpy(__entry
->sec_type
, sec_type
, UUID_SIZE
);
240 memcpy(__entry
->fru_id
, fru_id
, UUID_SIZE
);
241 __assign_str(fru_text
, fru_text
);
244 memcpy(__get_dynamic_array(buf
), err
, len
);
247 TP_printk("severity: %d; sec type:%pU; FRU: %pU %s; data len:%d; raw data:%s",
248 __entry
->sev
, __entry
->sec_type
,
249 __entry
->fru_id
, __get_str(fru_text
),
251 __print_hex(__get_dynamic_array(buf
), __entry
->len
))
255 * PCIe AER Trace event
257 * These events are generated when hardware detects a corrected or
258 * uncorrected event on a PCIe device. The event report has
259 * the following structure:
261 * char * dev_name - The name of the slot where the device resides
262 * ([domain:]bus:device.function).
263 * u32 status - Either the correctable or uncorrectable register
264 * indicating what error or errors have been seen
265 * u8 severity - error severity 0:NONFATAL 1:FATAL 2:CORRECTED
268 #define aer_correctable_errors \
269 {PCI_ERR_COR_RCVR, "Receiver Error"}, \
270 {PCI_ERR_COR_BAD_TLP, "Bad TLP"}, \
271 {PCI_ERR_COR_BAD_DLLP, "Bad DLLP"}, \
272 {PCI_ERR_COR_REP_ROLL, "RELAY_NUM Rollover"}, \
273 {PCI_ERR_COR_REP_TIMER, "Replay Timer Timeout"}, \
274 {PCI_ERR_COR_ADV_NFAT, "Advisory Non-Fatal Error"}, \
275 {PCI_ERR_COR_INTERNAL, "Corrected Internal Error"}, \
276 {PCI_ERR_COR_LOG_OVER, "Header Log Overflow"}
278 #define aer_uncorrectable_errors \
279 {PCI_ERR_UNC_UND, "Undefined"}, \
280 {PCI_ERR_UNC_DLP, "Data Link Protocol Error"}, \
281 {PCI_ERR_UNC_SURPDN, "Surprise Down Error"}, \
282 {PCI_ERR_UNC_POISON_TLP,"Poisoned TLP"}, \
283 {PCI_ERR_UNC_FCP, "Flow Control Protocol Error"}, \
284 {PCI_ERR_UNC_COMP_TIME, "Completion Timeout"}, \
285 {PCI_ERR_UNC_COMP_ABORT,"Completer Abort"}, \
286 {PCI_ERR_UNC_UNX_COMP, "Unexpected Completion"}, \
287 {PCI_ERR_UNC_RX_OVER, "Receiver Overflow"}, \
288 {PCI_ERR_UNC_MALF_TLP, "Malformed TLP"}, \
289 {PCI_ERR_UNC_ECRC, "ECRC Error"}, \
290 {PCI_ERR_UNC_UNSUP, "Unsupported Request Error"}, \
291 {PCI_ERR_UNC_ACSV, "ACS Violation"}, \
292 {PCI_ERR_UNC_INTN, "Uncorrectable Internal Error"},\
293 {PCI_ERR_UNC_MCBTLP, "MC Blocked TLP"}, \
294 {PCI_ERR_UNC_ATOMEG, "AtomicOp Egress Blocked"}, \
295 {PCI_ERR_UNC_TLPPRE, "TLP Prefix Blocked Error"}
297 TRACE_EVENT(aer_event
,
298 TP_PROTO(const char *dev_name
,
302 TP_ARGS(dev_name
, status
, severity
),
305 __string( dev_name
, dev_name
)
306 __field( u32
, status
)
307 __field( u8
, severity
)
311 __assign_str(dev_name
, dev_name
);
312 __entry
->status
= status
;
313 __entry
->severity
= severity
;
316 TP_printk("%s PCIe Bus Error: severity=%s, %s\n",
318 __entry
->severity
== AER_CORRECTABLE
? "Corrected" :
319 __entry
->severity
== AER_FATAL
?
320 "Fatal" : "Uncorrected, non-fatal",
321 __entry
->severity
== AER_CORRECTABLE
?
322 __print_flags(__entry
->status
, "|", aer_correctable_errors
) :
323 __print_flags(__entry
->status
, "|", aer_uncorrectable_errors
))
327 * memory-failure recovery action result event
329 * unsigned long pfn - Page Frame Number of the corrupted page
330 * int type - Page types of the corrupted page
331 * int result - Result of recovery action
334 #ifdef CONFIG_MEMORY_FAILURE
335 #define MF_ACTION_RESULT \
336 EM ( MF_IGNORED, "Ignored" ) \
337 EM ( MF_FAILED, "Failed" ) \
338 EM ( MF_DELAYED, "Delayed" ) \
339 EMe ( MF_RECOVERED, "Recovered" )
341 #define MF_PAGE_TYPE \
342 EM ( MF_MSG_KERNEL, "reserved kernel page" ) \
343 EM ( MF_MSG_KERNEL_HIGH_ORDER, "high-order kernel page" ) \
344 EM ( MF_MSG_SLAB, "kernel slab page" ) \
345 EM ( MF_MSG_DIFFERENT_COMPOUND, "different compound page after locking" ) \
346 EM ( MF_MSG_POISONED_HUGE, "huge page already hardware poisoned" ) \
347 EM ( MF_MSG_HUGE, "huge page" ) \
348 EM ( MF_MSG_FREE_HUGE, "free huge page" ) \
349 EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" ) \
350 EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" ) \
351 EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" ) \
352 EM ( MF_MSG_DIRTY_MLOCKED_LRU, "dirty mlocked LRU page" ) \
353 EM ( MF_MSG_CLEAN_MLOCKED_LRU, "clean mlocked LRU page" ) \
354 EM ( MF_MSG_DIRTY_UNEVICTABLE_LRU, "dirty unevictable LRU page" ) \
355 EM ( MF_MSG_CLEAN_UNEVICTABLE_LRU, "clean unevictable LRU page" ) \
356 EM ( MF_MSG_DIRTY_LRU, "dirty LRU page" ) \
357 EM ( MF_MSG_CLEAN_LRU, "clean LRU page" ) \
358 EM ( MF_MSG_TRUNCATED_LRU, "already truncated LRU page" ) \
359 EM ( MF_MSG_BUDDY, "free buddy page" ) \
360 EM ( MF_MSG_BUDDY_2ND, "free buddy page (2nd try)" ) \
361 EMe ( MF_MSG_UNKNOWN, "unknown page" )
364 * First define the enums in MM_ACTION_RESULT to be exported to userspace
365 * via TRACE_DEFINE_ENUM().
369 #define EM(a, b) TRACE_DEFINE_ENUM(a);
370 #define EMe(a, b) TRACE_DEFINE_ENUM(a);
376 * Now redefine the EM() and EMe() macros to map the enums to the strings
377 * that will be printed in the output.
381 #define EM(a, b) { a, b },
382 #define EMe(a, b) { a, b }
384 TRACE_EVENT(memory_failure_event
,
385 TP_PROTO(unsigned long pfn
,
389 TP_ARGS(pfn
, type
, result
),
392 __field(unsigned long, pfn
)
399 __entry
->type
= type
;
400 __entry
->result
= result
;
403 TP_printk("pfn %#lx: recovery action for %s: %s",
405 __print_symbolic(__entry
->type
, MF_PAGE_TYPE
),
406 __print_symbolic(__entry
->result
, MF_ACTION_RESULT
)
409 #endif /* CONFIG_MEMORY_FAILURE */
410 #endif /* _TRACE_HW_EVENT_MC_H */
412 /* This part must be outside protection */
413 #include <trace/define_trace.h>