Skip to content

Commit 2dfb7d5

Browse files
Chen, Gongaegl
authored andcommitted
trace, RAS: Add eMCA trace event interface
Add trace interface to elaborate all H/W error related information. Signed-off-by: Chen, Gong <gong.chen@linux.intel.com> Acked-by: Borislav Petkov <bp@suse.de> Signed-off-by: Tony Luck <tony.luck@intel.com>
1 parent d963cd9 commit 2dfb7d5

6 files changed

Lines changed: 158 additions & 8 deletions

File tree

‎drivers/acpi/Kconfig‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ config ACPI_EXTLOG
370370
tristate "Extended Error Log support"
371371
depends on X86_MCE && X86_LOCAL_APIC
372372
select UEFI_CPER
373+
select RAS
373374
default n
374375
help
375376
Certain usages such as Predictive Failure Analysis (PFA) require
@@ -384,6 +385,7 @@ config ACPI_EXTLOG
384385

385386
Enhanced MCA Logging allows firmware to provide additional error
386387
information to system software, synchronous with MCE or CMCI. This
387-
driver adds support for that functionality.
388+
driver adds support for that functionality with corresponding
389+
tracepoint which carries that information to userspace.
388390

389391
endif # ACPI

‎drivers/acpi/acpi_extlog.c‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <asm/mce.h>
1717

1818
#include "apei/apei-internal.h"
19+
#include <ras/ras_event.h>
1920

2021
#define EXT_ELOG_ENTRY_MASK GENMASK_ULL(51, 0) /* elog entry address mask */
2122

@@ -137,8 +138,12 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
137138
struct mce *mce = (struct mce *)data;
138139
int bank = mce->bank;
139140
int cpu = mce->extcpu;
140-
struct acpi_generic_status *estatus;
141-
int rc;
141+
struct acpi_generic_status *estatus, *tmp;
142+
struct acpi_generic_data *gdata;
143+
const uuid_le *fru_id = &NULL_UUID_LE;
144+
char *fru_text = "";
145+
uuid_le *sec_type;
146+
static u32 err_seq;
142147

143148
estatus = extlog_elog_entry_check(cpu, bank);
144149
if (estatus == NULL)
@@ -148,7 +153,23 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
148153
/* clear record status to enable BIOS to update it again */
149154
estatus->block_status = 0;
150155

151-
rc = print_extlog_rcd(NULL, (struct acpi_generic_status *)elog_buf, cpu);
156+
tmp = (struct acpi_generic_status *)elog_buf;
157+
print_extlog_rcd(NULL, tmp, cpu);
158+
159+
/* log event via trace */
160+
err_seq++;
161+
gdata = (struct acpi_generic_data *)(tmp + 1);
162+
if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
163+
fru_id = (uuid_le *)gdata->fru_id;
164+
if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
165+
fru_text = gdata->fru_text;
166+
sec_type = (uuid_le *)gdata->section_type;
167+
if (!uuid_le_cmp(*sec_type, CPER_SEC_PLATFORM_MEM)) {
168+
struct cper_sec_mem_err *mem = (void *)(gdata + 1);
169+
if (gdata->error_data_length >= sizeof(*mem))
170+
trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,
171+
(u8)gdata->error_severity);
172+
}
152173

153174
return NOTIFY_STOP;
154175
}

‎drivers/firmware/efi/cper.c‎

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ const char *cper_mem_err_type_str(unsigned int etype)
207207
}
208208
EXPORT_SYMBOL_GPL(cper_mem_err_type_str);
209209

210-
static int cper_mem_err_location(const struct cper_sec_mem_err *mem, char *msg)
210+
static int cper_mem_err_location(struct cper_mem_err_compact *mem, char *msg)
211211
{
212212
u32 len, n;
213213

@@ -249,7 +249,7 @@ static int cper_mem_err_location(const struct cper_sec_mem_err *mem, char *msg)
249249
return n;
250250
}
251251

252-
static int cper_dimm_err_location(const struct cper_sec_mem_err *mem, char *msg)
252+
static int cper_dimm_err_location(struct cper_mem_err_compact *mem, char *msg)
253253
{
254254
u32 len, n;
255255
const char *bank = NULL, *device = NULL;
@@ -271,8 +271,44 @@ static int cper_dimm_err_location(const struct cper_sec_mem_err *mem, char *msg)
271271
return n;
272272
}
273273

274+
void cper_mem_err_pack(const struct cper_sec_mem_err *mem,
275+
struct cper_mem_err_compact *cmem)
276+
{
277+
cmem->validation_bits = mem->validation_bits;
278+
cmem->node = mem->node;
279+
cmem->card = mem->card;
280+
cmem->module = mem->module;
281+
cmem->bank = mem->bank;
282+
cmem->device = mem->device;
283+
cmem->row = mem->row;
284+
cmem->column = mem->column;
285+
cmem->bit_pos = mem->bit_pos;
286+
cmem->requestor_id = mem->requestor_id;
287+
cmem->responder_id = mem->responder_id;
288+
cmem->target_id = mem->target_id;
289+
cmem->rank = mem->rank;
290+
cmem->mem_array_handle = mem->mem_array_handle;
291+
cmem->mem_dev_handle = mem->mem_dev_handle;
292+
}
293+
294+
const char *cper_mem_err_unpack(struct trace_seq *p,
295+
struct cper_mem_err_compact *cmem)
296+
{
297+
const char *ret = p->buffer + p->len;
298+
299+
if (cper_mem_err_location(cmem, rcd_decode_str))
300+
trace_seq_printf(p, "%s", rcd_decode_str);
301+
if (cper_dimm_err_location(cmem, rcd_decode_str))
302+
trace_seq_printf(p, "%s", rcd_decode_str);
303+
trace_seq_putc(p, '\0');
304+
305+
return ret;
306+
}
307+
274308
static void cper_print_mem(const char *pfx, const struct cper_sec_mem_err *mem)
275309
{
310+
struct cper_mem_err_compact cmem;
311+
276312
if (mem->validation_bits & CPER_MEM_VALID_ERROR_STATUS)
277313
printk("%s""error_status: 0x%016llx\n", pfx, mem->error_status);
278314
if (mem->validation_bits & CPER_MEM_VALID_PA)
@@ -281,14 +317,15 @@ static void cper_print_mem(const char *pfx, const struct cper_sec_mem_err *mem)
281317
if (mem->validation_bits & CPER_MEM_VALID_PA_MASK)
282318
printk("%s""physical_address_mask: 0x%016llx\n",
283319
pfx, mem->physical_addr_mask);
284-
if (cper_mem_err_location(mem, rcd_decode_str))
320+
cper_mem_err_pack(mem, &cmem);
321+
if (cper_mem_err_location(&cmem, rcd_decode_str))
285322
printk("%s%s\n", pfx, rcd_decode_str);
286323
if (mem->validation_bits & CPER_MEM_VALID_ERROR_TYPE) {
287324
u8 etype = mem->error_type;
288325
printk("%s""error_type: %d, %s\n", pfx, etype,
289326
cper_mem_err_type_str(etype));
290327
}
291-
if (cper_dimm_err_location(mem, rcd_decode_str))
328+
if (cper_dimm_err_location(&cmem, rcd_decode_str))
292329
printk("%s%s\n", pfx, rcd_decode_str);
293330
}
294331

‎drivers/ras/ras.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ static int __init ras_init(void)
2323
}
2424
subsys_initcall(ras_init);
2525

26+
#if defined(CONFIG_ACPI_EXTLOG) || defined(CONFIG_ACPI_EXTLOG_MODULE)
27+
EXPORT_TRACEPOINT_SYMBOL_GPL(extlog_mem_event);
28+
#endif
2629
EXPORT_TRACEPOINT_SYMBOL_GPL(mc_event);

‎include/linux/cper.h‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define LINUX_CPER_H
2323

2424
#include <linux/uuid.h>
25+
#include <linux/trace_seq.h>
2526

