From: Ruidong Tian <tianruidong@linux.alibaba.com>
To: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
alex@ghiti.fr, rafael@kernel.org, tony.luck@intel.com,
bp@alien8.de, guohanjun@huawei.com, mchehab@kernel.org,
xueshuai@linux.alibaba.com, lenb@kernel.org,
saket.dumbre@intel.com
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev,
Ruidong Tian <tianruidong@linux.alibaba.com>
Subject: [PATCH 2/3] riscv: Introduce HEST HEE notification handlers for APEI
Date: Fri, 8 May 2026 16:20:19 +0800 [thread overview]
Message-ID: <20260508082020.3368109-3-tianruidong@linux.alibaba.com> (raw)
In-Reply-To: <20260508082020.3368109-1-tianruidong@linux.alibaba.com>
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 <tianruidong@linux.alibaba.com>
---
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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-05-08 8:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 8:20 [PATCH 0/3] riscv: log Hardware Error Exception via APEI Ruidong Tian
2026-05-08 8:20 ` [PATCH 1/3] acpi: Introduce HEE in HEST notification types Ruidong Tian
2026-05-08 8:20 ` Ruidong Tian [this message]
2026-05-08 8:20 ` [PATCH 3/3] riscv: collect hardware error information via APEI on HEE Ruidong Tian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260508082020.3368109-3-tianruidong@linux.alibaba.com \
--to=tianruidong@linux.alibaba.com \
--cc=acpica-devel@lists.linux.dev \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=bp@alien8.de \
--cc=guohanjun@huawei.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=rafael@kernel.org \
--cc=saket.dumbre@intel.com \
--cc=tony.luck@intel.com \
--cc=xueshuai@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox