From: Ahmed Tiba <ahmed.tiba@arm.com>
To: linux-acpi@vger.kernel.org, devicetree@vger.kernel.org
Cc: tony.luck@intel.com, bp@alien8.de, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, catalin.marinas@arm.com,
will@kernel.org, linux-arm-kernel@lists.infradead.org,
rafael@kernel.org, linux-doc@vger.kernel.org,
Dmitry.Lamerov@arm.com, Michael.Zhao2@arm.com,
ahmed.tiba@arm.com
Subject: [PATCH 01/12] ras: add estatus core interfaces
Date: Wed, 17 Dec 2025 11:28:34 +0000 [thread overview]
Message-ID: <20251217112845.1814119-2-ahmed.tiba@arm.com> (raw)
In-Reply-To: <20251217112845.1814119-1-ahmed.tiba@arm.com>
Introduce CONFIG_RAS_ESTATUS_CORE and the public header that exposes
the generic error-status abstractions. Nothing uses the option yet, but
the definitions are shared by both GHES and the forthcoming DeviceTree
provider, so land them ahead of the core implementation.
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
MAINTAINERS | 5 +
drivers/firmware/efi/Kconfig | 11 ++
include/linux/estatus.h | 267 +++++++++++++++++++++++++++++++++++
3 files changed, 283 insertions(+)
create mode 100644 include/linux/estatus.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 5b11839cba9d..501b6d300aa5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -21757,6 +21757,11 @@ M: Alexandre Bounine <alex.bou9@gmail.com>
S: Maintained
F: drivers/rapidio/
+RAS ERROR STATUS
+M: Ahmed Tiba <ahmed.tiba@arm.com>
+S: Maintained
+F: include/linux/estatus.h
+
RAS INFRASTRUCTURE
M: Tony Luck <tony.luck@intel.com>
M: Borislav Petkov <bp@alien8.de>
diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig
index 29e0729299f5..d348ceb81cfb 100644
--- a/drivers/firmware/efi/Kconfig
+++ b/drivers/firmware/efi/Kconfig
@@ -329,6 +329,17 @@ config UEFI_CPER_X86
depends on UEFI_CPER && X86
default y
+config RAS_ESTATUS_CORE
+ bool "Firmware-first estatus processing core"
+ depends on UEFI_CPER
+ select GENERIC_ALLOCATOR
+ help
+ Provide the shared Common Platform Error Record (CPER) handling core
+ that firmware-first error sources reuse to read, cache, log, and
+ dispatch Generic Hardware Error Status Blocks. This gets selected
+ automatically by providers such as ACPI APEI GHES or the DeviceTree
+ estatus driver.
+
config TEE_STMM_EFI
tristate "TEE-based EFI runtime variable service driver"
depends on EFI && OPTEE
diff --git a/include/linux/estatus.h b/include/linux/estatus.h
new file mode 100644
index 000000000000..002a9533c85a
--- /dev/null
+++ b/include/linux/estatus.h
@@ -0,0 +1,267 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Firmware-first RAS: Generic Error Status Core
+ *
+ * Copyright (C) 2025 ARM Ltd.
+ * Author: Ahmed Tiba <ahmed.tiba@arm.com>
+ */
+
+#ifndef __LINUX_ESTATUS_H
+#define __LINUX_ESTATUS_H
+
+/* "estatus" abbreviates "error status" (CPER status blocks). */
+
+/*
+ * "estatus" is a contraction of "error status". The naming mirrors the ACPI
+ * Generic Error Status Block (HEST/CPER) terminology while staying agnostic of
+ * the transport (ACPI, DeviceTree, etc.).
+ */
+
+#include <linux/irq_work.h>
+#include <linux/kconfig.h>
+#include <linux/cper.h>
+#include <asm/fixmap.h>
+
+#if IS_ENABLED(CONFIG_ACPI)
+#include <linux/acpi.h>
+#include <acpi/actbl1.h>
+#define estatus_generic_status struct acpi_hest_generic_status
+#define estatus_generic_data struct acpi_hest_generic_data
+#define estatus_generic_data_v300 struct acpi_hest_generic_data_v300
+#else
+struct estatus_generic_status {
+ u32 block_status;
+ u32 raw_data_offset;
+ u32 raw_data_length;
+ u32 data_length;
+ u32 error_severity;
+} __packed;
+
+struct estatus_generic_data {
+ u8 section_type[16];
+ u32 error_severity;
+ u16 revision;
+ u8 validation_bits;
+ u8 flags;
+ u32 error_data_length;
+ u8 fru_id[16];
+ u8 fru_text[20];
+} __packed;
+
+struct estatus_generic_data_v300 {
+ u8 section_type[16];
+ u32 error_severity;
+ u16 revision;
+ u8 validation_bits;
+ u8 flags;
+ u32 error_data_length;
+ u8 fru_id[16];
+ u8 fru_text[20];
+ u64 time_stamp;
+} __packed;
+
+#define estatus_generic_status struct estatus_generic_status
+#define estatus_generic_data struct estatus_generic_data
+#define estatus_generic_data_v300 struct estatus_generic_data_v300
+
+#define acpi_hest_generic_status estatus_generic_status
+#define acpi_hest_generic_data estatus_generic_data
+#define acpi_hest_generic_data_v300 estatus_generic_data_v300
+#endif
+
+struct estatus_source;
+
+#if IS_ENABLED(CONFIG_ACPI_APEI_GHES)
+#include <acpi/apei.h>
+#endif
+
+void estatus_report_mem_error(int sev, struct cper_sec_mem_err *mem_err);
+
+enum estatus_notify_mode {
+ ESTATUS_NOTIFY_ASYNC,
+ ESTATUS_NOTIFY_SEA,
+};
+
+struct estatus_ops {
+ int (*get_phys)(struct estatus_source *source, phys_addr_t *addr);
+ int (*read)(struct estatus_source *source, phys_addr_t addr,
+ void *buf, size_t len, enum fixed_addresses fixmap_idx);
+ int (*write)(struct estatus_source *source, phys_addr_t addr,
+ const void *buf, size_t len, enum fixed_addresses fixmap_idx);
+ void (*ack)(struct estatus_source *source);
+ size_t (*get_max_len)(struct estatus_source *source);
+ enum estatus_notify_mode (*get_notify_mode)(struct estatus_source *source);
+ const char *(*get_name)(struct estatus_source *source);
+};
+
+struct estatus_source {
+ const struct estatus_ops *ops;
+ void *priv;
+ estatus_generic_status *estatus;
+ enum fixed_addresses fixmap_idx;
+};
+
+struct estatus_node {
+ struct llist_node llnode;
+ struct estatus_source *source;
+};
+
+struct estatus_cache {
+ u32 estatus_len;
+ atomic_t count;
+ struct estatus_source *source;
+ unsigned long long time_in;
+ struct rcu_head rcu;
+};
+
+enum {
+ ESTATUS_SEV_NO = 0x0,
+ ESTATUS_SEV_CORRECTED = 0x1,
+ ESTATUS_SEV_RECOVERABLE = 0x2,
+ ESTATUS_SEV_PANIC = 0x3,
+};
+
+int estatus_proc(struct estatus_source *ghes);
+int estatus_in_nmi_queue_one_entry(struct estatus_source *ghes,
+ enum fixed_addresses fixmap_idx);
+void estatus_proc_in_irq(struct irq_work *irq_work);
+
+/**
+ * estatus_register_vendor_record_notifier - register a notifier for vendor
+ * records that the kernel would otherwise ignore.
+ * @nb: pointer to the notifier_block structure of the event handler.
+ *
+ * return 0 : SUCCESS, non-zero : FAIL
+ */
+int estatus_register_vendor_record_notifier(struct notifier_block *nb);
+
+/**
+ * estatus_unregister_vendor_record_notifier - unregister the previously
+ * registered vendor record notifier.
+ * @nb: pointer to the notifier_block structure of the vendor record handler.
+ */
+void estatus_unregister_vendor_record_notifier(struct notifier_block *nb);
+
+int estatus_pool_init(unsigned int num_ghes);
+
+struct notifier_block;
+void estatus_register_report_chain(struct notifier_block *nb);
+void estatus_unregister_report_chain(struct notifier_block *nb);
+
+static inline int estatus_get_version(estatus_generic_data *gdata)
+{
+ return gdata->revision >> 8;
+}
+
+static inline void *estatus_get_payload(estatus_generic_data *gdata)
+{
+ if (estatus_get_version(gdata) >= 3)
+ return (void *)(((estatus_generic_data_v300 *)(gdata)) + 1);
+
+ return gdata + 1;
+}
+
+static inline int estatus_get_error_length(estatus_generic_data *gdata)
+{
+ return gdata->error_data_length;
+}
+
+static inline int estatus_get_size(estatus_generic_data *gdata)
+{
+ if (estatus_get_version(gdata) >= 3)
+ return sizeof(estatus_generic_data_v300);
+
+ return sizeof(estatus_generic_data);
+}
+
+static inline int estatus_get_record_size(estatus_generic_data *gdata)
+{
+ return (estatus_get_size(gdata) + estatus_get_error_length(gdata));
+}
+
+static inline void *estatus_get_next(estatus_generic_data *gdata)
+{
+ return (void *)(gdata) + estatus_get_record_size(gdata);
+}
+
+static inline estatus_generic_data *
+estatus_first_section(estatus_generic_status *estatus)
+{
+ return (estatus_generic_data *)(estatus + 1);
+}
+
+static inline bool
+estatus_section_valid(estatus_generic_status *estatus,
+ estatus_generic_data *section)
+{
+ return (void *)section - (void *)(estatus + 1) < estatus->data_length;
+}
+
+struct estatus_section_iter {
+ estatus_generic_status *estatus;
+ estatus_generic_data *section;
+ bool started;
+};
+
+static inline estatus_generic_data *
+estatus_section_iter_next(struct estatus_section_iter *iter,
+ estatus_generic_status *estatus)
+{
+ if (!iter->started) {
+ iter->estatus = estatus;
+ iter->section = estatus_first_section(estatus);
+ iter->started = true;
+ } else if (iter->section) {
+ iter->section = estatus_get_next(iter->section);
+ }
+
+ if (!iter->section)
+ return NULL;
+
+ if (!estatus_section_valid(iter->estatus, iter->section)) {
+ iter->section = NULL;
+ return NULL;
+ }
+
+ return iter->section;
+}
+
+#define estatus_for_each_section(_estatus, _section) \
+ for (struct estatus_section_iter __estatus_iter = {0}; \
+ ((_section) = estatus_section_iter_next(&__estatus_iter, (_estatus))); \
+ )
+
+static inline int acpi_hest_get_version(struct acpi_hest_generic_data *gdata)
+{
+ return estatus_get_version(gdata);
+}
+
+static inline void *acpi_hest_get_payload(struct acpi_hest_generic_data *gdata)
+{
+ return estatus_get_payload(gdata);
+}
+
+static inline int acpi_hest_get_error_length(struct acpi_hest_generic_data *gdata)
+{
+ return estatus_get_error_length(gdata);
+}
+
+static inline int acpi_hest_get_size(struct acpi_hest_generic_data *gdata)
+{
+ return estatus_get_size(gdata);
+}
+
+static inline int acpi_hest_get_record_size(struct acpi_hest_generic_data *gdata)
+{
+ return estatus_get_record_size(gdata);
+}
+
+static inline void *acpi_hest_get_next(struct acpi_hest_generic_data *gdata)
+{
+ return estatus_get_next(gdata);
+}
+
+#define apei_estatus_for_each_section(estatus, section) \
+ estatus_for_each_section(estatus, section)
+
+#endif
--
2.43.0
next prev parent reply other threads:[~2025-12-17 11:29 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-17 11:28 [PATCH 00/12] ras: share firmware-first estatus handling Ahmed Tiba
2025-12-17 11:28 ` Ahmed Tiba [this message]
2025-12-17 11:28 ` [PATCH 02/12] ras: add estatus core implementation Ahmed Tiba
2025-12-18 15:42 ` Mauro Carvalho Chehab
2025-12-19 14:35 ` Ahmed Tiba
2025-12-21 19:31 ` kernel test robot
2025-12-17 11:28 ` [PATCH 03/12] ras: add estatus vendor handling and processing Ahmed Tiba
2025-12-18 16:04 ` Mauro Carvalho Chehab
2025-12-19 14:49 ` Ahmed Tiba
2025-12-19 15:30 ` Mauro Carvalho Chehab
2025-12-19 18:11 ` Ahmed Tiba
2025-12-22 8:13 ` Mauro Carvalho Chehab
2025-12-29 15:01 ` Ahmed Tiba
2025-12-21 23:39 ` kernel test robot
2025-12-17 11:28 ` [PATCH 04/12] ras: add estatus queuing and IRQ/NMI handling Ahmed Tiba
2025-12-17 11:28 ` [PATCH 05/12] ras: flesh out estatus processing core Ahmed Tiba
2025-12-17 11:28 ` [PATCH 06/12] efi/cper: adopt estatus iteration helpers Ahmed Tiba
2025-12-17 11:28 ` [PATCH 07/12] ghes: prepare estatus hooks for shared handling Ahmed Tiba
2025-12-17 11:28 ` [PATCH 08/12] ghes: add estatus provider ops Ahmed Tiba
2025-12-17 11:28 ` [PATCH 09/12] ghes: route error handling through shared estatus core Ahmed Tiba
2025-12-17 11:28 ` [PATCH 10/12] dt-bindings: ras: document estatus provider Ahmed Tiba
2025-12-17 11:41 ` Krzysztof Kozlowski
2025-12-17 17:49 ` Ahmed Tiba
2025-12-18 6:48 ` Krzysztof Kozlowski
2025-12-18 10:22 ` Ahmed Tiba
2025-12-18 10:31 ` Ahmed Tiba
2025-12-19 9:53 ` Krzysztof Kozlowski
2025-12-19 10:37 ` Ahmed Tiba
2025-12-19 10:47 ` Ahmed Tiba
2025-12-17 11:28 ` [PATCH 11/12] ras: add DeviceTree estatus provider driver Ahmed Tiba
2025-12-18 12:13 ` Will Deacon
2025-12-18 13:42 ` Ahmed Tiba
2025-12-18 15:19 ` Will Deacon
2025-12-19 9:02 ` Ahmed Tiba
2025-12-19 13:00 ` Will Deacon
2025-12-19 17:21 ` Ahmed Tiba
2026-01-05 21:09 ` Will Deacon
2025-12-17 11:28 ` [PATCH 12/12] doc: ras: describe firmware-first estatus flow Ahmed Tiba
2025-12-21 1:35 ` [PATCH 00/12] ras: share firmware-first estatus handling Borislav Petkov
2025-12-29 11:54 ` Ahmed Tiba
2026-01-14 14:15 ` Borislav Petkov
2026-01-15 12:17 ` Ahmed Tiba
2026-01-20 11:15 ` Borislav Petkov
2026-01-26 10:58 ` Ahmed Tiba
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=20251217112845.1814119-2-ahmed.tiba@arm.com \
--to=ahmed.tiba@arm.com \
--cc=Dmitry.Lamerov@arm.com \
--cc=Michael.Zhao2@arm.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=tony.luck@intel.com \
--cc=will@kernel.org \
/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