Add a global variable, ghes_recovered_erors, to count hardware errors classified as recoverable or corrected. This counter is exported and included in vmcoreinfo for post-crash diagnostics. Tracking this value helps operators potentially correlate hardware errors across system events and crash dumps, indicating that RAS logs might be useful while analyzing these crashes. This discussion and motivation could be found in [1]. Atomic operations are deliberately omitted, as precise accuracy is not required for this metric. Link: https://lore.kernel.org/all/20250704-taint_recovered-v1-0-7a817f2d228e@xxxxxxxxxx/#t [1] Suggested-by: Borislav Petkov <bp@xxxxxxxxx> Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx> --- drivers/acpi/apei/ghes.c | 15 +++++++++++++-- include/acpi/ghes.h | 2 ++ kernel/vmcore_info.c | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index f0584ccad4519..3735cfba17667 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -118,6 +118,12 @@ static inline bool is_hest_sync_notify(struct ghes *ghes) return notify_type == ACPI_HEST_NOTIFY_SEA; } +/* Count the number of hardware recovered errors, to be reported at + * crash/vmcore + */ +unsigned int ghes_recovered_erors; +EXPORT_SYMBOL_GPL(ghes_recovered_erors); + /* * This driver isn't really modular, however for the time being, * continuing to use module_param is the easiest way to remain @@ -1100,13 +1106,16 @@ static int ghes_proc(struct ghes *ghes) { struct acpi_hest_generic_status *estatus = ghes->estatus; u64 buf_paddr; - int rc; + int rc, sev; rc = ghes_read_estatus(ghes, estatus, &buf_paddr, FIX_APEI_GHES_IRQ); if (rc) goto out; - if (ghes_severity(estatus->error_severity) >= GHES_SEV_PANIC) + sev = ghes_severity(estatus->error_severity); + if (sev == GHES_SEV_RECOVERABLE || sev == GHES_SEV_CORRECTED) + ghes_recovered_erors += 1; + else if (sev >= GHES_SEV_PANIC) __ghes_panic(ghes, estatus, buf_paddr, FIX_APEI_GHES_IRQ); if (!ghes_estatus_cached(estatus)) { @@ -1750,6 +1759,8 @@ void __init acpi_ghes_init(void) pr_info(GHES_PFX "APEI firmware first mode is enabled by APEI bit.\n"); else pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n"); + + ghes_recovered_erors = 0; } /* diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index be1dd4c1a9174..4b6be6733f826 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -75,6 +75,8 @@ void ghes_unregister_vendor_record_notifier(struct notifier_block *nb); struct list_head *ghes_get_devices(void); void ghes_estatus_pool_region_free(unsigned long addr, u32 size); + +extern unsigned int ghes_recovered_erors; #else static inline struct list_head *ghes_get_devices(void) { return NULL; } diff --git a/kernel/vmcore_info.c b/kernel/vmcore_info.c index e066d31d08f89..cb2a7daef3a68 100644 --- a/kernel/vmcore_info.c +++ b/kernel/vmcore_info.c @@ -14,6 +14,7 @@ #include <linux/cpuhotplug.h> #include <linux/memblock.h> #include <linux/kmemleak.h> +#include <acpi/ghes.h> #include <asm/page.h> #include <asm/sections.h> @@ -223,6 +224,9 @@ static int __init crash_save_vmcoreinfo_init(void) VMCOREINFO_SYMBOL(kallsyms_offsets); VMCOREINFO_SYMBOL(kallsyms_relative_base); #endif /* CONFIG_KALLSYMS */ +#ifdef CONFIG_ACPI_APEI_GHES + VMCOREINFO_NUMBER(ghes_recovered_erors); +#endif arch_crash_save_vmcoreinfo(); update_vmcoreinfo_note(); --- base-commit: d7b8f8e20813f0179d8ef519541a3527e7661d3a change-id: 20250707-vmcore_hw_error-322429e6c316 Best regards, -- Breno Leitao <leitao@xxxxxxxxxx>