2627
/* CPER record signature and the size */
2728
#define CPER_SIG_RECORD "CPER"
@@ -363,6 +364,24 @@ struct cper_sec_mem_err {
363364
__u16 mem_dev_handle; /* module handle in UEFI 2.4 */
364365
};
365366

367+
struct cper_mem_err_compact {
368+
__u64 validation_bits;
369+
__u16 node;
370+
__u16 card;
371+
__u16 module;
372+
__u16 bank;
373+
__u16 device;
374+
__u16 row;
375+
__u16 column;
376+
__u16 bit_pos;
377+
__u64 requestor_id;
378+
__u64 responder_id;
379+
__u64 target_id;
380+
__u16 rank;
381+
__u16 mem_array_handle;
382+
__u16 mem_dev_handle;
383+
};
384+
366385
struct cper_sec_pcie {
367386
__u64 validation_bits;
368387
__u32 port_type;
@@ -406,5 +425,9 @@ const char *cper_severity_str(unsigned int);
406425
const char *cper_mem_err_type_str(unsigned int);
407426
void cper_print_bits(const char *prefix, unsigned int bits,
408427
const char * const strs[], unsigned int strs_size);
428+
void cper_mem_err_pack(const struct cper_sec_mem_err *,
429+
struct cper_mem_err_compact *);
430+
const char *cper_mem_err_unpack(struct trace_seq *,
431+
struct cper_mem_err_compact *);
409432

410433
#endif

‎include/ras/ras_event.h‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,70 @@
99
#include <linux/edac.h>
1010
#include <linux/ktime.h>
1111
#include <linux/aer.h>
12+
#include <linux/cper.h>
13+
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+
21+
/* memory trace event */
22+
23+
#if defined(CONFIG_ACPI_EXTLOG) || defined(CONFIG_ACPI_EXTLOG_MODULE)
24+
TRACE_EVENT(extlog_mem_event,
25+
TP_PROTO(struct cper_sec_mem_err *mem,
26+
u32 err_seq,
27+
const uuid_le *fru_id,
28+
const char *fru_text,
29+
u8 sev),
30+
31+
TP_ARGS(mem, err_seq, fru_id, fru_text, sev),
32+
33+
TP_STRUCT__entry(
34+
__field(u32, err_seq)
35+
__field(u8, etype)
36+
__field(u8, sev)
37+
__field(u64, pa)
38+
__field(u8, pa_mask_lsb)
39+
__field_struct(uuid_le, fru_id)
40+
__string(fru_text, fru_text)
41+
__field_struct(struct cper_mem_err_compact, data)
42+
),
43+
44+
TP_fast_assign(
45+
__entry->err_seq = err_seq;
46+
if (mem->validation_bits & CPER_MEM_VALID_ERROR_TYPE)
47+
__entry->etype = mem->error_type;
48+
else
49+
__entry->etype = ~0;
50+
__entry->sev = sev;
51+
if (mem->validation_bits & CPER_MEM_VALID_PA)
52+
__entry->pa = mem->physical_addr;
53+
else
54+
__entry->pa = ~0ull;
55+
56+
if (mem->validation_bits & CPER_MEM_VALID_PA_MASK)
57+
__entry->pa_mask_lsb = (u8)__ffs64(mem->physical_addr_mask);
58+
else
59+
__entry->pa_mask_lsb = ~0;
60+
__entry->fru_id = *fru_id;
61+
__assign_str(fru_text, fru_text);
62+
cper_mem_err_pack(mem, &__entry->data);
63+
),
64+
65+
TP_printk("{%d} %s error: %s physical addr: %016llx (mask lsb: %x) %sFRU: %pUl %.20s",
66+
__entry->err_seq,
67+
cper_severity_str(__entry->sev),
68+
cper_mem_err_type_str(__entry->etype),
69+
__entry->pa,
70+
__entry->pa_mask_lsb,
71+
cper_mem_err_unpack(p, &__entry->data),
72+
&__entry->fru_id,
73+
__get_str(fru_text))
74+
);
75+
#endif
1276

1377
/*
1478
* Hardware Events Report

0 commit comments

Comments
 (0)