Skip to content

Commit 297b64c

Browse files
Tyler Baicarwildea01
authored andcommitted
ras: acpi / apei: generate trace event for unrecognized CPER section
The UEFI spec includes non-standard section type support in the Common Platform Error Record. This is defined in section N.2.3 of UEFI version 2.5. Currently if the CPER section's type (UUID) does not match any section type that the kernel knows how to parse, a trace event is not generated. Generate a trace event which contains the raw error data for non-standard section type error records. Signed-off-by: Tyler Baicar <[email protected]> CC: Jonathan (Zhixiong) Zhang <[email protected]> Tested-by: Shiju Jose <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 0fc300f commit 297b64c

File tree

5 files changed

+87
-2
lines changed

5 files changed

+87
-2
lines changed

drivers/acpi/apei/ghes.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@
4545
#include <linux/aer.h>
4646
#include <linux/nmi.h>
4747
#include <linux/sched/clock.h>
48+
#include <linux/uuid.h>
49+
#include <linux/ras.h>
4850

4951
#include <acpi/actbl1.h>
5052
#include <acpi/ghes.h>
5153
#include <acpi/apei.h>
5254
#include <asm/tlbflush.h>
55+
#include <ras/ras_event.h>
5356

5457
#include "apei-internal.h"
5558

@@ -461,11 +464,19 @@ static void ghes_do_proc(struct ghes *ghes,
461464
int sev, sec_sev;
462465
struct acpi_hest_generic_data *gdata;
463466
guid_t *sec_type;
467+
guid_t *fru_id = &NULL_UUID_LE;
468+
char *fru_text = "";
464469

465470
sev = ghes_severity(estatus->error_severity);
466471
apei_estatus_for_each_section(estatus, gdata) {
467472
sec_type = (guid_t *)gdata->section_type;
468473
sec_sev = ghes_severity(gdata->error_severity);
474+
if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
475+
fru_id = (guid_t *)gdata->fru_id;
476+
477+
if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
478+
fru_text = gdata->fru_text;
479+
469480
if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
470481
struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata);
471482

@@ -506,6 +517,13 @@ static void ghes_do_proc(struct ghes *ghes,
506517

507518
}
508519
#endif
520+
else {
521+
void *err = acpi_hest_get_payload(gdata);
522+
523+
log_non_standard_event(sec_type, fru_id, fru_text,
524+
sec_sev, err,
525+
gdata->error_data_length);
526+
}
509527
}
510528
}
511529

drivers/ras/ras.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@
77

88
#include <linux/init.h>
99
#include <linux/ras.h>
10+
#include <linux/uuid.h>
1011

1112
#define CREATE_TRACE_POINTS
1213
#define TRACE_INCLUDE_PATH ../../include/ras
1314
#include <ras/ras_event.h>
1415

16+
void log_non_standard_event(const uuid_le *sec_type, const uuid_le *fru_id,
17+
const char *fru_text, const u8 sev, const u8 *err,
18+
const u32 len)
19+
{
20+
trace_non_standard_event(sec_type, fru_id, fru_text, sev, err, len);
21+
}
22+
1523
static int __init ras_init(void)
1624
{
1725
int rc = 0;
@@ -27,7 +35,7 @@ subsys_initcall(ras_init);
2735
EXPORT_TRACEPOINT_SYMBOL_GPL(extlog_mem_event);
2836
#endif
2937
EXPORT_TRACEPOINT_SYMBOL_GPL(mc_event);
30-
38+
EXPORT_TRACEPOINT_SYMBOL_GPL(non_standard_event);
3139

3240
int __init parse_ras_param(char *str)
3341
{

include/linux/ras.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define __RAS_H__
33

44
#include <asm/errno.h>
5+
#include <linux/uuid.h>
56

67
#ifdef CONFIG_DEBUG_FS
78
int ras_userspace_consumers(void);
@@ -22,4 +23,15 @@ static inline void __init cec_init(void) { }
2223
static inline int cec_add_elem(u64 pfn) { return -ENODEV; }
2324
#endif
2425

26+
#ifdef CONFIG_RAS
27+
void log_non_standard_event(const guid_t *sec_type,
28+
const guid_t *fru_id, const char *fru_text,
29+
const u8 sev, const u8 *err, const u32 len);
30+
#else
31+
static void log_non_standard_event(const guid_t *sec_type,
32+
const guid_t *fru_id, const char *fru_text,
33+
const u8 sev, const u8 *err,
34+
const u32 len) { return; }
35+
#endif
36+
2537
#endif /* __RAS_H__ */

include/linux/uuid.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919
#include <uapi/linux/uuid.h>
2020

21+
#define UUID_SIZE 16
22+
2123
typedef struct {
22-
__u8 b[16];
24+
__u8 b[UUID_SIZE];
2325
} uuid_t;
2426

2527
#define UUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \

include/ras/ras_event.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,51 @@ TRACE_EVENT(mc_event,
161161
__get_str(driver_detail))
162162
);
163163

164+
/*
165+
* Non-Standard Section Report
166+
*
167+
* This event is generated when hardware detected a hardware
168+
* error event, which may be of non-standard section as defined
169+
* in UEFI spec appendix "Common Platform Error Record", or may
170+
* be of sections for which TRACE_EVENT is not defined.
171+
*
172+
*/
173+
TRACE_EVENT(non_standard_event,
174+
175+
TP_PROTO(const uuid_le *sec_type,
176+
const uuid_le *fru_id,
177+
const char *fru_text,
178+
const u8 sev,
179+
const u8 *err,
180+
const u32 len),
181+
182+
TP_ARGS(sec_type, fru_id, fru_text, sev, err, len),
183+
184+
TP_STRUCT__entry(
185+
__array(char, sec_type, UUID_SIZE)
186+
__array(char, fru_id, UUID_SIZE)
187+
__string(fru_text, fru_text)
188+
__field(u8, sev)
189+
__field(u32, len)
190+
__dynamic_array(u8, buf, len)
191+
),
192+
193+
TP_fast_assign(
194+
memcpy(__entry->sec_type, sec_type, UUID_SIZE);
195+
memcpy(__entry->fru_id, fru_id, UUID_SIZE);
196+
__assign_str(fru_text, fru_text);
197+
__entry->sev = sev;
198+
__entry->len = len;
199+
memcpy(__get_dynamic_array(buf), err, len);
200+
),
201+
202+
TP_printk("severity: %d; sec type:%pU; FRU: %pU %s; data len:%d; raw data:%s",
203+
__entry->sev, __entry->sec_type,
204+
__entry->fru_id, __get_str(fru_text),
205+
__entry->len,
206+
__print_hex(__get_dynamic_array(buf), __entry->len))
207+
);
208+
164209
/*
165210
* PCIe AER Trace event
166211
*

0 commit comments

Comments
 (0)