[PATCH 2/3] riscv: Introduce HEST HEE notification handlers for APEI
Ruidong Tian <[email protected]> Fri, 8 May 2026 16:20:19 +0800
| Newsgroups | dev.linux.lists.acpica-devel,org.infradead.lists.linux-riscv,org.kernel.vger.linux-acpi,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Add functions to register a ghes entry with HEE, allowing the OS to receive hardware error notifications from firmware through standardized ACPI interfaces. Signed-off-by: Ruidong Tian <[email protected]> --- arch/riscv/include/asm/fixmap.h | 3 ++ drivers/acpi/apei/Kconfig | 12 ++++++ drivers/acpi/apei/ghes.c | 68 ++++++++++++++++++++++++++++++++- include/acpi/ghes.h | 6 +++ 4 files changed, 87 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/fixmap.h b/arch/riscv/include/asm/fixmap.h index e874fd952286..9b3d5bbfda24 100644 --- a/arch/riscv/include/asm/fixmap.h +++ b/arch/riscv/include/asm/fixmap.h @@ -45,6 +45,9 @@ enum fixed_addresses { FIX_APEI_GHES_SSE_LOW_PRIORITY, FIX_APEI_GHES_SSE_HIGH_PRIORITY, #endif /* CONFIG_RISCV_SBI_SSE */ +#ifdef CONFIG_ACPI_APEI_HEE + FIX_APEI_GHES_HEE, +#endif /* CONFIG_ACPI_APEI_HEE */ #endif /* CONFIG_ACPI_APEI_GHES */ __end_of_permanent_fixed_addresses, /* diff --git a/drivers/acpi/apei/Kconfig b/drivers/acpi/apei/Kconfig index 895a843d0e36..ff487ab28a65 100644 --- a/drivers/acpi/apei/Kconfig +++ b/drivers/acpi/apei/Kconfig @@ -51,6 +51,18 @@ config ACPI_APEI_SSE depends on RISCV && RISCV_SBI_SSE && ACPI_APEI_GHES default y +config ACPI_APEI_HEE + bool "APEI Hardware Error Exception support" + depends on RISCV && ACPI_APEI_GHES + default y + help + Enable support for RISC-V Hardware Error Exception (HEE) notification + in ACPI Platform Error Interface (APEI). This allows firmware + to report hardware errors through RISC-V exception mechanism. + + Say Y if you want to support firmware-first error handling + on RISC-V platforms with ACPI. + config ACPI_APEI_MEMORY_FAILURE bool "APEI memory error recovering support" depends on ACPI_APEI && MEMORY_FAILURE diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index f228640d3f25..e0a5db80e554 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -125,7 +125,8 @@ static inline bool is_hest_sync_notify(struct ghes *ghes) { u8 notify_type = ghes->generic->notify.type; - return notify_type == ACPI_HEST_NOTIFY_SEA; + return notify_type == ACPI_HEST_NOTIFY_SEA || + notify_type == ACPI_HEST_NOTIFY_HEE; } /* @@ -1404,7 +1405,8 @@ static int ghes_in_nmi_queue_one_entry(struct ghes *ghes, return rc; } -#if defined(CONFIG_HAVE_ACPI_APEI_NMI) || defined(CONFIG_ACPI_APEI_SEA) +#if defined(CONFIG_HAVE_ACPI_APEI_NMI) || defined(CONFIG_ACPI_APEI_SEA) || \ + defined(CONFIG_ACPI_APEI_HEE) static int ghes_in_nmi_spool_from_list(struct list_head *rcu_list, enum fixed_addresses fixmap_idx) { @@ -1540,6 +1542,53 @@ static inline int ghes_sea_add(struct ghes *ghes) { return -EINVAL; } static inline void ghes_sea_remove(struct ghes *ghes) { } #endif /* CONFIG_ACPI_APEI_SEA */ +#ifdef CONFIG_ACPI_APEI_HEE +static LIST_HEAD(ghes_hee); + +/* + * Return 0 only if one of the HEE error sources successfully reported an error + * record sent from the firmware. + */ +int ghes_notify_hee(void) +{ + static DEFINE_RAW_SPINLOCK(ghes_notify_lock_hee); + int rv; + + raw_spin_lock(&ghes_notify_lock_hee); + rv = ghes_in_nmi_spool_from_list(&ghes_hee, FIX_APEI_GHES_HEE); + raw_spin_unlock(&ghes_notify_lock_hee); + + return rv; +} +EXPORT_SYMBOL_GPL(ghes_notify_hee); + +static int ghes_hee_add(struct ghes *ghes) +{ + int rc; + + rc = ghes_map_error_status(ghes); + if (rc) + return rc; + + mutex_lock(&ghes_list_mutex); + list_add_rcu(&ghes->list, &ghes_hee); + mutex_unlock(&ghes_list_mutex); + + return 0; +} + +static void ghes_hee_remove(struct ghes *ghes) +{ + mutex_lock(&ghes_list_mutex); + list_del_rcu(&ghes->list); + mutex_unlock(&ghes_list_mutex); + synchronize_rcu(); +} +#else /* CONFIG_ACPI_APEI_HEE */ +static inline void ghes_hee_add(struct ghes *ghes) { } +static inline void ghes_hee_remove(struct ghes *ghes) { } +#endif /* CONFIG_ACPI_APEI_HEE */ + #ifdef CONFIG_HAVE_ACPI_APEI_NMI /* * NMI may be triggered on any CPU, so ghes_in_nmi is used for @@ -1754,6 +1803,13 @@ static int ghes_probe(struct platform_device *ghes_dev) goto err; } break; + case ACPI_HEST_NOTIFY_HEE: + if (!IS_ENABLED(CONFIG_ACPI_APEI_HEE)) { + pr_warn(GHES_PFX "Generic hardware error source: %d notified via HEE is not supported\n", + generic->header.source_id); + goto err; + } + break; case ACPI_HEST_NOTIFY_NMI: if (!IS_ENABLED(CONFIG_HAVE_ACPI_APEI_NMI)) { pr_warn(GHES_PFX "Generic hardware error source: %d notified via NMI interrupt is not supported!\n", @@ -1837,6 +1893,11 @@ static int ghes_probe(struct platform_device *ghes_dev) if (rc) goto err; break; + case ACPI_HEST_NOTIFY_HEE: + rc = ghes_hee_add(ghes); + if (rc) + goto err; + break; case ACPI_HEST_NOTIFY_NMI: rc = ghes_nmi_add(ghes); if (rc) @@ -1917,6 +1978,9 @@ static void ghes_remove(struct platform_device *ghes_dev) case ACPI_HEST_NOTIFY_SEA: ghes_sea_remove(ghes); break; + case ACPI_HEST_NOTIFY_HEE: + ghes_hee_remove(ghes); + break; case ACPI_HEST_NOTIFY_NMI: ghes_nmi_remove(ghes); break; diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index 8d7e5caef3f1..bf4f6077ca39 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -140,6 +140,12 @@ int ghes_notify_sea(void); static inline int ghes_notify_sea(void) { return -ENOENT; } #endif +#ifdef CONFIG_ACPI_APEI_HEE +int ghes_notify_hee(void); +#else +static inline int ghes_notify_hee(void) { return -ENOENT; } +#endif + struct notifier_block; extern void ghes_register_report_chain(struct notifier_block *nb); extern void ghes_unregister_report_chain(struct notifier_block *nb); -- 2.51.2.612.gdc70283dfc