Skip to content

Commit 9aa9cf3

Browse files
shijujose4Lorenzo Pieralisi
authored andcommitted
ACPI / APEI: Add a notifier chain for unknown (vendor) CPER records
CPER records describing a firmware-first error are identified by GUID. The ghes driver currently logs, but ignores any unknown CPER records. This prevents describing errors that can't be represented by a standard entry, that would otherwise allow a driver to recover from an error. The UEFI spec calls these 'Non-standard Section Body' (N.2.3 of version 2.8). Add a notifier chain for these non-standard/vendor-records. Callers must identify their type of records by GUID. Record data is copied to memory from the ghes_estatus_pool to allow us to keep it until after the notifier has run. Co-developed-by: James Morse <james.morse@arm.com> Link: https://lore.kernel.org/r/20200903123456.1823-2-shiju.jose@huawei.com Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Shiju Jose <shiju.jose@huawei.com> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Acked-by: "Rafael J. Wysocki" <rjw@rjwysocki.net>
1 parent 9123e3a commit 9aa9cf3

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

‎drivers/acpi/apei/ghes.c‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
((struct acpi_hest_generic_status *) \
8080
((struct ghes_estatus_node *)(estatus_node) + 1))
8181

82+
#define GHES_VENDOR_ENTRY_LEN(gdata_len) \
83+
(sizeof(struct ghes_vendor_record_entry) + (gdata_len))
84+
#define GHES_GDATA_FROM_VENDOR_ENTRY(vendor_entry) \
85+
((struct acpi_hest_generic_data *) \
86+
((struct ghes_vendor_record_entry *)(vendor_entry) + 1))
87+
8288
/*
8389
* NMI-like notifications vary by architecture, before the compiler can prune
8490
* unused static functions it needs a value for these enums.
@@ -123,6 +129,12 @@ static DEFINE_MUTEX(ghes_list_mutex);
123129
*/
124130
static DEFINE_SPINLOCK(ghes_notify_lock_irq);
125131

132+
struct ghes_vendor_record_entry {
133+
struct work_struct work;
134+
int error_severity;
135+
char vendor_record[];
136+
};
137+
126138
static struct gen_pool *ghes_estatus_pool;
127139
static unsigned long ghes_estatus_pool_size_request;
128140

@@ -511,6 +523,56 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata)
511523
#endif
512524
}
513525

526+
static BLOCKING_NOTIFIER_HEAD(vendor_record_notify_list);
527+
528+
int ghes_register_vendor_record_notifier(struct notifier_block *nb)
529+
{
530+
return blocking_notifier_chain_register(&vendor_record_notify_list, nb);
531+
}
532+
EXPORT_SYMBOL_GPL(ghes_register_vendor_record_notifier);
533+
534+
void ghes_unregister_vendor_record_notifier(struct notifier_block *nb)
535+
{
536+
blocking_notifier_chain_unregister(&vendor_record_notify_list, nb);
537+
}
538+
EXPORT_SYMBOL_GPL(ghes_unregister_vendor_record_notifier);
539+
540+
static void ghes_vendor_record_work_func(struct work_struct *work)
541+
{
542+
struct ghes_vendor_record_entry *entry;
543+
struct acpi_hest_generic_data *gdata;
544+
u32 len;
545+
546+
entry = container_of(work, struct ghes_vendor_record_entry, work);
547+
gdata = GHES_GDATA_FROM_VENDOR_ENTRY(entry);
548+
549+
blocking_notifier_call_chain(&vendor_record_notify_list,
550+
entry->error_severity, gdata);
551+
552+
len = GHES_VENDOR_ENTRY_LEN(acpi_hest_get_record_size(gdata));
553+
gen_pool_free(ghes_estatus_pool, (unsigned long)entry, len);
554+
}
555+
556+
static void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
557+
int sev)
558+
{
559+
struct acpi_hest_generic_data *copied_gdata;
560+
struct ghes_vendor_record_entry *entry;
561+
u32 len;
562+
563+
len = GHES_VENDOR_ENTRY_LEN(acpi_hest_get_record_size(gdata));
564+
entry = (void *)gen_pool_alloc(ghes_estatus_pool, len);
565+
if (!entry)
566+
return;
567+
568+
copied_gdata = GHES_GDATA_FROM_VENDOR_ENTRY(entry);
569+
memcpy(copied_gdata, gdata, acpi_hest_get_record_size(gdata));
570+
entry->error_severity = sev;
571+
572+
INIT_WORK(&entry->work, ghes_vendor_record_work_func);
573+
schedule_work(&entry->work);
574+
}
575+
514576
static bool ghes_do_proc(struct ghes *ghes,
515577
const struct acpi_hest_generic_status *estatus)
516578
{
@@ -549,6 +611,7 @@ static bool ghes_do_proc(struct ghes *ghes,
549611
} else {
550612
void *err = acpi_hest_get_payload(gdata);
551613

614+
ghes_defer_non_standard_event(gdata, sev);
552615
log_non_standard_event(sec_type, fru_id, fru_text,
553616
sec_sev, err,
554617
gdata->error_data_length);

‎include/acpi/ghes.h‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ enum {
5353
GHES_SEV_PANIC = 0x3,
5454
};
5555

56+
#ifdef CONFIG_ACPI_APEI_GHES
57+
/**
58+
* ghes_register_vendor_record_notifier - register a notifier for vendor
59+
* records that the kernel would otherwise ignore.
60+
* @nb: pointer to the notifier_block structure of the event handler.
61+
*
62+
* return 0 : SUCCESS, non-zero : FAIL
63+
*/
64+
int ghes_register_vendor_record_notifier(struct notifier_block *nb);
65+
66+
/**
67+
* ghes_unregister_vendor_record_notifier - unregister the previously
68+
* registered vendor record notifier.
69+
* @nb: pointer to the notifier_block structure of the vendor record handler.
70+
*/
71+
void ghes_unregister_vendor_record_notifier(struct notifier_block *nb);
72+
#endif
73+
5674
int ghes_estatus_pool_init(int num_ghes);
5775

5876
/* From drivers/edac/ghes_edac.c */

0 commit comments

Comments
 (0)