* [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider
@ 2026-12-03 13:40 Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 01/22] ACPI: APEI: GHES: wait for RCU readers before unmapping Ahmed Tiba
` (21 more replies)
0 siblings, 22 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
This is v8 of the GHES refactor series, rebased onto v7.4-rc5.
The rebase incorporates the relevant fixes already present in v7.4-rc5.
Separate preparatory patches address the remaining findings reported by
Sashiko. These functional fixes are kept separate from the mechanical
GHES CPER helper movements to simplify review.
Changes in v8:
- Rebase the series onto v7.4-rc5.
- Retain the relevant fixes that landed upstream after v7.
- Add separate preparatory patches for the remaining Sashiko findings.
- Wait for RCU readers before unmapping GHES error status registers.
- Avoid traversing the GHES device list from the EDAC driver.
- Track the error status pool allocation size used for queued records.
- Drain deferred IRQ work before releasing a GHES source.
- Apply GHESv2 read-acknowledge masks without an additional shift.
- Revalidate the error status length after copying the complete record.
- Free an error status cache entry when no cache slot can be selected.
- Include architecture ACPI declarations directly from efi/cper.
- Permit multiple users to extend the shared error status pool.
- Keep task-work allocations valid until error reporting completes.
- Reset FRU metadata for every CPER section.
- Validate the remaining length before reading a CPER section.
- Keep the original GHES CPER helper movement patches mechanical.
Link to v7: https://lore.kernel.org/r/20260708-topics-ahmtib01-ras_ffh_arm_internal_review-v7-0-8b3a85216cef@arm.com
---
Ahmed Tiba (22):
ACPI: APEI: GHES: wait for RCU readers before unmapping
EDAC: ghes: avoid traversing the GHES device list
ACPI: APEI: GHES: track error status pool allocation size
ACPI: APEI: GHES: drain deferred work before freeing a source
ACPI: APEI: GHES: apply read-acknowledge masks directly
ACPI: APEI: GHES: revalidate the error status length after copying
ACPI: APEI: GHES: free an estatus cache entry when no slot is found
efi/cper: include architecture ACPI declarations directly
ACPI: APEI: GHES: allow the error status pool to be extended
ACPI: APEI: GHES: keep task work valid through error reporting
ACPI: APEI: GHES: reset FRU metadata for each CPER section
efi/cper: validate the remaining length before reading a section
ACPI: APEI: GHES: share macros via a private header
ACPI: APEI: GHES: move CPER read helpers
ACPI: APEI: GHES: move GHESv2 ack and alloc helpers
ACPI: APEI: GHES: move estatus cache helpers
ACPI: APEI: GHES: move vendor record helpers
ACPI: APEI: GHES: move CXL CPER helpers
ACPI: APEI: introduce GHES CPER helper configuration
ACPI: APEI: share GHES CPER helpers
dt-bindings: firmware: add arm,ras-cper
RAS: add firmware-first CPER provider
Documentation/admin-guide/RAS/main.rst | 15 +
.../devicetree/bindings/firmware/arm,ras-cper.yaml | 52 +
MAINTAINERS | 6 +
drivers/Makefile | 2 +
drivers/acpi/Kconfig | 9 +
drivers/acpi/acpi_extlog.c | 7 +-
drivers/acpi/apei/Kconfig | 2 +
drivers/acpi/apei/Makefile | 1 -
drivers/acpi/apei/ghes.c | 1129 +------------------
drivers/acpi/apei/ghes_cper.c | 1159 ++++++++++++++++++++
drivers/edac/ghes_edac.c | 38 +-
drivers/firmware/efi/cper-x86.c | 1 +
drivers/firmware/efi/cper.c | 3 +
drivers/pci/pcie/aer.c | 4 +-
drivers/ras/Kconfig | 13 +
drivers/ras/Makefile | 1 +
drivers/ras/cper-esource.c | 356 ++++++
include/acpi/ghes.h | 11 +-
include/acpi/ghes_cper.h | 154 +++
include/cxl/event.h | 4 +-
20 files changed, 1825 insertions(+), 1142 deletions(-)
---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
change-id: 20260220-topics-ahmtib01-ras_ffh_arm_internal_review-bfddc7fc7cab
Best regards,
--
Ahmed Tiba <ahmed.tiba@arm.com>
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v8 01/22] ACPI: APEI: GHES: wait for RCU readers before unmapping
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 02/22] EDAC: ghes: avoid traversing the GHES device list Ahmed Tiba
` (20 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
ghes_has_active_errors() walks the SEA and NMI source lists under RCU
and reads the mapped error status register for each source. The
corresponding removal paths delete the source from the list, but unmap
the register before waiting for existing RCU readers.
A reader that obtained the source before list_del_rcu() can therefore
dereference the mapping after it has been released. Keep the mapping
valid until synchronize_rcu() has drained those readers.
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/message/20260708141859.0FA971F000E9%40smtp.kernel.org
Fixes: f2edc1fb9c81 ("ACPI: APEI: GHES: Improve ghes_notify_nmi() status check")
Fixes: b73cf7eaa6ee ("ACPI: APEI: GHES: Improve ghes_notify_sea() status check")
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 5d888c82efea..18dc77491277 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -1598,8 +1598,10 @@ static void ghes_sea_remove(struct ghes *ghes)
mutex_lock(&ghes_list_mutex);
list_del_rcu(&ghes->list);
mutex_unlock(&ghes_list_mutex);
- ghes_unmap_error_status(ghes);
+
+ /* Wait for RCU readers before unmapping the error status. */
synchronize_rcu();
+ ghes_unmap_error_status(ghes);
}
#else /* CONFIG_ACPI_APEI_SEA */
static inline int ghes_sea_add(struct ghes *ghes) { return -EINVAL; }
@@ -1660,13 +1662,12 @@ static void ghes_nmi_remove(struct ghes *ghes)
unregister_nmi_handler(NMI_LOCAL, "ghes");
mutex_unlock(&ghes_list_mutex);
- ghes_unmap_error_status(ghes);
-
/*
* To synchronize with NMI handler, ghes can only be
* freed after NMI handler finishes.
*/
synchronize_rcu();
+ ghes_unmap_error_status(ghes);
}
#else /* CONFIG_HAVE_ACPI_APEI_NMI */
static inline int ghes_nmi_add(struct ghes *ghes) { return -EINVAL; }
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 02/22] EDAC: ghes: avoid traversing the GHES device list
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 01/22] ACPI: APEI: GHES: wait for RCU readers before unmapping Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 03/22] ACPI: APEI: GHES: track error status pool allocation size Ahmed Tiba
` (19 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
ghes_edac_init() and ghes_edac_exit() walk the global GHES device list
without the mutex used by GHES probe and removal. Concurrent device
removal can therefore invalidate an entry while EDAC is traversing it.
GHES EDAC exposes one logical memory controller and receives reports
through the global GHES notifier chain, so it only needs one GHES device
as the parent of the controller. Find a device bound to the built-in
GHES driver through the driver core and retain the device reference until
module exit. This removes the EDAC dependency on the lifetime of struct
ghes and the associated list entry.
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/message/20260708141859.0FA971F000E9%40smtp.kernel.org
Fixes: 802e7f1dfed7 ("EDAC/ghes: Make ghes_edac a proper module")
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/edac/ghes_edac.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
index d80c88818691..df36b3b9d8dd 100644
--- a/drivers/edac/ghes_edac.c
+++ b/drivers/edac/ghes_edac.c
@@ -15,6 +15,8 @@
#include "edac_module.h"
#include <ras/ras_event.h>
#include <linux/notifier.h>
+#include <linux/device/driver.h>
+#include <linux/platform_device.h>
#include <linux/string.h>
#define OTHER_DETAIL_LEN 400
@@ -57,7 +59,7 @@ static DEFINE_SPINLOCK(ghes_lock);
static bool system_scanned;
-static struct list_head *ghes_devs;
+static struct device *ghes_dev;
/* Memory Device - Type 17 of SMBIOS spec */
struct memdev_dmi_entry {
@@ -505,7 +507,7 @@ static int ghes_edac_register(struct device *dev)
return rc;
}
-static void ghes_edac_unregister(struct ghes *ghes)
+static void ghes_edac_unregister(void)
{
struct mem_ctl_info *mci;
unsigned long flags;
@@ -541,32 +543,34 @@ static void ghes_edac_unregister(struct ghes *ghes)
static int __init ghes_edac_init(void)
{
- struct ghes *g, *g_tmp;
+ struct device_driver *drv;
+ int ret;
- ghes_devs = ghes_get_devices();
- if (!ghes_devs)
+ if (!ghes_get_devices())
return -ENODEV;
- if (list_empty(ghes_devs)) {
- pr_info("GHES probing device list is empty\n");
+ /* GHES is built in, so the driver cannot be unloaded. */
+ drv = driver_find("GHES", &platform_bus_type);
+ if (!drv)
return -ENODEV;
- }
- list_for_each_entry_safe(g, g_tmp, ghes_devs, elist) {
- ghes_edac_register(g->dev);
- }
+ /* All GHES sources share one logical EDAC controller. */
+ ghes_dev = driver_find_next_device(drv, NULL);
+ if (!ghes_dev)
+ return -ENODEV;
- return 0;
+ ret = ghes_edac_register(ghes_dev);
+ if (ret)
+ put_device(ghes_dev);
+
+ return ret;
}
module_init(ghes_edac_init);
static void __exit ghes_edac_exit(void)
{
- struct ghes *g, *g_tmp;
-
- list_for_each_entry_safe(g, g_tmp, ghes_devs, elist) {
- ghes_edac_unregister(g);
- }
+ ghes_edac_unregister();
+ put_device(ghes_dev);
}
module_exit(ghes_edac_exit);
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 03/22] ACPI: APEI: GHES: track error status pool allocation size
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 01/22] ACPI: APEI: GHES: wait for RCU readers before unmapping Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 02/22] EDAC: ghes: avoid traversing the GHES device list Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 04/22] ACPI: APEI: GHES: drain deferred work before freeing a source Ahmed Tiba
` (18 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
ghes_in_nmi_queue_one_entry() allocates a queue node using the error
status length read from the initial header. The subsequent full read
accepts a shorter error status, but ghes_proc_in_irq() recalculates the
size to free from that shorter record. This leaves part of the original
allocation in ghes_estatus_pool permanently allocated.
Store the allocation size in the queue node and use it whenever the node
is returned to the pool.
Fixes: d9f608dc1564 ("ACPI / APEI: Only use queued estatus entry during in_nmi_queue_one_entry()")
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/message/20260708141940.75EA51F000E9%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 8 +++-----
include/acpi/ghes.h | 1 +
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 18dc77491277..03eee0b2500e 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -1348,7 +1348,6 @@ static void ghes_proc_in_irq(struct irq_work *irq_work)
struct ghes_estatus_node *estatus_node;
struct acpi_hest_generic *generic;
struct acpi_hest_generic_status *estatus;
- u32 len, node_len;
llnode = llist_del_all(&ghes_estatus_llist);
/*
@@ -1361,8 +1360,6 @@ static void ghes_proc_in_irq(struct irq_work *irq_work)
estatus_node = llist_entry(llnode, struct ghes_estatus_node,
llnode);
estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
- len = cper_estatus_len(estatus);
- node_len = GHES_ESTATUS_NODE_LEN(len);
ghes_do_proc(estatus_node->ghes, estatus);
@@ -1372,7 +1369,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work)
ghes_estatus_cache_add(generic, estatus);
}
gen_pool_free(ghes_estatus_pool, (unsigned long)estatus_node,
- node_len);
+ estatus_node->node_len);
llnode = next;
}
@@ -1431,6 +1428,7 @@ static int ghes_in_nmi_queue_one_entry(struct ghes *ghes,
if (!estatus_node)
return -ENOMEM;
+ estatus_node->node_len = node_len;
estatus_node->ghes = ghes;
estatus_node->generic = ghes->generic;
estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
@@ -1467,7 +1465,7 @@ static int ghes_in_nmi_queue_one_entry(struct ghes *ghes,
no_work:
gen_pool_free(ghes_estatus_pool, (unsigned long)estatus_node,
- node_len);
+ estatus_node->node_len);
return rc;
}
diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h
index 7acf209061ea..56274dbe3bff 100644
--- a/include/acpi/ghes.h
+++ b/include/acpi/ghes.h
@@ -37,6 +37,7 @@ struct ghes_estatus_node {
struct llist_node llnode;
struct acpi_hest_generic *generic;
struct ghes *ghes;
+ u32 node_len;
};
struct ghes_estatus_cache {
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 04/22] ACPI: APEI: GHES: drain deferred work before freeing a source
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (2 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 03/22] ACPI: APEI: GHES: track error status pool allocation size Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 14:00 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 05/22] ACPI: APEI: GHES: apply read-acknowledge masks directly Ahmed Tiba
` (17 subsequent siblings)
21 siblings, 1 reply; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
Queued error status nodes retain a pointer to their struct ghes so that
ghes_proc_in_irq() can process the record later. Device removal stops new
notifications, but it can free that source while previously queued IRQ
work still holds the pointer.
Drain the global IRQ work after unregistering the notification source and
before releasing the GHES resources.
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/message/20260617140908.9FEA81F000E9%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 03eee0b2500e..dd3a698990e2 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -1926,6 +1926,7 @@ static void ghes_remove(struct platform_device *ghes_dev)
break;
}
+ irq_work_sync(&ghes_proc_irq_work);
ghes_fini(ghes);
mutex_lock(&ghes_devs_mutex);
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 05/22] ACPI: APEI: GHES: apply read-acknowledge masks directly
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (3 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 04/22] ACPI: APEI: GHES: drain deferred work before freeing a source Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:58 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 06/22] ACPI: APEI: GHES: revalidate the error status length after copying Ahmed Tiba
` (16 subsequent siblings)
21 siblings, 1 reply; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
apei_read() and apei_write() operate on the value described by the Generic
Address Structure and already account for its bit offset. Shifting the
GHESv2 Read Ack Preserve and Write masks by that offset a second time can
modify the wrong bits and fail to acknowledge an error source.
Apply the firmware-provided masks directly to the value returned by
apei_read().
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/message/20260617141511.F13231F000E9%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index dd3a698990e2..6344bfc15a50 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -260,8 +260,8 @@ static void ghes_ack_error(struct acpi_hest_generic_v2 *gv2)
if (rc)
return;
- val &= gv2->read_ack_preserve << gv2->read_ack_register.bit_offset;
- val |= gv2->read_ack_write << gv2->read_ack_register.bit_offset;
+ val &= gv2->read_ack_preserve;
+ val |= gv2->read_ack_write;
apei_write(val, &gv2->read_ack_register);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 06/22] ACPI: APEI: GHES: revalidate the error status length after copying
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (4 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 05/22] ACPI: APEI: GHES: apply read-acknowledge masks directly Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 07/22] ACPI: APEI: GHES: free an estatus cache entry when no slot is found Ahmed Tiba
` (15 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
GHES first reads an error status header to validate its length and size the
destination buffer, then copies the complete status block. Firmware can
change the header between those operations. If the second header reports a
larger length, cper_estatus_check() can walk beyond the copied buffer.
Recalculate the length after the full copy and reject records that are
shorter than the status header or larger than the supplied buffer.
Fixes: e00a6e3392cb ("ACPI / APEI: Split ghes_read_estatus() to allow a peek at the CPER length")
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/message/20260617141511.F13231F000E9%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 6344bfc15a50..d4ddf3c79216 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -421,7 +421,21 @@ static int __ghes_read_estatus(struct acpi_hest_generic_status *estatus,
u64 buf_paddr, enum fixed_addresses fixmap_idx,
size_t buf_len)
{
+ u32 len;
+
ghes_copy_tofrom_phys(estatus, buf_paddr, buf_len, 1, fixmap_idx);
+
+ len = cper_estatus_len(estatus);
+ if (len < sizeof(*estatus)) {
+ pr_warn_ratelimited(FW_WARN GHES_PFX "Truncated error status block!\n");
+ return -EIO;
+ }
+
+ if (len > buf_len) {
+ pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid error status block length!\n");
+ return -EIO;
+ }
+
if (cper_estatus_check(estatus)) {
pr_warn_ratelimited(FW_WARN GHES_PFX
"Failed to read error status block!\n");
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 07/22] ACPI: APEI: GHES: free an estatus cache entry when no slot is found
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (5 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 06/22] ACPI: APEI: GHES: revalidate the error status length after copying Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:53 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 08/22] efi/cper: include architecture ACPI declarations directly Ahmed Tiba
` (14 subsequent siblings)
21 siblings, 1 reply; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
ghes_estatus_cache_add() allocates a new cache entry before looking for a
slot. If every populated slot has a zero average period, the selection loop
can leave slot at -1. The unpublished entry and its allocation counter are
then leaked.
Return the entry to ghes_estatus_pool and balance the allocation counter
when no slot is selected.
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/message/20260617141000.8392A1F000E9%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index d4ddf3c79216..b38806d205ab 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -1233,6 +1233,10 @@ ghes_estatus_cache_add(struct acpi_hest_generic *generic,
if (victim)
call_rcu(&unrcu_pointer(victim)->rcu,
ghes_estatus_cache_rcu_free);
+ } else {
+ gen_pool_free(ghes_estatus_pool, (unsigned long)new_cache,
+ GHES_ESTATUS_CACHE_LEN(new_cache->estatus_len));
+ atomic_dec(&ghes_estatus_cache_alloced);
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 08/22] efi/cper: include architecture ACPI declarations directly
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (6 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 07/22] ACPI: APEI: GHES: free an estatus cache entry when no slot is found Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 09/22] ACPI: APEI: GHES: allow the error status pool to be extended Ahmed Tiba
` (13 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
cper-x86.c calls arch_apei_report_x86_error(), whose declaration is
provided by asm/acpi.h. The declaration is currently available only through
an indirect include when ACPI is enabled, which breaks configurations that
build the CPER decoder without ACPI.
Include asm/acpi.h directly so the dependency is explicit and the decoder
also builds in ACPI-disabled configurations.
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/patchset/20260708-topics-ahmtib01-ras_ffh_arm_internal_review-v7-0-8b3a85216cef%40arm.com?part=7
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/firmware/efi/cper-x86.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/firmware/efi/cper-x86.c b/drivers/firmware/efi/cper-x86.c
index 3949d7b5e808..aa9388284e65 100644
--- a/drivers/firmware/efi/cper-x86.c
+++ b/drivers/firmware/efi/cper-x86.c
@@ -3,6 +3,7 @@
#include <linux/cper.h>
#include <linux/acpi.h>
+#include <asm/acpi.h>
/*
* We don't need a "CPER_IA" prefix since these are all locally defined.
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 09/22] ACPI: APEI: GHES: allow the error status pool to be extended
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (7 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 08/22] efi/cper: include architecture ACPI declarations directly Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 10/22] ACPI: APEI: GHES: keep task work valid through error reporting Ahmed Tiba
` (12 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
ghes_estatus_pool_init() always creates a new pool, overwriting the global
pointer. This is sufficient while GHES is its only caller, but additional
firmware-first providers need to contribute capacity to the same pool.
Concurrent initialization could also replace a pool that is already in use.
Serialize initialization, create the pool only for the first caller, and
add a separately allocated region for every caller. Destroy the pool after
an allocation failure only when it has no existing regions.
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/message/20260518123939.A9E15C2BCB7%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index b38806d205ab..b48b1f56a429 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -172,6 +172,7 @@ struct ghes_vendor_record_entry {
};
static struct gen_pool *ghes_estatus_pool;
+static DEFINE_MUTEX(ghes_estatus_pool_lock);
static struct ghes_estatus_cache __rcu *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE];
static atomic_t ghes_estatus_cache_alloced;
@@ -201,30 +202,44 @@ int ghes_estatus_pool_init(unsigned int num_ghes)
unsigned long addr, len;
int rc;
- ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1);
- if (!ghes_estatus_pool)
- return -ENOMEM;
-
len = GHES_ESTATUS_CACHE_AVG_SIZE * GHES_ESTATUS_CACHE_ALLOCED_MAX;
len += (num_ghes * GHES_ESOURCE_PREALLOC_MAX_SIZE);
+ mutex_lock(&ghes_estatus_pool_lock);
+
+ if (!ghes_estatus_pool) {
+ ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1);
+ if (!ghes_estatus_pool) {
+ rc = -ENOMEM;
+ goto out_unlock;
+ }
+ }
+
addr = (unsigned long)vmalloc(PAGE_ALIGN(len));
- if (!addr)
+ if (!addr) {
+ rc = -ENOMEM;
goto err_pool_alloc;
+ }
rc = gen_pool_add(ghes_estatus_pool, addr, PAGE_ALIGN(len), -1);
if (rc)
goto err_pool_add;
+ mutex_unlock(&ghes_estatus_pool_lock);
return 0;
err_pool_add:
vfree((void *)addr);
err_pool_alloc:
- gen_pool_destroy(ghes_estatus_pool);
-
- return -ENOMEM;
+ if (!gen_pool_avail(ghes_estatus_pool) &&
+ !gen_pool_size(ghes_estatus_pool)) {
+ gen_pool_destroy(ghes_estatus_pool);
+ ghes_estatus_pool = NULL;
+ }
+out_unlock:
+ mutex_unlock(&ghes_estatus_pool_lock);
+ return rc;
}
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 10/22] ACPI: APEI: GHES: keep task work valid through error reporting
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (8 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 09/22] ACPI: APEI: GHES: allow the error status pool to be extended Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 11/22] ACPI: APEI: GHES: reset FRU metadata for each CPER section Ahmed Tiba
` (11 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
memory_failure_cb() returns its task-work allocation to
ghes_estatus_pool before handling the result from memory_failure(). When
memory_failure() returns an unhandled error, the diagnostic path reads
twcb->pfn after the allocation has been returned to the pool and may have
been reused.
Keep the task-work allocation valid until result handling and diagnostic
reporting have completed. Return it to the pool through a common cleanup
path after its final use.
Fixes: c1f1fda14137 ("ACPI: APEI: handle synchronous exceptions in task work")
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/message/20260708144441.6E1181F000E9%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index b48b1f56a429..94f539f5d676 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -521,14 +521,15 @@ static void memory_failure_cb(struct callback_head *twork)
int ret;
ret = memory_failure(twcb->pfn, twcb->flags);
- gen_pool_free(ghes_estatus_pool, (unsigned long)twcb, sizeof(*twcb));
-
if (!ret || ret == -EHWPOISON || ret == -EOPNOTSUPP)
- return;
+ goto out;
pr_err("%#llx: Sending SIGBUS to %s:%d due to hardware memory corruption\n",
twcb->pfn, current->comm, task_pid_nr(current));
force_sig(SIGBUS);
+
+out:
+ gen_pool_free(ghes_estatus_pool, (unsigned long)twcb, sizeof(*twcb));
}
static bool ghes_do_memory_failure(u64 physical_addr, int flags)
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 11/22] ACPI: APEI: GHES: reset FRU metadata for each CPER section
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (9 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 10/22] ACPI: APEI: GHES: keep task work valid through error reporting Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:54 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 12/22] efi/cper: validate the remaining length before reading a section Ahmed Tiba
` (10 subsequent siblings)
21 siblings, 1 reply; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
ghes_do_proc() initializes the FRU ID and text only once before walking
all sections in an error status block. A section without FRU validation
bits therefore inherits metadata from an earlier section and reports the
wrong FRU through the non-standard event tracepoint.
Reset both values at the start of every section before applying the
validation bits from the current section.
Fixes: 297b64c74385 ("ras: acpi / apei: generate trace event for unrecognized CPER section")
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/message/20260708144441.6E1181F000E9%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 94f539f5d676..84a8b7ee911f 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -998,6 +998,9 @@ static void ghes_do_proc(struct ghes *ghes,
apei_estatus_for_each_section(estatus, gdata) {
sec_type = (guid_t *)gdata->section_type;
sec_sev = ghes_severity(gdata->error_severity);
+ fru_id = &guid_null;
+ fru_text = "";
+
if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
fru_id = (guid_t *)gdata->fru_id;
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 12/22] efi/cper: validate the remaining length before reading a section
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (10 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 11/22] ACPI: APEI: GHES: reset FRU metadata for each CPER section Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:52 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 13/22] ACPI: APEI: GHES: share macros via a private header Ahmed Tiba
` (9 subsequent siblings)
21 siblings, 1 reply; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain, sashiko-bot
cper_estatus_check() enters the section loop whenever any data remains.
When a malformed status block leaves fewer than sizeof(*gdata) trailing
bytes, acpi_hest_get_size() reads gdata->revision beyond the valid buffer
before the existing record-size check can reject it.
Require a complete generic data header before dereferencing the section.
Fixes: c4335fdd3822 ("ACPI: APEI: fix the wrong iteration of generic error status block")
Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/message/20260708143557.91D601F000E9%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/firmware/efi/cper.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index 13b3e72c3b62..118953d41cc2 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -793,6 +793,9 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
apei_estatus_for_each_section(estatus, gdata) {
int record_size;
+ if (data_len < sizeof(*gdata))
+ return -EINVAL;
+
/*
* The <acpi/ghes.h> helpers sum these as a signed int, so a
* huge error_data_length wraps small rather than large and the
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 13/22] ACPI: APEI: GHES: share macros via a private header
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (11 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 12/22] efi/cper: validate the remaining length before reading a section Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 14:00 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 14/22] ACPI: APEI: GHES: move CPER read helpers Ahmed Tiba
` (8 subsequent siblings)
21 siblings, 1 reply; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain
Carve the CPER helper macros out of ghes.c and place them in a private
header so they can be shared with upcoming helper files.
Move the vendor record entry declaration and the prototypes for the CPER
read and clear helpers along with ghes_new() and ghes_fini() into the same
header. This requires dropping their local static visibility in ghes.c.
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 94 +++++++++---------------------------------
include/acpi/ghes_cper.h | 103 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 121 insertions(+), 76 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 84a8b7ee911f..6726a60f295a 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -49,6 +49,7 @@
#include <acpi/actbl1.h>
#include <acpi/ghes.h>
+#include <acpi/ghes_cper.h>
#include <acpi/apei.h>
#include <asm/fixmap.h>
#include <asm/tlbflush.h>
@@ -57,40 +58,6 @@
#include "apei-internal.h"
-#define GHES_PFX "GHES: "
-
-#define GHES_ESTATUS_MAX_SIZE 65536
-#define GHES_ESOURCE_PREALLOC_MAX_SIZE 65536
-
-#define GHES_ESTATUS_POOL_MIN_ALLOC_ORDER 3
-
-/* This is just an estimation for memory pool allocation */
-#define GHES_ESTATUS_CACHE_AVG_SIZE 512
-
-#define GHES_ESTATUS_CACHES_SIZE 4
-
-#define GHES_ESTATUS_IN_CACHE_MAX_NSEC 10000000000ULL
-/* Prevent too many caches are allocated because of RCU */
-#define GHES_ESTATUS_CACHE_ALLOCED_MAX (GHES_ESTATUS_CACHES_SIZE * 3 / 2)
-
-#define GHES_ESTATUS_CACHE_LEN(estatus_len) \
- (sizeof(struct ghes_estatus_cache) + (estatus_len))
-#define GHES_ESTATUS_FROM_CACHE(estatus_cache) \
- ((struct acpi_hest_generic_status *) \
- ((struct ghes_estatus_cache *)(estatus_cache) + 1))
-
-#define GHES_ESTATUS_NODE_LEN(estatus_len) \
- (sizeof(struct ghes_estatus_node) + (estatus_len))
-#define GHES_ESTATUS_FROM_NODE(estatus_node) \
- ((struct acpi_hest_generic_status *) \
- ((struct ghes_estatus_node *)(estatus_node) + 1))
-
-#define GHES_VENDOR_ENTRY_LEN(gdata_len) \
- (sizeof(struct ghes_vendor_record_entry) + (gdata_len))
-#define GHES_GDATA_FROM_VENDOR_ENTRY(vendor_entry) \
- ((struct acpi_hest_generic_data *) \
- ((struct ghes_vendor_record_entry *)(vendor_entry) + 1))
-
/*
* NMI-like notifications vary by architecture, before the compiler can prune
* unused static functions it needs a value for these enums.
@@ -102,25 +69,6 @@
static ATOMIC_NOTIFIER_HEAD(ghes_report_chain);
-static inline bool is_hest_type_generic_v2(struct ghes *ghes)
-{
- return ghes->generic->header.type == ACPI_HEST_TYPE_GENERIC_ERROR_V2;
-}
-
-/*
- * A platform may describe one error source for the handling of synchronous
- * errors (e.g. MCE or SEA), or for handling asynchronous errors (e.g. SCI
- * or External Interrupt). On x86, the HEST notifications are always
- * asynchronous, so only SEA on ARM is delivered as a synchronous
- * notification.
- */
-static inline bool is_hest_sync_notify(struct ghes *ghes)
-{
- u8 notify_type = ghes->generic->notify.type;
-
- return notify_type == ACPI_HEST_NOTIFY_SEA;
-}
-
/*
* This driver isn't really modular, however for the time being,
* continuing to use module_param is the easiest way to remain
@@ -165,12 +113,6 @@ static DEFINE_MUTEX(ghes_devs_mutex);
*/
static DEFINE_SPINLOCK(ghes_notify_lock_irq);
-struct ghes_vendor_record_entry {
- struct work_struct work;
- int error_severity;
- char vendor_record[];
-};
-
static struct gen_pool *ghes_estatus_pool;
static DEFINE_MUTEX(ghes_estatus_pool_lock);
@@ -281,7 +223,7 @@ static void ghes_ack_error(struct acpi_hest_generic_v2 *gv2)
apei_write(val, &gv2->read_ack_register);
}
-static struct ghes *ghes_new(struct acpi_hest_generic *generic)
+struct ghes *ghes_new(struct acpi_hest_generic *generic)
{
struct ghes *ghes;
unsigned int error_block_length;
@@ -328,7 +270,7 @@ static struct ghes *ghes_new(struct acpi_hest_generic *generic)
return ERR_PTR(rc);
}
-static void ghes_fini(struct ghes *ghes)
+void ghes_fini(struct ghes *ghes)
{
kfree(ghes->estatus);
apei_unmap_generic_address(&ghes->generic->error_status_address);
@@ -378,8 +320,8 @@ static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len,
}
/* Check the top-level record header has an appropriate size. */
-static int __ghes_check_estatus(struct ghes *ghes,
- struct acpi_hest_generic_status *estatus)
+int __ghes_check_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus)
{
u32 len = cper_estatus_len(estatus);
u32 max_len = min(ghes->generic->error_block_length,
@@ -404,9 +346,9 @@ static int __ghes_check_estatus(struct ghes *ghes,
}
/* Read the CPER block, returning its address, and header in estatus. */
-static int __ghes_peek_estatus(struct ghes *ghes,
- struct acpi_hest_generic_status *estatus,
- u64 *buf_paddr, enum fixed_addresses fixmap_idx)
+int __ghes_peek_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus,
+ u64 *buf_paddr, enum fixed_addresses fixmap_idx)
{
struct acpi_hest_generic *g = ghes->generic;
int rc;
@@ -415,7 +357,7 @@ static int __ghes_peek_estatus(struct ghes *ghes,
if (rc) {
*buf_paddr = 0;
pr_warn_ratelimited(FW_WARN GHES_PFX
-"Failed to read error status block address for hardware error source: %d.\n",
+ "Failed to read error status block address for hardware error source: %d.\n",
g->header.source_id);
return -EIO;
}
@@ -432,9 +374,9 @@ static int __ghes_peek_estatus(struct ghes *ghes,
return 0;
}
-static int __ghes_read_estatus(struct acpi_hest_generic_status *estatus,
- u64 buf_paddr, enum fixed_addresses fixmap_idx,
- size_t buf_len)
+int __ghes_read_estatus(struct acpi_hest_generic_status *estatus,
+ u64 buf_paddr, enum fixed_addresses fixmap_idx,
+ size_t buf_len)
{
u32 len;
@@ -460,9 +402,9 @@ static int __ghes_read_estatus(struct acpi_hest_generic_status *estatus,
return 0;
}
-static int ghes_read_estatus(struct ghes *ghes,
- struct acpi_hest_generic_status *estatus,
- u64 *buf_paddr, enum fixed_addresses fixmap_idx)
+int ghes_read_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus,
+ u64 *buf_paddr, enum fixed_addresses fixmap_idx)
{
int rc;
@@ -478,9 +420,9 @@ static int ghes_read_estatus(struct ghes *ghes,
cper_estatus_len(estatus));
}
-static void ghes_clear_estatus(struct ghes *ghes,
- struct acpi_hest_generic_status *estatus,
- u64 buf_paddr, enum fixed_addresses fixmap_idx)
+void ghes_clear_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus,
+ u64 buf_paddr, enum fixed_addresses fixmap_idx)
{
estatus->block_status = 0;
diff --git a/include/acpi/ghes_cper.h b/include/acpi/ghes_cper.h
new file mode 100644
index 000000000000..fca7b55ab014
--- /dev/null
+++ b/include/acpi/ghes_cper.h
@@ -0,0 +1,103 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * GHES declarations used by both the ACPI APEI GHES driver
+ * and the firmware-first CPER provider.
+ *
+ * These declarations lets GHES and other firmware-first error sources use
+ * the same helper so the non-ACPI path follows the same
+ * behavior as GHES instead of carrying a separate copy.
+ *
+ * Derived from the ACPI APEI GHES driver.
+ *
+ * Copyright 2010,2011 Intel Corp.
+ * Author: Huang Ying <ying.huang@intel.com>
+ */
+
+#ifndef ACPI_APEI_GHES_CPER_H
+#define ACPI_APEI_GHES_CPER_H
+
+#include <linux/workqueue.h>
+
+#include <acpi/ghes.h>
+#include <asm/fixmap.h>
+
+#define GHES_PFX "GHES: "
+
+#define GHES_ESTATUS_MAX_SIZE 65536
+#define GHES_ESOURCE_PREALLOC_MAX_SIZE 65536
+
+#define GHES_ESTATUS_POOL_MIN_ALLOC_ORDER 3
+
+/* This is just an estimation for memory pool allocation */
+#define GHES_ESTATUS_CACHE_AVG_SIZE 512
+
+#define GHES_ESTATUS_CACHES_SIZE 4
+
+#define GHES_ESTATUS_IN_CACHE_MAX_NSEC 10000000000ULL
+/* Prevent too many caches are allocated because of RCU */
+#define GHES_ESTATUS_CACHE_ALLOCED_MAX (GHES_ESTATUS_CACHES_SIZE * 3 / 2)
+
+#define GHES_ESTATUS_CACHE_LEN(estatus_len) \
+ (sizeof(struct ghes_estatus_cache) + (estatus_len))
+#define GHES_ESTATUS_FROM_CACHE(estatus_cache) \
+ ((struct acpi_hest_generic_status *) \
+ ((struct ghes_estatus_cache *)(estatus_cache) + 1))
+
+#define GHES_ESTATUS_NODE_LEN(estatus_len) \
+ (sizeof(struct ghes_estatus_node) + (estatus_len))
+#define GHES_ESTATUS_FROM_NODE(estatus_node) \
+ ((struct acpi_hest_generic_status *) \
+ ((struct ghes_estatus_node *)(estatus_node) + 1))
+
+#define GHES_VENDOR_ENTRY_LEN(gdata_len) \
+ (sizeof(struct ghes_vendor_record_entry) + (gdata_len))
+#define GHES_GDATA_FROM_VENDOR_ENTRY(vendor_entry) \
+ ((struct acpi_hest_generic_data *) \
+ ((struct ghes_vendor_record_entry *)(vendor_entry) + 1))
+
+static inline bool is_hest_type_generic_v2(struct ghes *ghes)
+{
+ return ghes->generic->header.type == ACPI_HEST_TYPE_GENERIC_ERROR_V2;
+}
+
+/*
+ * A platform may describe one error source for the handling of synchronous
+ * errors (e.g. MCE or SEA), or for handling asynchronous errors (e.g. SCI
+ * or External Interrupt). On x86, the HEST notifications are always
+ * asynchronous, so only SEA on ARM is delivered as a synchronous
+ * notification.
+ */
+static inline bool is_hest_sync_notify(struct ghes *ghes)
+{
+ u8 notify_type = ghes->generic->notify.type;
+
+ return notify_type == ACPI_HEST_NOTIFY_SEA;
+}
+
+struct ghes_vendor_record_entry {
+ struct work_struct work;
+ int error_severity;
+ char vendor_record[];
+};
+
+#ifdef CONFIG_ACPI_APEI
+struct ghes *ghes_new(struct acpi_hest_generic *generic);
+void ghes_fini(struct ghes *ghes);
+
+int __ghes_peek_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus,
+ u64 *buf_paddr, enum fixed_addresses fixmap_idx);
+int __ghes_check_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus);
+int __ghes_read_estatus(struct acpi_hest_generic_status *estatus,
+ u64 buf_paddr, enum fixed_addresses fixmap_idx,
+ size_t buf_len);
+int ghes_read_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus,
+ u64 *buf_paddr, enum fixed_addresses fixmap_idx);
+void ghes_clear_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus,
+ u64 buf_paddr, enum fixed_addresses fixmap_idx);
+#endif
+
+#endif /* ACPI_APEI_GHES_CPER_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 14/22] ACPI: APEI: GHES: move CPER read helpers
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (12 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 13/22] ACPI: APEI: GHES: share macros via a private header Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 15/22] ACPI: APEI: GHES: move GHESv2 ack and alloc helpers Ahmed Tiba
` (7 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain
Relocate the CPER buffer mapping, peek, validation, read, clear, and
acknowledgment helpers from ghes.c into ghes_cper.c so they can be shared
with other firmware-first providers. This commit only moves code; behavior
stays the same.
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/Makefile | 2 +-
drivers/acpi/apei/ghes.c | 180 ------------------------------------
drivers/acpi/apei/ghes_cper.c | 210 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 211 insertions(+), 181 deletions(-)
diff --git a/drivers/acpi/apei/Makefile b/drivers/acpi/apei/Makefile
index 66588d6be56f..f57f3b009d8e 100644
--- a/drivers/acpi/apei/Makefile
+++ b/drivers/acpi/apei/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_ACPI_APEI) += apei.o
-obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o
+obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o ghes_cper.o
# clang versions prior to 18 may blow out the stack with KASAN
ifeq ($(CONFIG_COMPILE_TEST)_$(CONFIG_CC_IS_CLANG)_$(call clang-min-version, 180000),y_y_)
KASAN_SANITIZE_ghes.o := n
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 6726a60f295a..897fb2a9da7f 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -119,26 +119,6 @@ static DEFINE_MUTEX(ghes_estatus_pool_lock);
static struct ghes_estatus_cache __rcu *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE];
static atomic_t ghes_estatus_cache_alloced;
-static void __iomem *ghes_map(u64 pfn, enum fixed_addresses fixmap_idx)
-{
- phys_addr_t paddr;
- pgprot_t prot;
-
- paddr = PFN_PHYS(pfn);
- prot = arch_apei_get_mem_attribute(paddr);
- __set_fixmap(fixmap_idx, paddr, prot);
-
- return (void __iomem *) __fix_to_virt(fixmap_idx);
-}
-
-static void ghes_unmap(void __iomem *vaddr, enum fixed_addresses fixmap_idx)
-{
- int _idx = virt_to_fix((unsigned long)vaddr);
-
- WARN_ON_ONCE(fixmap_idx != _idx);
- clear_fixmap(fixmap_idx);
-}
-
int ghes_estatus_pool_init(unsigned int num_ghes)
{
unsigned long addr, len;
@@ -208,21 +188,6 @@ static void unmap_gen_v2(struct ghes *ghes)
apei_unmap_generic_address(&ghes->generic_v2->read_ack_register);
}
-static void ghes_ack_error(struct acpi_hest_generic_v2 *gv2)
-{
- int rc;
- u64 val = 0;
-
- rc = apei_read(&val, &gv2->read_ack_register);
- if (rc)
- return;
-
- val &= gv2->read_ack_preserve;
- val |= gv2->read_ack_write;
-
- apei_write(val, &gv2->read_ack_register);
-}
-
struct ghes *ghes_new(struct acpi_hest_generic *generic)
{
struct ghes *ghes;
@@ -295,151 +260,6 @@ static inline int ghes_severity(int severity)
}
}
-static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len,
- int from_phys,
- enum fixed_addresses fixmap_idx)
-{
- void __iomem *vaddr;
- u64 offset;
- u32 trunk;
-
- while (len > 0) {
- offset = paddr - (paddr & PAGE_MASK);
- vaddr = ghes_map(PHYS_PFN(paddr), fixmap_idx);
- trunk = PAGE_SIZE - offset;
- trunk = min(trunk, len);
- if (from_phys)
- memcpy_fromio(buffer, vaddr + offset, trunk);
- else
- memcpy_toio(vaddr + offset, buffer, trunk);
- len -= trunk;
- paddr += trunk;
- buffer += trunk;
- ghes_unmap(vaddr, fixmap_idx);
- }
-}
-
-/* Check the top-level record header has an appropriate size. */
-int __ghes_check_estatus(struct ghes *ghes,
- struct acpi_hest_generic_status *estatus)
-{
- u32 len = cper_estatus_len(estatus);
- u32 max_len = min(ghes->generic->error_block_length,
- ghes->estatus_length);
-
- if (len < sizeof(*estatus)) {
- pr_warn_ratelimited(FW_WARN GHES_PFX "Truncated error status block!\n");
- return -EIO;
- }
-
- if (!len || len > max_len) {
- pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid error status block length!\n");
- return -EIO;
- }
-
- if (cper_estatus_check_header(estatus)) {
- pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid CPER header!\n");
- return -EIO;
- }
-
- return 0;
-}
-
-/* Read the CPER block, returning its address, and header in estatus. */
-int __ghes_peek_estatus(struct ghes *ghes,
- struct acpi_hest_generic_status *estatus,
- u64 *buf_paddr, enum fixed_addresses fixmap_idx)
-{
- struct acpi_hest_generic *g = ghes->generic;
- int rc;
-
- rc = apei_read(buf_paddr, &g->error_status_address);
- if (rc) {
- *buf_paddr = 0;
- pr_warn_ratelimited(FW_WARN GHES_PFX
- "Failed to read error status block address for hardware error source: %d.\n",
- g->header.source_id);
- return -EIO;
- }
- if (!*buf_paddr)
- return -ENOENT;
-
- ghes_copy_tofrom_phys(estatus, *buf_paddr, sizeof(*estatus), 1,
- fixmap_idx);
- if (!estatus->block_status) {
- *buf_paddr = 0;
- return -ENOENT;
- }
-
- return 0;
-}
-
-int __ghes_read_estatus(struct acpi_hest_generic_status *estatus,
- u64 buf_paddr, enum fixed_addresses fixmap_idx,
- size_t buf_len)
-{
- u32 len;
-
- ghes_copy_tofrom_phys(estatus, buf_paddr, buf_len, 1, fixmap_idx);
-
- len = cper_estatus_len(estatus);
- if (len < sizeof(*estatus)) {
- pr_warn_ratelimited(FW_WARN GHES_PFX "Truncated error status block!\n");
- return -EIO;
- }
-
- if (len > buf_len) {
- pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid error status block length!\n");
- return -EIO;
- }
-
- if (cper_estatus_check(estatus)) {
- pr_warn_ratelimited(FW_WARN GHES_PFX
- "Failed to read error status block!\n");
- return -EIO;
- }
-
- return 0;
-}
-
-int ghes_read_estatus(struct ghes *ghes,
- struct acpi_hest_generic_status *estatus,
- u64 *buf_paddr, enum fixed_addresses fixmap_idx)
-{
- int rc;
-
- rc = __ghes_peek_estatus(ghes, estatus, buf_paddr, fixmap_idx);
- if (rc)
- return rc;
-
- rc = __ghes_check_estatus(ghes, estatus);
- if (rc)
- return rc;
-
- return __ghes_read_estatus(estatus, *buf_paddr, fixmap_idx,
- cper_estatus_len(estatus));
-}
-
-void ghes_clear_estatus(struct ghes *ghes,
- struct acpi_hest_generic_status *estatus,
- u64 buf_paddr, enum fixed_addresses fixmap_idx)
-{
- estatus->block_status = 0;
-
- if (!buf_paddr)
- return;
-
- ghes_copy_tofrom_phys(estatus, buf_paddr,
- sizeof(estatus->block_status), 0,
- fixmap_idx);
-
- /*
- * GHESv2 type HEST entries introduce support for error acknowledgment,
- * so only acknowledge the error if this support is present.
- */
- if (is_hest_type_generic_v2(ghes))
- ghes_ack_error(ghes->generic_v2);
-}
/**
* struct ghes_task_work - for synchronous RAS event
diff --git a/drivers/acpi/apei/ghes_cper.c b/drivers/acpi/apei/ghes_cper.c
new file mode 100644
index 000000000000..0c3f52b2d7f1
--- /dev/null
+++ b/drivers/acpi/apei/ghes_cper.c
@@ -0,0 +1,210 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Shared GHES helpers for firmware-first CPER error handling.
+ *
+ * This file holds the GHES helper code that is shared by the in-tree GHES
+ * driver and by other firmware-first error sources that reuse the same CPER
+ * handling flow.
+ *
+ * Derived from the ACPI APEI GHES driver.
+ *
+ * Copyright 2010,2011 Intel Corp.
+ * Author: Huang Ying <ying.huang@intel.com>
+ */
+
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/ratelimit.h>
+#include <linux/slab.h>
+
+#include <acpi/apei.h>
+#include <acpi/acpi_io.h>
+#include <acpi/ghes_cper.h>
+
+#include <asm/fixmap.h>
+#include <asm/tlbflush.h>
+
+#include "apei-internal.h"
+
+static void __iomem *ghes_map(u64 pfn, enum fixed_addresses fixmap_idx)
+{
+ phys_addr_t paddr;
+ pgprot_t prot;
+
+ paddr = PFN_PHYS(pfn);
+ prot = arch_apei_get_mem_attribute(paddr);
+ __set_fixmap(fixmap_idx, paddr, prot);
+
+ return (void __iomem *) __fix_to_virt(fixmap_idx);
+}
+
+static void ghes_unmap(void __iomem *vaddr, enum fixed_addresses fixmap_idx)
+{
+ int _idx = virt_to_fix((unsigned long)vaddr);
+
+ WARN_ON_ONCE(fixmap_idx != _idx);
+ clear_fixmap(fixmap_idx);
+}
+
+static void ghes_ack_error(struct acpi_hest_generic_v2 *gv2)
+{
+ int rc;
+ u64 val = 0;
+
+ rc = apei_read(&val, &gv2->read_ack_register);
+ if (rc)
+ return;
+
+ val &= gv2->read_ack_preserve;
+ val |= gv2->read_ack_write;
+
+ apei_write(val, &gv2->read_ack_register);
+}
+
+static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len,
+ int from_phys,
+ enum fixed_addresses fixmap_idx)
+{
+ void __iomem *vaddr;
+ u64 offset;
+ u32 trunk;
+
+ while (len > 0) {
+ offset = paddr - (paddr & PAGE_MASK);
+ vaddr = ghes_map(PHYS_PFN(paddr), fixmap_idx);
+ trunk = PAGE_SIZE - offset;
+ trunk = min(trunk, len);
+ if (from_phys)
+ memcpy_fromio(buffer, vaddr + offset, trunk);
+ else
+ memcpy_toio(vaddr + offset, buffer, trunk);
+ len -= trunk;
+ paddr += trunk;
+ buffer += trunk;
+ ghes_unmap(vaddr, fixmap_idx);
+ }
+}
+
+/* Check the top-level record header has an appropriate size. */
+int __ghes_check_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus)
+{
+ u32 len = cper_estatus_len(estatus);
+ u32 max_len = min(ghes->generic->error_block_length,
+ ghes->estatus_length);
+
+ if (len < sizeof(*estatus)) {
+ pr_warn_ratelimited(FW_WARN GHES_PFX "Truncated error status block!\n");
+ return -EIO;
+ }
+
+ if (len > max_len) {
+ pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid error status block length!\n");
+ return -EIO;
+ }
+
+ if (cper_estatus_check_header(estatus)) {
+ pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid CPER header!\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+/* Read the CPER block, returning its address, and header in estatus. */
+int __ghes_peek_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus,
+ u64 *buf_paddr, enum fixed_addresses fixmap_idx)
+{
+ struct acpi_hest_generic *g = ghes->generic;
+ int rc;
+
+ rc = apei_read(buf_paddr, &g->error_status_address);
+ if (rc) {
+ *buf_paddr = 0;
+ pr_warn_ratelimited(FW_WARN GHES_PFX
+ "Failed to read error status block address for hardware error source: %d.\n",
+ g->header.source_id);
+ return -EIO;
+ }
+ if (!*buf_paddr)
+ return -ENOENT;
+
+ ghes_copy_tofrom_phys(estatus, *buf_paddr, sizeof(*estatus), 1,
+ fixmap_idx);
+ if (!estatus->block_status) {
+ *buf_paddr = 0;
+ return -ENOENT;
+ }
+
+ return 0;
+}
+
+int __ghes_read_estatus(struct acpi_hest_generic_status *estatus,
+ u64 buf_paddr, enum fixed_addresses fixmap_idx,
+ size_t buf_len)
+{
+ u32 len;
+
+ ghes_copy_tofrom_phys(estatus, buf_paddr, buf_len, 1, fixmap_idx);
+
+ len = cper_estatus_len(estatus);
+ if (len < sizeof(*estatus)) {
+ pr_warn_ratelimited(FW_WARN GHES_PFX "Truncated error status block!\n");
+ return -EIO;
+ }
+
+ if (len > buf_len) {
+ pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid error status block length!\n");
+ return -EIO;
+ }
+
+ if (cper_estatus_check(estatus)) {
+ pr_warn_ratelimited(FW_WARN GHES_PFX
+ "Failed to read error status block!\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+int ghes_read_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus,
+ u64 *buf_paddr, enum fixed_addresses fixmap_idx)
+{
+ int rc;
+
+ rc = __ghes_peek_estatus(ghes, estatus, buf_paddr, fixmap_idx);
+ if (rc)
+ return rc;
+
+ rc = __ghes_check_estatus(ghes, estatus);
+ if (rc)
+ return rc;
+
+ return __ghes_read_estatus(estatus, *buf_paddr, fixmap_idx,
+ cper_estatus_len(estatus));
+}
+
+void ghes_clear_estatus(struct ghes *ghes,
+ struct acpi_hest_generic_status *estatus,
+ u64 buf_paddr, enum fixed_addresses fixmap_idx)
+{
+ estatus->block_status = 0;
+
+ if (!buf_paddr)
+ return;
+
+ ghes_copy_tofrom_phys(estatus, buf_paddr,
+ sizeof(estatus->block_status), 0,
+ fixmap_idx);
+
+ /*
+ * GHESv2 type HEST entries introduce support for error acknowledgment,
+ * so only acknowledge the error if this support is present.
+ */
+ if (is_hest_type_generic_v2(ghes))
+ ghes_ack_error(ghes->generic_v2);
+}
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 15/22] ACPI: APEI: GHES: move GHESv2 ack and alloc helpers
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (13 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 14/22] ACPI: APEI: GHES: move CPER read helpers Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 16/22] ACPI: APEI: GHES: move estatus cache helpers Ahmed Tiba
` (6 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain
Move the GHESv2 acknowledgment and error-source allocation helpers from
ghes.c into ghes_cper.c. This is a mechanical refactor that keeps the
logic unchanged while making the helpers reusable.
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 65 -------------------------------------------
drivers/acpi/apei/ghes_cper.c | 65 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+), 65 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 897fb2a9da7f..ee2436ecdcf9 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -178,71 +178,6 @@ void ghes_estatus_pool_region_free(unsigned long addr, u32 size)
}
EXPORT_SYMBOL_GPL(ghes_estatus_pool_region_free);
-static int map_gen_v2(struct ghes *ghes)
-{
- return apei_map_generic_address(&ghes->generic_v2->read_ack_register);
-}
-
-static void unmap_gen_v2(struct ghes *ghes)
-{
- apei_unmap_generic_address(&ghes->generic_v2->read_ack_register);
-}
-
-struct ghes *ghes_new(struct acpi_hest_generic *generic)
-{
- struct ghes *ghes;
- unsigned int error_block_length;
- int rc;
-
- ghes = kzalloc_obj(*ghes);
- if (!ghes)
- return ERR_PTR(-ENOMEM);
-
- ghes->generic = generic;
- if (is_hest_type_generic_v2(ghes)) {
- rc = map_gen_v2(ghes);
- if (rc)
- goto err_free;
- }
-
- rc = apei_map_generic_address(&generic->error_status_address);
- if (rc)
- goto err_unmap_read_ack_addr;
- error_block_length = generic->error_block_length;
- if (error_block_length > GHES_ESTATUS_MAX_SIZE) {
- pr_warn(FW_WARN GHES_PFX
- "Error status block length is too long: %u for "
- "generic hardware error source: %d.\n",
- error_block_length, generic->header.source_id);
- error_block_length = GHES_ESTATUS_MAX_SIZE;
- }
- ghes->estatus = kmalloc(error_block_length, GFP_KERNEL);
- ghes->estatus_length = error_block_length;
- if (!ghes->estatus) {
- rc = -ENOMEM;
- goto err_unmap_status_addr;
- }
-
- return ghes;
-
-err_unmap_status_addr:
- apei_unmap_generic_address(&generic->error_status_address);
-err_unmap_read_ack_addr:
- if (is_hest_type_generic_v2(ghes))
- unmap_gen_v2(ghes);
-err_free:
- kfree(ghes);
- return ERR_PTR(rc);
-}
-
-void ghes_fini(struct ghes *ghes)
-{
- kfree(ghes->estatus);
- apei_unmap_generic_address(&ghes->generic->error_status_address);
- if (is_hest_type_generic_v2(ghes))
- unmap_gen_v2(ghes);
-}
-
static inline int ghes_severity(int severity)
{
switch (severity) {
diff --git a/drivers/acpi/apei/ghes_cper.c b/drivers/acpi/apei/ghes_cper.c
index 0c3f52b2d7f1..9c668725e08a 100644
--- a/drivers/acpi/apei/ghes_cper.c
+++ b/drivers/acpi/apei/ghes_cper.c
@@ -63,6 +63,71 @@ static void ghes_ack_error(struct acpi_hest_generic_v2 *gv2)
apei_write(val, &gv2->read_ack_register);
}
+static int map_gen_v2(struct ghes *ghes)
+{
+ return apei_map_generic_address(&ghes->generic_v2->read_ack_register);
+}
+
+static void unmap_gen_v2(struct ghes *ghes)
+{
+ apei_unmap_generic_address(&ghes->generic_v2->read_ack_register);
+}
+
+struct ghes *ghes_new(struct acpi_hest_generic *generic)
+{
+ struct ghes *ghes;
+ unsigned int error_block_length;
+ int rc;
+
+ ghes = kzalloc_obj(*ghes);
+ if (!ghes)
+ return ERR_PTR(-ENOMEM);
+
+ ghes->generic = generic;
+ if (is_hest_type_generic_v2(ghes)) {
+ rc = map_gen_v2(ghes);
+ if (rc)
+ goto err_free;
+ }
+
+ rc = apei_map_generic_address(&generic->error_status_address);
+ if (rc)
+ goto err_unmap_read_ack_addr;
+ error_block_length = generic->error_block_length;
+ if (error_block_length > GHES_ESTATUS_MAX_SIZE) {
+ pr_warn(FW_WARN GHES_PFX
+ "Error status block length is too long: %u for "
+ "generic hardware error source: %d.\n",
+ error_block_length, generic->header.source_id);
+ error_block_length = GHES_ESTATUS_MAX_SIZE;
+ }
+ ghes->estatus = kmalloc(error_block_length, GFP_KERNEL);
+ ghes->estatus_length = error_block_length;
+ if (!ghes->estatus) {
+ rc = -ENOMEM;
+ goto err_unmap_status_addr;
+ }
+
+ return ghes;
+
+err_unmap_status_addr:
+ apei_unmap_generic_address(&generic->error_status_address);
+err_unmap_read_ack_addr:
+ if (is_hest_type_generic_v2(ghes))
+ unmap_gen_v2(ghes);
+err_free:
+ kfree(ghes);
+ return ERR_PTR(rc);
+}
+
+void ghes_fini(struct ghes *ghes)
+{
+ kfree(ghes->estatus);
+ apei_unmap_generic_address(&ghes->generic->error_status_address);
+ if (is_hest_type_generic_v2(ghes))
+ unmap_gen_v2(ghes);
+}
+
static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len,
int from_phys,
enum fixed_addresses fixmap_idx)
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 16/22] ACPI: APEI: GHES: move estatus cache helpers
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (14 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 15/22] ACPI: APEI: GHES: move GHESv2 ack and alloc helpers Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 17/22] ACPI: APEI: GHES: move vendor record helpers Ahmed Tiba
` (5 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain
Relocate the estatus cache allocation and lookup helpers from ghes.c into
ghes_cper.c. This code move keeps the logic intact while making the cache
implementation available to forthcoming users.
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 142 +----------------------------------------
drivers/acpi/apei/ghes_cper.c | 143 ++++++++++++++++++++++++++++++++++++++++++
include/acpi/ghes_cper.h | 5 ++
3 files changed, 149 insertions(+), 141 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index ee2436ecdcf9..bdd3500e19b2 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -113,12 +113,9 @@ static DEFINE_MUTEX(ghes_devs_mutex);
*/
static DEFINE_SPINLOCK(ghes_notify_lock_irq);
-static struct gen_pool *ghes_estatus_pool;
+struct gen_pool *ghes_estatus_pool;
static DEFINE_MUTEX(ghes_estatus_pool_lock);
-static struct ghes_estatus_cache __rcu *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE];
-static atomic_t ghes_estatus_cache_alloced;
-
int ghes_estatus_pool_init(unsigned int num_ghes)
{
unsigned long addr, len;
@@ -819,143 +816,6 @@ static int ghes_print_estatus(const char *pfx,
return 0;
}
-/*
- * GHES error status reporting throttle, to report more kinds of
- * errors, instead of just most frequently occurred errors.
- */
-static int ghes_estatus_cached(struct acpi_hest_generic_status *estatus)
-{
- u32 len;
- int i, cached = 0;
- unsigned long long now;
- struct ghes_estatus_cache *cache;
- struct acpi_hest_generic_status *cache_estatus;
-
- len = cper_estatus_len(estatus);
- rcu_read_lock();
- for (i = 0; i < GHES_ESTATUS_CACHES_SIZE; i++) {
- cache = rcu_dereference(ghes_estatus_caches[i]);
- if (cache == NULL)
- continue;
- if (len != cache->estatus_len)
- continue;
- cache_estatus = GHES_ESTATUS_FROM_CACHE(cache);
- if (memcmp(estatus, cache_estatus, len))
- continue;
- atomic_inc(&cache->count);
- now = sched_clock();
- if (now - cache->time_in < GHES_ESTATUS_IN_CACHE_MAX_NSEC)
- cached = 1;
- break;
- }
- rcu_read_unlock();
- return cached;
-}
-
-static struct ghes_estatus_cache *ghes_estatus_cache_alloc(
- struct acpi_hest_generic *generic,
- struct acpi_hest_generic_status *estatus)
-{
- int alloced;
- u32 len, cache_len;
- struct ghes_estatus_cache *cache;
- struct acpi_hest_generic_status *cache_estatus;
-
- alloced = atomic_add_return(1, &ghes_estatus_cache_alloced);
- if (alloced > GHES_ESTATUS_CACHE_ALLOCED_MAX) {
- atomic_dec(&ghes_estatus_cache_alloced);
- return NULL;
- }
- len = cper_estatus_len(estatus);
- cache_len = GHES_ESTATUS_CACHE_LEN(len);
- cache = (void *)gen_pool_alloc(ghes_estatus_pool, cache_len);
- if (!cache) {
- atomic_dec(&ghes_estatus_cache_alloced);
- return NULL;
- }
- cache_estatus = GHES_ESTATUS_FROM_CACHE(cache);
- memcpy(cache_estatus, estatus, len);
- cache->estatus_len = len;
- atomic_set(&cache->count, 0);
- cache->generic = generic;
- cache->time_in = sched_clock();
- return cache;
-}
-
-static void ghes_estatus_cache_rcu_free(struct rcu_head *head)
-{
- struct ghes_estatus_cache *cache;
- u32 len;
-
- cache = container_of(head, struct ghes_estatus_cache, rcu);
- len = cper_estatus_len(GHES_ESTATUS_FROM_CACHE(cache));
- len = GHES_ESTATUS_CACHE_LEN(len);
- gen_pool_free(ghes_estatus_pool, (unsigned long)cache, len);
- atomic_dec(&ghes_estatus_cache_alloced);
-}
-
-static void
-ghes_estatus_cache_add(struct acpi_hest_generic *generic,
- struct acpi_hest_generic_status *estatus)
-{
- unsigned long long now, duration, period, max_period = 0;
- struct ghes_estatus_cache *cache, *new_cache;
- struct ghes_estatus_cache __rcu *victim;
- int i, slot = -1, count;
-
- new_cache = ghes_estatus_cache_alloc(generic, estatus);
- if (!new_cache)
- return;
-
- rcu_read_lock();
- now = sched_clock();
- for (i = 0; i < GHES_ESTATUS_CACHES_SIZE; i++) {
- cache = rcu_dereference(ghes_estatus_caches[i]);
- if (cache == NULL) {
- slot = i;
- break;
- }
- duration = now - cache->time_in;
- if (duration >= GHES_ESTATUS_IN_CACHE_MAX_NSEC) {
- slot = i;
- break;
- }
- count = atomic_read(&cache->count);
- period = duration;
- do_div(period, (count + 1));
- if (period > max_period) {
- max_period = period;
- slot = i;
- }
- }
- rcu_read_unlock();
-
- if (slot != -1) {
- /*
- * Use release semantics to ensure that ghes_estatus_cached()
- * running on another CPU will see the updated cache fields if
- * it can see the new value of the pointer.
- */
- victim = xchg_release(&ghes_estatus_caches[slot],
- RCU_INITIALIZER(new_cache));
-
- /*
- * At this point, victim may point to a cached item different
- * from the one based on which we selected the slot. Instead of
- * going to the loop again to pick another slot, let's just
- * drop the other item anyway: this may cause a false cache
- * miss later on, but that won't cause any problems.
- */
- if (victim)
- call_rcu(&unrcu_pointer(victim)->rcu,
- ghes_estatus_cache_rcu_free);
- } else {
- gen_pool_free(ghes_estatus_pool, (unsigned long)new_cache,
- GHES_ESTATUS_CACHE_LEN(new_cache->estatus_len));
- atomic_dec(&ghes_estatus_cache_alloced);
- }
-}
-
static void __ghes_panic(struct ghes *ghes,
struct acpi_hest_generic_status *estatus,
u64 buf_paddr, enum fixed_addresses fixmap_idx)
diff --git a/drivers/acpi/apei/ghes_cper.c b/drivers/acpi/apei/ghes_cper.c
index 9c668725e08a..a3c0cf044818 100644
--- a/drivers/acpi/apei/ghes_cper.c
+++ b/drivers/acpi/apei/ghes_cper.c
@@ -13,10 +13,14 @@
*/
#include <linux/err.h>
+#include <linux/genalloc.h>
#include <linux/io.h>
#include <linux/kernel.h>
+#include <linux/math64.h>
#include <linux/mm.h>
#include <linux/ratelimit.h>
+#include <linux/rcupdate.h>
+#include <linux/sched/clock.h>
#include <linux/slab.h>
#include <acpi/apei.h>
@@ -28,6 +32,9 @@
#include "apei-internal.h"
+static struct ghes_estatus_cache __rcu *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE];
+static atomic_t ghes_estatus_cache_alloced;
+
static void __iomem *ghes_map(u64 pfn, enum fixed_addresses fixmap_idx)
{
phys_addr_t paddr;
@@ -273,3 +280,139 @@ void ghes_clear_estatus(struct ghes *ghes,
if (is_hest_type_generic_v2(ghes))
ghes_ack_error(ghes->generic_v2);
}
+
+/*
+ * GHES error status reporting throttle, to report more kinds of
+ * errors, instead of just most frequently occurred errors.
+ */
+int ghes_estatus_cached(struct acpi_hest_generic_status *estatus)
+{
+ u32 len;
+ int i, cached = 0;
+ unsigned long long now;
+ struct ghes_estatus_cache *cache;
+ struct acpi_hest_generic_status *cache_estatus;
+
+ len = cper_estatus_len(estatus);
+ rcu_read_lock();
+ for (i = 0; i < GHES_ESTATUS_CACHES_SIZE; i++) {
+ cache = rcu_dereference(ghes_estatus_caches[i]);
+ if (cache == NULL)
+ continue;
+ if (len != cache->estatus_len)
+ continue;
+ cache_estatus = GHES_ESTATUS_FROM_CACHE(cache);
+ if (memcmp(estatus, cache_estatus, len))
+ continue;
+ atomic_inc(&cache->count);
+ now = sched_clock();
+ if (now - cache->time_in < GHES_ESTATUS_IN_CACHE_MAX_NSEC)
+ cached = 1;
+ break;
+ }
+ rcu_read_unlock();
+ return cached;
+}
+
+static struct ghes_estatus_cache *ghes_estatus_cache_alloc(
+ struct acpi_hest_generic *generic,
+ struct acpi_hest_generic_status *estatus)
+{
+ int alloced;
+ u32 len, cache_len;
+ struct ghes_estatus_cache *cache;
+ struct acpi_hest_generic_status *cache_estatus;
+
+ alloced = atomic_add_return(1, &ghes_estatus_cache_alloced);
+ if (alloced > GHES_ESTATUS_CACHE_ALLOCED_MAX) {
+ atomic_dec(&ghes_estatus_cache_alloced);
+ return NULL;
+ }
+ len = cper_estatus_len(estatus);
+ cache_len = GHES_ESTATUS_CACHE_LEN(len);
+ cache = (void *)gen_pool_alloc(ghes_estatus_pool, cache_len);
+ if (!cache) {
+ atomic_dec(&ghes_estatus_cache_alloced);
+ return NULL;
+ }
+ cache_estatus = GHES_ESTATUS_FROM_CACHE(cache);
+ memcpy(cache_estatus, estatus, len);
+ cache->estatus_len = len;
+ atomic_set(&cache->count, 0);
+ cache->generic = generic;
+ cache->time_in = sched_clock();
+ return cache;
+}
+
+static void ghes_estatus_cache_rcu_free(struct rcu_head *head)
+{
+ struct ghes_estatus_cache *cache;
+ u32 len;
+
+ cache = container_of(head, struct ghes_estatus_cache, rcu);
+ len = cper_estatus_len(GHES_ESTATUS_FROM_CACHE(cache));
+ len = GHES_ESTATUS_CACHE_LEN(len);
+ gen_pool_free(ghes_estatus_pool, (unsigned long)cache, len);
+ atomic_dec(&ghes_estatus_cache_alloced);
+}
+
+void ghes_estatus_cache_add(struct acpi_hest_generic *generic,
+ struct acpi_hest_generic_status *estatus)
+{
+ unsigned long long now, duration, period, max_period = 0;
+ struct ghes_estatus_cache *cache, *new_cache;
+ struct ghes_estatus_cache __rcu *victim;
+ int i, slot = -1, count;
+
+ new_cache = ghes_estatus_cache_alloc(generic, estatus);
+ if (!new_cache)
+ return;
+
+ rcu_read_lock();
+ now = sched_clock();
+ for (i = 0; i < GHES_ESTATUS_CACHES_SIZE; i++) {
+ cache = rcu_dereference(ghes_estatus_caches[i]);
+ if (cache == NULL) {
+ slot = i;
+ break;
+ }
+ duration = now - cache->time_in;
+ if (duration >= GHES_ESTATUS_IN_CACHE_MAX_NSEC) {
+ slot = i;
+ break;
+ }
+ count = atomic_read(&cache->count);
+ period = duration;
+ do_div(period, (count + 1));
+ if (period > max_period) {
+ max_period = period;
+ slot = i;
+ }
+ }
+ rcu_read_unlock();
+
+ if (slot != -1) {
+ /*
+ * Use release semantics to ensure that ghes_estatus_cached()
+ * running on another CPU will see the updated cache fields if
+ * it can see the new value of the pointer.
+ */
+ victim = xchg_release(&ghes_estatus_caches[slot],
+ RCU_INITIALIZER(new_cache));
+
+ /*
+ * At this point, victim may point to a cached item different
+ * from the one based on which we selected the slot. Instead of
+ * going to the loop again to pick another slot, let's just
+ * drop the other item anyway: this may cause a false cache
+ * miss later on, but that won't cause any problems.
+ */
+ if (victim)
+ call_rcu(&unrcu_pointer(victim)->rcu,
+ ghes_estatus_cache_rcu_free);
+ } else {
+ gen_pool_free(ghes_estatus_pool, (unsigned long)new_cache,
+ GHES_ESTATUS_CACHE_LEN(new_cache->estatus_len));
+ atomic_dec(&ghes_estatus_cache_alloced);
+ }
+}
diff --git a/include/acpi/ghes_cper.h b/include/acpi/ghes_cper.h
index fca7b55ab014..b548fdc52082 100644
--- a/include/acpi/ghes_cper.h
+++ b/include/acpi/ghes_cper.h
@@ -55,6 +55,8 @@
((struct acpi_hest_generic_data *) \
((struct ghes_vendor_record_entry *)(vendor_entry) + 1))
+extern struct gen_pool *ghes_estatus_pool;
+
static inline bool is_hest_type_generic_v2(struct ghes *ghes)
{
return ghes->generic->header.type == ACPI_HEST_TYPE_GENERIC_ERROR_V2;
@@ -99,5 +101,8 @@ void ghes_clear_estatus(struct ghes *ghes,
struct acpi_hest_generic_status *estatus,
u64 buf_paddr, enum fixed_addresses fixmap_idx);
#endif
+int ghes_estatus_cached(struct acpi_hest_generic_status *estatus);
+void ghes_estatus_cache_add(struct acpi_hest_generic *generic,
+ struct acpi_hest_generic_status *estatus);
#endif /* ACPI_APEI_GHES_CPER_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 17/22] ACPI: APEI: GHES: move vendor record helpers
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (15 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 16/22] ACPI: APEI: GHES: move estatus cache helpers Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 14:04 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 18/22] ACPI: APEI: GHES: move CXL CPER helpers Ahmed Tiba
` (4 subsequent siblings)
21 siblings, 1 reply; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain
Shift the vendor record workqueue helpers into ghes_cper.c so both GHES
and future DT-based providers can use the same implementation. The change
is mechanical and keeps the notifier behavior identical.
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 68 ------------------------------------------
drivers/acpi/apei/ghes_cper.c | 69 +++++++++++++++++++++++++++++++++++++++++++
include/acpi/ghes_cper.h | 2 ++
3 files changed, 71 insertions(+), 68 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index bdd3500e19b2..2369bfcbfe88 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -401,74 +401,6 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata)
#endif
}
-static BLOCKING_NOTIFIER_HEAD(vendor_record_notify_list);
-
-int ghes_register_vendor_record_notifier(struct notifier_block *nb)
-{
- return blocking_notifier_chain_register(&vendor_record_notify_list, nb);
-}
-EXPORT_SYMBOL_GPL(ghes_register_vendor_record_notifier);
-
-void ghes_unregister_vendor_record_notifier(struct notifier_block *nb)
-{
- blocking_notifier_chain_unregister(&vendor_record_notify_list, nb);
-}
-EXPORT_SYMBOL_GPL(ghes_unregister_vendor_record_notifier);
-
-static void ghes_vendor_record_notifier_destroy(void *nb)
-{
- ghes_unregister_vendor_record_notifier(nb);
-}
-
-int devm_ghes_register_vendor_record_notifier(struct device *dev,
- struct notifier_block *nb)
-{
- int ret;
-
- ret = ghes_register_vendor_record_notifier(nb);
- if (ret)
- return ret;
-
- return devm_add_action_or_reset(dev, ghes_vendor_record_notifier_destroy, nb);
-}
-EXPORT_SYMBOL_GPL(devm_ghes_register_vendor_record_notifier);
-
-static void ghes_vendor_record_work_func(struct work_struct *work)
-{
- struct ghes_vendor_record_entry *entry;
- struct acpi_hest_generic_data *gdata;
- u32 len;
-
- entry = container_of(work, struct ghes_vendor_record_entry, work);
- gdata = GHES_GDATA_FROM_VENDOR_ENTRY(entry);
-
- blocking_notifier_call_chain(&vendor_record_notify_list,
- entry->error_severity, gdata);
-
- len = GHES_VENDOR_ENTRY_LEN(acpi_hest_get_record_size(gdata));
- gen_pool_free(ghes_estatus_pool, (unsigned long)entry, len);
-}
-
-static void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
- int sev)
-{
- struct acpi_hest_generic_data *copied_gdata;
- struct ghes_vendor_record_entry *entry;
- u32 len;
-
- len = GHES_VENDOR_ENTRY_LEN(acpi_hest_get_record_size(gdata));
- entry = (void *)gen_pool_alloc(ghes_estatus_pool, len);
- if (!entry)
- return;
-
- copied_gdata = GHES_GDATA_FROM_VENDOR_ENTRY(entry);
- memcpy(copied_gdata, gdata, acpi_hest_get_record_size(gdata));
- entry->error_severity = sev;
-
- INIT_WORK(&entry->work, ghes_vendor_record_work_func);
- schedule_work(&entry->work);
-}
-
/* Room for 8 entries */
#define CXL_CPER_PROT_ERR_FIFO_DEPTH 8
static DEFINE_KFIFO(cxl_cper_prot_err_fifo, struct cxl_cper_prot_err_work_data,
diff --git a/drivers/acpi/apei/ghes_cper.c b/drivers/acpi/apei/ghes_cper.c
index a3c0cf044818..20826d9fb13e 100644
--- a/drivers/acpi/apei/ghes_cper.c
+++ b/drivers/acpi/apei/ghes_cper.c
@@ -18,6 +18,7 @@
#include <linux/kernel.h>
#include <linux/math64.h>
#include <linux/mm.h>
+#include <linux/notifier.h>
#include <linux/ratelimit.h>
#include <linux/rcupdate.h>
#include <linux/sched/clock.h>
@@ -281,6 +282,74 @@ void ghes_clear_estatus(struct ghes *ghes,
ghes_ack_error(ghes->generic_v2);
}
+static BLOCKING_NOTIFIER_HEAD(vendor_record_notify_list);
+
+int ghes_register_vendor_record_notifier(struct notifier_block *nb)
+{
+ return blocking_notifier_chain_register(&vendor_record_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(ghes_register_vendor_record_notifier);
+
+void ghes_unregister_vendor_record_notifier(struct notifier_block *nb)
+{
+ blocking_notifier_chain_unregister(&vendor_record_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(ghes_unregister_vendor_record_notifier);
+
+static void ghes_vendor_record_notifier_destroy(void *nb)
+{
+ ghes_unregister_vendor_record_notifier(nb);
+}
+
+int devm_ghes_register_vendor_record_notifier(struct device *dev,
+ struct notifier_block *nb)
+{
+ int ret;
+
+ ret = ghes_register_vendor_record_notifier(nb);
+ if (ret)
+ return ret;
+
+ return devm_add_action_or_reset(dev, ghes_vendor_record_notifier_destroy, nb);
+}
+EXPORT_SYMBOL_GPL(devm_ghes_register_vendor_record_notifier);
+
+static void ghes_vendor_record_work_func(struct work_struct *work)
+{
+ struct ghes_vendor_record_entry *entry;
+ struct acpi_hest_generic_data *gdata;
+ u32 len;
+
+ entry = container_of(work, struct ghes_vendor_record_entry, work);
+ gdata = GHES_GDATA_FROM_VENDOR_ENTRY(entry);
+
+ blocking_notifier_call_chain(&vendor_record_notify_list,
+ entry->error_severity, gdata);
+
+ len = GHES_VENDOR_ENTRY_LEN(acpi_hest_get_record_size(gdata));
+ gen_pool_free(ghes_estatus_pool, (unsigned long)entry, len);
+}
+
+void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
+ int sev)
+{
+ struct acpi_hest_generic_data *copied_gdata;
+ struct ghes_vendor_record_entry *entry;
+ u32 len;
+
+ len = GHES_VENDOR_ENTRY_LEN(acpi_hest_get_record_size(gdata));
+ entry = (void *)gen_pool_alloc(ghes_estatus_pool, len);
+ if (!entry)
+ return;
+
+ copied_gdata = GHES_GDATA_FROM_VENDOR_ENTRY(entry);
+ memcpy(copied_gdata, gdata, acpi_hest_get_record_size(gdata));
+ entry->error_severity = sev;
+
+ INIT_WORK(&entry->work, ghes_vendor_record_work_func);
+ schedule_work(&entry->work);
+}
+
/*
* GHES error status reporting throttle, to report more kinds of
* errors, instead of just most frequently occurred errors.
diff --git a/include/acpi/ghes_cper.h b/include/acpi/ghes_cper.h
index b548fdc52082..38f8e0782b9e 100644
--- a/include/acpi/ghes_cper.h
+++ b/include/acpi/ghes_cper.h
@@ -104,5 +104,7 @@ void ghes_clear_estatus(struct ghes *ghes,
int ghes_estatus_cached(struct acpi_hest_generic_status *estatus);
void ghes_estatus_cache_add(struct acpi_hest_generic *generic,
struct acpi_hest_generic_status *estatus);
+void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
+ int sev);
#endif /* ACPI_APEI_GHES_CPER_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 18/22] ACPI: APEI: GHES: move CXL CPER helpers
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (16 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 17/22] ACPI: APEI: GHES: move vendor record helpers Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 19/22] ACPI: APEI: introduce GHES CPER helper configuration Ahmed Tiba
` (3 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain
Move the CXL CPER handling paths out of ghes.c and into ghes_cper.c so the
helpers can be reused. Update the public prototypes so GHES continues to
call the relocated implementation.
Preserve the existing CXL record validation, FIFO handling, and locking
unchanged.
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 152 -----------------------------------------
drivers/acpi/apei/ghes_cper.c | 155 ++++++++++++++++++++++++++++++++++++++++++
include/acpi/ghes_cper.h | 11 +++
3 files changed, 166 insertions(+), 152 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 2369bfcbfe88..7b460d6fa0d2 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -401,158 +401,6 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata)
#endif
}
-/* Room for 8 entries */
-#define CXL_CPER_PROT_ERR_FIFO_DEPTH 8
-static DEFINE_KFIFO(cxl_cper_prot_err_fifo, struct cxl_cper_prot_err_work_data,
- CXL_CPER_PROT_ERR_FIFO_DEPTH);
-
-/* Synchronize schedule_work() with cxl_cper_prot_err_work changes */
-static DEFINE_RAW_SPINLOCK(cxl_cper_prot_err_work_lock);
-struct work_struct *cxl_cper_prot_err_work;
-
-void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
- int severity, u32 len)
-{
-#ifdef CONFIG_ACPI_APEI_PCIEAER
- struct cxl_cper_prot_err_work_data wd;
-
- if (cxl_cper_sec_prot_err_valid(prot_err, len))
- return;
-
- guard(raw_spinlock_irqsave)(&cxl_cper_prot_err_work_lock);
-
- if (!cxl_cper_prot_err_work)
- return;
-
- if (cxl_cper_setup_prot_err_work_data(&wd, prot_err, severity))
- return;
-
- if (!kfifo_put(&cxl_cper_prot_err_fifo, wd)) {
- pr_err_ratelimited("CXL CPER kfifo overflow\n");
- return;
- }
-
- schedule_work(cxl_cper_prot_err_work);
-#endif
-}
-EXPORT_SYMBOL_FOR_MODULES(cxl_cper_post_prot_err, "acpi_extlog");
-
-void cxl_cper_register_prot_err_work(struct work_struct *work)
-{
- guard(raw_spinlock_irqsave)(&cxl_cper_prot_err_work_lock);
-
- if (WARN_ONCE(cxl_cper_prot_err_work,
- "CPER-CXL kfifo consumer already registered\n"))
- return;
- cxl_cper_prot_err_work = work;
-}
-EXPORT_SYMBOL_FOR_MODULES(cxl_cper_register_prot_err_work, "cxl_core");
-
-void cxl_cper_unregister_prot_err_work(void)
-{
- struct work_struct *old;
-
- scoped_guard(raw_spinlock_irqsave, &cxl_cper_prot_err_work_lock) {
- WARN_ONCE(!cxl_cper_prot_err_work,
- "CPER-CXL kfifo consumer not registered on unregister\n");
- old = cxl_cper_prot_err_work;
- cxl_cper_prot_err_work = NULL;
- }
-
- if (old)
- cancel_work_sync(old);
-
- /* Discard stale entries so they are not replayed on next module load */
- kfifo_reset(&cxl_cper_prot_err_fifo);
-}
-EXPORT_SYMBOL_FOR_MODULES(cxl_cper_unregister_prot_err_work, "cxl_core");
-
-int cxl_cper_prot_err_kfifo_get(struct cxl_cper_prot_err_work_data *wd)
-{
- return kfifo_get(&cxl_cper_prot_err_fifo, wd);
-}
-EXPORT_SYMBOL_FOR_MODULES(cxl_cper_prot_err_kfifo_get, "cxl_core");
-
-/* Room for 8 entries for each of the 4 event log queues */
-#define CXL_CPER_FIFO_DEPTH 32
-DEFINE_KFIFO(cxl_cper_fifo, struct cxl_cper_work_data, CXL_CPER_FIFO_DEPTH);
-
-/* Synchronize schedule_work() with cxl_cper_work changes */
-static DEFINE_RAW_SPINLOCK(cxl_cper_work_lock);
-struct work_struct *cxl_cper_work;
-
-static void cxl_cper_post_event(enum cxl_event_type event_type,
- struct cxl_cper_event_rec *rec, u32 len)
-{
- struct cxl_cper_work_data wd;
-
- if (len < sizeof(*rec)) {
- pr_err(FW_WARN "CXL CPER section too small (%u)\n", len);
- return;
- }
-
- if (rec->hdr.length <= sizeof(rec->hdr) ||
- rec->hdr.length > sizeof(*rec)) {
- pr_err(FW_WARN "CXL CPER Invalid section length (%u)\n",
- rec->hdr.length);
- return;
- }
-
- if (!(rec->hdr.validation_bits & CPER_CXL_COMP_EVENT_LOG_VALID)) {
- pr_err(FW_WARN "CXL CPER invalid event\n");
- return;
- }
-
- guard(raw_spinlock_irqsave)(&cxl_cper_work_lock);
-
- if (!cxl_cper_work)
- return;
-
- wd.event_type = event_type;
- memcpy(&wd.rec, rec, sizeof(wd.rec));
-
- if (!kfifo_put(&cxl_cper_fifo, wd)) {
- pr_err_ratelimited("CXL CPER kfifo overflow\n");
- return;
- }
-
- schedule_work(cxl_cper_work);
-}
-
-int cxl_cper_register_work(struct work_struct *work)
-{
- guard(raw_spinlock_irqsave)(&cxl_cper_work_lock);
- if (WARN_ONCE(cxl_cper_work,
- "CXL CPER kfifo consumer already registered\n"))
- return -EINVAL;
-
- cxl_cper_work = work;
- return 0;
-}
-EXPORT_SYMBOL_NS_GPL(cxl_cper_register_work, "CXL");
-
-void cxl_cper_unregister_work(struct work_struct *work)
-{
- scoped_guard(raw_spinlock_irqsave, &cxl_cper_work_lock) {
- if (WARN_ONCE(cxl_cper_work != work,
- "CXL CPER kfifo consumer mismatch on unregister\n"))
- return;
- cxl_cper_work = NULL;
- }
-
- cancel_work_sync(work);
-
- /* Discard stale entries so they are not replayed on next module load */
- kfifo_reset(&cxl_cper_fifo);
-}
-EXPORT_SYMBOL_NS_GPL(cxl_cper_unregister_work, "CXL");
-
-int cxl_cper_kfifo_get(struct cxl_cper_work_data *wd)
-{
- return kfifo_get(&cxl_cper_fifo, wd);
-}
-EXPORT_SYMBOL_NS_GPL(cxl_cper_kfifo_get, "CXL");
-
static void ghes_log_hwerr(int sev, guid_t *sec_type)
{
if (sev != GHES_SEV_RECOVERABLE)
diff --git a/drivers/acpi/apei/ghes_cper.c b/drivers/acpi/apei/ghes_cper.c
index 20826d9fb13e..2037046d9be8 100644
--- a/drivers/acpi/apei/ghes_cper.c
+++ b/drivers/acpi/apei/ghes_cper.c
@@ -12,9 +12,12 @@
* Author: Huang Ying <ying.huang@intel.com>
*/
+#include <linux/aer.h>
+#include <linux/cleanup.h>
#include <linux/err.h>
#include <linux/genalloc.h>
#include <linux/io.h>
+#include <linux/kfifo.h>
#include <linux/kernel.h>
#include <linux/math64.h>
#include <linux/mm.h>
@@ -350,6 +353,158 @@ void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
schedule_work(&entry->work);
}
+/* Room for 8 entries */
+#define CXL_CPER_PROT_ERR_FIFO_DEPTH 8
+static DEFINE_KFIFO(cxl_cper_prot_err_fifo, struct cxl_cper_prot_err_work_data,
+ CXL_CPER_PROT_ERR_FIFO_DEPTH);
+
+/* Synchronize schedule_work() with cxl_cper_prot_err_work changes */
+static DEFINE_RAW_SPINLOCK(cxl_cper_prot_err_work_lock);
+struct work_struct *cxl_cper_prot_err_work;
+
+void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
+ int severity, u32 len)
+{
+#ifdef CONFIG_ACPI_APEI_PCIEAER
+ struct cxl_cper_prot_err_work_data wd;
+
+ if (cxl_cper_sec_prot_err_valid(prot_err, len))
+ return;
+
+ guard(raw_spinlock_irqsave)(&cxl_cper_prot_err_work_lock);
+
+ if (!cxl_cper_prot_err_work)
+ return;
+
+ if (cxl_cper_setup_prot_err_work_data(&wd, prot_err, severity))
+ return;
+
+ if (!kfifo_put(&cxl_cper_prot_err_fifo, wd)) {
+ pr_err_ratelimited("CXL CPER kfifo overflow\n");
+ return;
+ }
+
+ schedule_work(cxl_cper_prot_err_work);
+#endif
+}
+EXPORT_SYMBOL_FOR_MODULES(cxl_cper_post_prot_err, "acpi_extlog");
+
+void cxl_cper_register_prot_err_work(struct work_struct *work)
+{
+ guard(raw_spinlock_irqsave)(&cxl_cper_prot_err_work_lock);
+
+ if (WARN_ONCE(cxl_cper_prot_err_work,
+ "CPER-CXL kfifo consumer already registered\n"))
+ return;
+ cxl_cper_prot_err_work = work;
+}
+EXPORT_SYMBOL_FOR_MODULES(cxl_cper_register_prot_err_work, "cxl_core");
+
+void cxl_cper_unregister_prot_err_work(void)
+{
+ struct work_struct *old;
+
+ scoped_guard(raw_spinlock_irqsave, &cxl_cper_prot_err_work_lock) {
+ WARN_ONCE(!cxl_cper_prot_err_work,
+ "CPER-CXL kfifo consumer not registered on unregister\n");
+ old = cxl_cper_prot_err_work;
+ cxl_cper_prot_err_work = NULL;
+ }
+
+ if (old)
+ cancel_work_sync(old);
+
+ /* Discard stale entries so they are not replayed on next module load */
+ kfifo_reset(&cxl_cper_prot_err_fifo);
+}
+EXPORT_SYMBOL_FOR_MODULES(cxl_cper_unregister_prot_err_work, "cxl_core");
+
+int cxl_cper_prot_err_kfifo_get(struct cxl_cper_prot_err_work_data *wd)
+{
+ return kfifo_get(&cxl_cper_prot_err_fifo, wd);
+}
+EXPORT_SYMBOL_FOR_MODULES(cxl_cper_prot_err_kfifo_get, "cxl_core");
+
+/* Room for 8 entries for each of the 4 event log queues */
+#define CXL_CPER_FIFO_DEPTH 32
+DEFINE_KFIFO(cxl_cper_fifo, struct cxl_cper_work_data, CXL_CPER_FIFO_DEPTH);
+
+/* Synchronize schedule_work() with cxl_cper_work changes */
+static DEFINE_RAW_SPINLOCK(cxl_cper_work_lock);
+struct work_struct *cxl_cper_work;
+
+void cxl_cper_post_event(enum cxl_event_type event_type,
+ struct cxl_cper_event_rec *rec, u32 len)
+{
+ struct cxl_cper_work_data wd;
+
+ if (len < sizeof(*rec)) {
+ pr_err(FW_WARN "CXL CPER section too small (%u)\n", len);
+ return;
+ }
+
+ if (rec->hdr.length <= sizeof(rec->hdr) ||
+ rec->hdr.length > sizeof(*rec)) {
+ pr_err(FW_WARN "CXL CPER Invalid section length (%u)\n",
+ rec->hdr.length);
+ return;
+ }
+
+ if (!(rec->hdr.validation_bits & CPER_CXL_COMP_EVENT_LOG_VALID)) {
+ pr_err(FW_WARN "CXL CPER invalid event\n");
+ return;
+ }
+
+ guard(raw_spinlock_irqsave)(&cxl_cper_work_lock);
+
+ if (!cxl_cper_work)
+ return;
+
+ wd.event_type = event_type;
+ memcpy(&wd.rec, rec, sizeof(wd.rec));
+
+ if (!kfifo_put(&cxl_cper_fifo, wd)) {
+ pr_err_ratelimited("CXL CPER kfifo overflow\n");
+ return;
+ }
+
+ schedule_work(cxl_cper_work);
+}
+
+int cxl_cper_register_work(struct work_struct *work)
+{
+ guard(raw_spinlock_irqsave)(&cxl_cper_work_lock);
+ if (WARN_ONCE(cxl_cper_work,
+ "CXL CPER kfifo consumer already registered\n"))
+ return -EINVAL;
+
+ cxl_cper_work = work;
+ return 0;
+}
+EXPORT_SYMBOL_NS_GPL(cxl_cper_register_work, "CXL");
+
+void cxl_cper_unregister_work(struct work_struct *work)
+{
+ scoped_guard(raw_spinlock_irqsave, &cxl_cper_work_lock) {
+ if (WARN_ONCE(cxl_cper_work != work,
+ "CXL CPER kfifo consumer mismatch on unregister\n"))
+ return;
+ cxl_cper_work = NULL;
+ }
+
+ cancel_work_sync(work);
+
+ /* Discard stale entries so they are not replayed on next module load */
+ kfifo_reset(&cxl_cper_fifo);
+}
+EXPORT_SYMBOL_NS_GPL(cxl_cper_unregister_work, "CXL");
+
+int cxl_cper_kfifo_get(struct cxl_cper_work_data *wd)
+{
+ return kfifo_get(&cxl_cper_fifo, wd);
+}
+EXPORT_SYMBOL_NS_GPL(cxl_cper_kfifo_get, "CXL");
+
/*
* GHES error status reporting throttle, to report more kinds of
* errors, instead of just most frequently occurred errors.
diff --git a/include/acpi/ghes_cper.h b/include/acpi/ghes_cper.h
index 38f8e0782b9e..5821eca46d63 100644
--- a/include/acpi/ghes_cper.h
+++ b/include/acpi/ghes_cper.h
@@ -20,6 +20,7 @@
#include <acpi/ghes.h>
#include <asm/fixmap.h>
+#include <cxl/event.h>
#define GHES_PFX "GHES: "
@@ -106,5 +107,15 @@ void ghes_estatus_cache_add(struct acpi_hest_generic *generic,
struct acpi_hest_generic_status *estatus);
void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
int sev);
+void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
+ int severity, u32 len);
+void cxl_cper_register_prot_err_work(struct work_struct *work);
+void cxl_cper_unregister_prot_err_work(void);
+int cxl_cper_prot_err_kfifo_get(struct cxl_cper_prot_err_work_data *wd);
+void cxl_cper_post_event(enum cxl_event_type event_type,
+ struct cxl_cper_event_rec *rec, u32 len);
+int cxl_cper_register_work(struct work_struct *work);
+void cxl_cper_unregister_work(struct work_struct *work);
+int cxl_cper_kfifo_get(struct cxl_cper_work_data *wd);
#endif /* ACPI_APEI_GHES_CPER_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 19/22] ACPI: APEI: introduce GHES CPER helper configuration
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (17 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 18/22] ACPI: APEI: GHES: move CXL CPER helpers Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 20/22] ACPI: APEI: share GHES CPER helpers Ahmed Tiba
` (2 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain
Add a dedicated GHES_CPER_HELPERS Kconfig entry and route ghes_cper.o
through it. Select the helper configuration from ACPI_APEI_GHES and update
the public declarations to follow the new symbol.
This prepares the helper implementation to be selected by firmware-first
providers that do not build the ACPI GHES driver.
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/Makefile | 1 +
drivers/acpi/Kconfig | 4 ++++
drivers/acpi/apei/Kconfig | 1 +
drivers/acpi/apei/Makefile | 2 +-
include/acpi/ghes.h | 10 ++++++----
include/cxl/event.h | 2 +-
6 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/Makefile b/drivers/Makefile
index 0841ea851847..27a664cb45ea 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -31,6 +31,7 @@ obj-y += idle/
obj-y += char/ipmi/
obj-$(CONFIG_ACPI) += acpi/
+obj-$(CONFIG_GHES_CPER_HELPERS) += acpi/apei/ghes_cper.o
# PnP must come after ACPI since it will eventually need to check if acpi
# was used and do nothing if so
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index fa3eb52b22cd..3cec674cf788 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -6,6 +6,10 @@
config ARCH_SUPPORTS_ACPI
bool
+config GHES_CPER_HELPERS
+ bool
+ select UEFI_CPER
+
menuconfig ACPI
bool "ACPI (Advanced Configuration and Power Interface) Support"
depends on ARCH_SUPPORTS_ACPI
diff --git a/drivers/acpi/apei/Kconfig b/drivers/acpi/apei/Kconfig
index 428458c623f0..ddb62638eb02 100644
--- a/drivers/acpi/apei/Kconfig
+++ b/drivers/acpi/apei/Kconfig
@@ -21,6 +21,7 @@ config ACPI_APEI_GHES
bool "APEI Generic Hardware Error Source"
depends on ACPI_APEI
select ACPI_HED
+ select GHES_CPER_HELPERS
select IRQ_WORK
select GENERIC_ALLOCATOR
select ARM_SDE_INTERFACE if ARM64
diff --git a/drivers/acpi/apei/Makefile b/drivers/acpi/apei/Makefile
index f57f3b009d8e..66588d6be56f 100644
--- a/drivers/acpi/apei/Makefile
+++ b/drivers/acpi/apei/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_ACPI_APEI) += apei.o
-obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o ghes_cper.o
+obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o
# clang versions prior to 18 may blow out the stack with KASAN
ifeq ($(CONFIG_COMPILE_TEST)_$(CONFIG_CC_IS_CLANG)_$(call clang-min-version, 180000),y_y_)
KASAN_SANITIZE_ghes.o := n
diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h
index 56274dbe3bff..9b28a417d94d 100644
--- a/include/acpi/ghes.h
+++ b/include/acpi/ghes.h
@@ -85,18 +85,20 @@ int devm_ghes_register_vendor_record_notifier(struct device *dev,
struct list_head *ghes_get_devices(void);
-void ghes_estatus_pool_region_free(unsigned long addr, u32 size);
-
struct cxl_cper_sec_prot_err;
void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
int severity, u32 len);
#else
static inline struct list_head *ghes_get_devices(void) { return NULL; }
-
-static inline void ghes_estatus_pool_region_free(unsigned long addr, u32 size) { return; }
#endif
+#ifdef CONFIG_GHES_CPER_HELPERS
int ghes_estatus_pool_init(unsigned int num_ghes);
+void ghes_estatus_pool_region_free(unsigned long addr, u32 size);
+#else
+static inline int ghes_estatus_pool_init(unsigned int num_ghes) { return -ENODEV; }
+static inline void ghes_estatus_pool_region_free(unsigned long addr, u32 size) { }
+#endif
static inline int acpi_hest_get_version(struct acpi_hest_generic_data *gdata)
{
diff --git a/include/cxl/event.h b/include/cxl/event.h
index a9f5c2381cc9..91fb76d052b5 100644
--- a/include/cxl/event.h
+++ b/include/cxl/event.h
@@ -285,7 +285,7 @@ struct cxl_cper_prot_err_work_data {
int severity;
};
-#ifdef CONFIG_ACPI_APEI_GHES
+#ifdef CONFIG_GHES_CPER_HELPERS
int cxl_cper_register_work(struct work_struct *work);
void cxl_cper_unregister_work(struct work_struct *work);
int cxl_cper_kfifo_get(struct cxl_cper_work_data *wd);
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 20/22] ACPI: APEI: share GHES CPER helpers
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (18 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 19/22] ACPI: APEI: introduce GHES CPER helper configuration Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 21/22] dt-bindings: firmware: add arm,ras-cper Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 22/22] RAS: add firmware-first CPER provider Ahmed Tiba
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain
Move the remaining GHES CPER status-processing and error-status pool
helpers from ghes.c into ghes_cper.c. Replace the local processing entry
point with a wrapper that supplies the device, source descriptor, and
notification context to the shared implementation.
Export the pool and notifier interfaces needed by other firmware-first
providers. Provide the architecture memory-error fallback required when the
helper is built without ACPI APEI.
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 482 +---------------------------------------
drivers/acpi/apei/ghes_cper.c | 503 ++++++++++++++++++++++++++++++++++++++++++
include/acpi/ghes_cper.h | 20 ++
3 files changed, 525 insertions(+), 480 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 7b460d6fa0d2..3a3a864ac5f6 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -67,8 +67,6 @@
#define FIX_APEI_GHES_SDEI_CRITICAL __end_of_fixed_addresses
#endif
-static ATOMIC_NOTIFIER_HEAD(ghes_report_chain);
-
/*
* This driver isn't really modular, however for the time being,
* continuing to use module_param is the easiest way to remain
@@ -113,487 +111,11 @@ static DEFINE_MUTEX(ghes_devs_mutex);
*/
static DEFINE_SPINLOCK(ghes_notify_lock_irq);
-struct gen_pool *ghes_estatus_pool;
-static DEFINE_MUTEX(ghes_estatus_pool_lock);
-
-int ghes_estatus_pool_init(unsigned int num_ghes)
-{
- unsigned long addr, len;
- int rc;
-
- len = GHES_ESTATUS_CACHE_AVG_SIZE * GHES_ESTATUS_CACHE_ALLOCED_MAX;
- len += (num_ghes * GHES_ESOURCE_PREALLOC_MAX_SIZE);
-
- mutex_lock(&ghes_estatus_pool_lock);
-
- if (!ghes_estatus_pool) {
- ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1);
- if (!ghes_estatus_pool) {
- rc = -ENOMEM;
- goto out_unlock;
- }
- }
-
- addr = (unsigned long)vmalloc(PAGE_ALIGN(len));
- if (!addr) {
- rc = -ENOMEM;
- goto err_pool_alloc;
- }
-
- rc = gen_pool_add(ghes_estatus_pool, addr, PAGE_ALIGN(len), -1);
- if (rc)
- goto err_pool_add;
-
- mutex_unlock(&ghes_estatus_pool_lock);
- return 0;
-
-err_pool_add:
- vfree((void *)addr);
-
-err_pool_alloc:
- if (!gen_pool_avail(ghes_estatus_pool) &&
- !gen_pool_size(ghes_estatus_pool)) {
- gen_pool_destroy(ghes_estatus_pool);
- ghes_estatus_pool = NULL;
- }
-out_unlock:
- mutex_unlock(&ghes_estatus_pool_lock);
- return rc;
-}
-
-/**
- * ghes_estatus_pool_region_free - free previously allocated memory
- * from the ghes_estatus_pool.
- * @addr: address of memory to free.
- * @size: size of memory to free.
- *
- * Returns none.
- */
-void ghes_estatus_pool_region_free(unsigned long addr, u32 size)
-{
- gen_pool_free(ghes_estatus_pool, addr, size);
-}
-EXPORT_SYMBOL_GPL(ghes_estatus_pool_region_free);
-
-static inline int ghes_severity(int severity)
-{
- switch (severity) {
- case CPER_SEV_INFORMATIONAL:
- return GHES_SEV_NO;
- case CPER_SEV_CORRECTED:
- return GHES_SEV_CORRECTED;
- case CPER_SEV_RECOVERABLE:
- return GHES_SEV_RECOVERABLE;
- case CPER_SEV_FATAL:
- return GHES_SEV_PANIC;
- default:
- /* Unknown, go panic */
- return GHES_SEV_PANIC;
- }
-}
-
-
-/**
- * struct ghes_task_work - for synchronous RAS event
- *
- * @twork: callback_head for task work
- * @pfn: page frame number of corrupted page
- * @flags: work control flags
- *
- * Structure to pass task work to be handled before
- * returning to user-space via task_work_add().
- */
-struct ghes_task_work {
- struct callback_head twork;
- u64 pfn;
- int flags;
-};
-
-static void memory_failure_cb(struct callback_head *twork)
-{
- struct ghes_task_work *twcb = container_of(twork, struct ghes_task_work, twork);
- int ret;
-
- ret = memory_failure(twcb->pfn, twcb->flags);
- if (!ret || ret == -EHWPOISON || ret == -EOPNOTSUPP)
- goto out;
-
- pr_err("%#llx: Sending SIGBUS to %s:%d due to hardware memory corruption\n",
- twcb->pfn, current->comm, task_pid_nr(current));
- force_sig(SIGBUS);
-
-out:
- gen_pool_free(ghes_estatus_pool, (unsigned long)twcb, sizeof(*twcb));
-}
-
-static bool ghes_do_memory_failure(u64 physical_addr, int flags)
-{
- struct ghes_task_work *twcb;
- unsigned long pfn;
-
- if (!IS_ENABLED(CONFIG_ACPI_APEI_MEMORY_FAILURE))
- return false;
-
- pfn = PHYS_PFN(physical_addr);
-
- if (flags == MF_ACTION_REQUIRED && current->mm) {
- twcb = (void *)gen_pool_alloc(ghes_estatus_pool, sizeof(*twcb));
- if (!twcb)
- return false;
-
- twcb->pfn = pfn;
- twcb->flags = flags;
- init_task_work(&twcb->twork, memory_failure_cb);
- task_work_add(current, &twcb->twork, TWA_RESUME);
- return true;
- }
-
- memory_failure_queue(pfn, flags);
- return true;
-}
-
-static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata,
- int sev, bool sync)
-{
- int flags = -1;
- int sec_sev = ghes_severity(gdata->error_severity);
- struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata);
-
- if (!(mem_err->validation_bits & CPER_MEM_VALID_PA))
- return false;
-
- /* iff following two events can be handled properly by now */
- if (sec_sev == GHES_SEV_CORRECTED &&
- (gdata->flags & CPER_SEC_ERROR_THRESHOLD_EXCEEDED))
- flags = MF_SOFT_OFFLINE;
- if (sev == GHES_SEV_RECOVERABLE && sec_sev == GHES_SEV_RECOVERABLE)
- flags = sync ? MF_ACTION_REQUIRED : 0;
-
- if (flags != -1)
- return ghes_do_memory_failure(mem_err->physical_addr, flags);
-
- return false;
-}
-
-static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
- int sev, bool sync)
-{
- struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata);
- int flags = sync ? MF_ACTION_REQUIRED : 0;
- int length = gdata->error_data_length;
- char error_type[120];
- bool queued = false;
- int sec_sev, i;
- char *p;
-
- sec_sev = ghes_severity(gdata->error_severity);
- if (length >= sizeof(*err)) {
- log_arm_hw_error(err, sec_sev);
- } else {
- pr_warn(FW_BUG "arm error length: %d\n", length);
- pr_warn(FW_BUG "length is too small\n");
- pr_warn(FW_BUG "firmware-generated error record is incorrect\n");
- return false;
- }
-
- if (sev != GHES_SEV_RECOVERABLE || sec_sev != GHES_SEV_RECOVERABLE)
- return false;
-
- p = (char *)(err + 1);
- length -= sizeof(*err);
-
- for (i = 0; i < err->err_info_num; i++) {
- struct cper_arm_err_info *err_info;
- bool is_cache, has_pa;
-
- /* Ensure we have enough data for the error info header */
- if (length < sizeof(*err_info))
- break;
-
- err_info = (struct cper_arm_err_info *)p;
-
- /* Validate the claimed length before using it */
- length -= err_info->length;
- if (length < 0)
- break;
-
- is_cache = err_info->type & CPER_ARM_CACHE_ERROR;
- has_pa = (err_info->validation_bits & CPER_ARM_INFO_VALID_PHYSICAL_ADDR);
-
- /*
- * The field (err_info->error_info & BIT(26)) is fixed to set to
- * 1 in some old firmware of HiSilicon Kunpeng920. We assume that
- * firmware won't mix corrected errors in an uncorrected section,
- * and don't filter out 'corrected' error here.
- */
- if (is_cache && has_pa) {
- queued |= ghes_do_memory_failure(err_info->physical_fault_addr, flags);
- p += err_info->length;
- continue;
- }
-
- cper_bits_to_str(error_type, sizeof(error_type),
- FIELD_GET(CPER_ARM_ERR_TYPE_MASK, err_info->type),
- cper_proc_error_type_strs,
- ARRAY_SIZE(cper_proc_error_type_strs));
-
- pr_warn_ratelimited(FW_WARN GHES_PFX
- "Unhandled processor error type 0x%02x: %s%s\n",
- err_info->type, error_type,
- (err_info->type & ~CPER_ARM_ERR_TYPE_MASK) ? " with reserved bit(s)" : "");
- p += err_info->length;
- }
-
- return queued;
-}
-
-/*
- * PCIe AER errors need to be sent to the AER driver for reporting and
- * recovery. The GHES severities map to the following AER severities and
- * require the following handling:
- *
- * GHES_SEV_CORRECTABLE -> AER_CORRECTABLE
- * These need to be reported by the AER driver but no recovery is
- * necessary.
- * GHES_SEV_RECOVERABLE -> AER_NONFATAL
- * GHES_SEV_RECOVERABLE && CPER_SEC_RESET -> AER_FATAL
- * These both need to be reported and recovered from by the AER driver.
- * GHES_SEV_PANIC does not make it to this handling since the kernel must
- * panic.
- */
-static void ghes_handle_aer(struct acpi_hest_generic_data *gdata)
-{
-#ifdef CONFIG_ACPI_APEI_PCIEAER
- struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
-
- if (gdata->error_data_length < sizeof(*pcie_err))
- return;
-
- if (pcie_err->validation_bits & CPER_PCIE_VALID_DEVICE_ID &&
- pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO) {
- struct aer_capability_regs *aer_info;
- unsigned int devfn;
- int aer_severity;
-
- devfn = PCI_DEVFN(pcie_err->device_id.device,
- pcie_err->device_id.function);
- aer_severity = cper_severity_to_aer(gdata->error_severity);
-
- /*
- * If firmware reset the component to contain
- * the error, we must reinitialize it before
- * use, so treat it as a fatal AER error.
- */
- if (gdata->flags & CPER_SEC_RESET)
- aer_severity = AER_FATAL;
-
- aer_info = (void *)gen_pool_alloc(ghes_estatus_pool,
- sizeof(struct aer_capability_regs));
- if (!aer_info)
- return;
-
- aer_cap_regs_unpack(aer_info, pcie_err->aer_info, sizeof(pcie_err->aer_info));
-
- aer_recover_queue(pcie_err->device_id.segment,
- pcie_err->device_id.bus,
- devfn, aer_severity, aer_info);
- }
-#endif
-}
-
-static void ghes_log_hwerr(int sev, guid_t *sec_type)
-{
- if (sev != GHES_SEV_RECOVERABLE)
- return;
-
- if (guid_equal(sec_type, &CPER_SEC_PROC_ARM) ||
- guid_equal(sec_type, &CPER_SEC_PROC_GENERIC) ||
- guid_equal(sec_type, &CPER_SEC_PROC_IA)) {
- hwerr_log_error_type(HWERR_RECOV_CPU);
- return;
- }
-
- if (guid_equal(sec_type, &CPER_SEC_CXL_PROT_ERR) ||
- guid_equal(sec_type, &CPER_SEC_CXL_GEN_MEDIA_GUID) ||
- guid_equal(sec_type, &CPER_SEC_CXL_DRAM_GUID) ||
- guid_equal(sec_type, &CPER_SEC_CXL_MEM_MODULE_GUID)) {
- hwerr_log_error_type(HWERR_RECOV_CXL);
- return;
- }
-
- if (guid_equal(sec_type, &CPER_SEC_PCIE) ||
- guid_equal(sec_type, &CPER_SEC_PCI_X_BUS)) {
- hwerr_log_error_type(HWERR_RECOV_PCI);
- return;
- }
-
- if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
- hwerr_log_error_type(HWERR_RECOV_MEMORY);
- return;
- }
-
- hwerr_log_error_type(HWERR_RECOV_OTHERS);
-}
-
-/*
- * The fields from "extended" on are absent from the 73-byte UEFI 2.1/2.2
- * layout that older firmware still emits. Return the length needed for the
- * fields the validation bits claim, so over-claiming is rejected without
- * rejecting an honest short record.
- */
-static u32 ghes_mem_err_min_len(u64 validation_bits)
-{
- u32 len = sizeof(struct cper_sec_mem_err_old);
-
- if (validation_bits & (CPER_MEM_VALID_ROW_EXT | CPER_MEM_VALID_CHIP_ID))
- len = offsetof(struct cper_sec_mem_err, rank);
- if (validation_bits & CPER_MEM_VALID_RANK_NUMBER)
- len = offsetof(struct cper_sec_mem_err, mem_array_handle);
- if (validation_bits & CPER_MEM_VALID_CARD_HANDLE)
- len = offsetof(struct cper_sec_mem_err, mem_dev_handle);
- if (validation_bits & CPER_MEM_VALID_MODULE_HANDLE)
- len = sizeof(struct cper_sec_mem_err);
-
- return len;
-}
-
static void ghes_do_proc(struct ghes *ghes,
const struct acpi_hest_generic_status *estatus)
{
- int sev, sec_sev;
- struct acpi_hest_generic_data *gdata;
- guid_t *sec_type;
- const guid_t *fru_id = &guid_null;
- char *fru_text = "";
- bool queued = false;
- bool sync = is_hest_sync_notify(ghes);
-
- sev = ghes_severity(estatus->error_severity);
- apei_estatus_for_each_section(estatus, gdata) {
- sec_type = (guid_t *)gdata->section_type;
- sec_sev = ghes_severity(gdata->error_severity);
- fru_id = &guid_null;
- fru_text = "";
-
- if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
- fru_id = (guid_t *)gdata->fru_id;
-
- if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
- fru_text = gdata->fru_text;
-
- ghes_log_hwerr(sev, sec_type);
- if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
- struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata);
-
- /*
- * Check once for all three consumers below. The 73-byte
- * UEFI 2.1/2.2 layout is the floor, matching
- * cper_estatus_print_section() and making
- * validation_bits safe to read.
- */
- if (gdata->error_data_length <
- sizeof(struct cper_sec_mem_err_old))
- continue;
-
- /* Then require what the claimed fields actually need. */
- if (gdata->error_data_length <
- ghes_mem_err_min_len(mem_err->validation_bits)) {
- pr_warn_ratelimited(FW_WARN GHES_PFX
- "memory error section too small (%u) for the fields it claims\n",
- gdata->error_data_length);
- continue;
- }
-
- atomic_notifier_call_chain(&ghes_report_chain, sev, mem_err);
-
- arch_apei_report_mem_error(sev, mem_err);
- queued |= ghes_handle_memory_failure(gdata, sev, sync);
- } else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
- ghes_handle_aer(gdata);
- } else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) {
- queued |= ghes_handle_arm_hw_error(gdata, sev, sync);
- } else if (guid_equal(sec_type, &CPER_SEC_CXL_PROT_ERR)) {
- struct cxl_cper_sec_prot_err *prot_err = acpi_hest_get_payload(gdata);
-
- cxl_cper_post_prot_err(prot_err, gdata->error_severity,
- gdata->error_data_length);
- } else if (guid_equal(sec_type, &CPER_SEC_CXL_GEN_MEDIA_GUID)) {
- struct cxl_cper_event_rec *rec = acpi_hest_get_payload(gdata);
-
- cxl_cper_post_event(CXL_CPER_EVENT_GEN_MEDIA, rec,
- gdata->error_data_length);
- } else if (guid_equal(sec_type, &CPER_SEC_CXL_DRAM_GUID)) {
- struct cxl_cper_event_rec *rec = acpi_hest_get_payload(gdata);
-
- cxl_cper_post_event(CXL_CPER_EVENT_DRAM, rec,
- gdata->error_data_length);
- } else if (guid_equal(sec_type, &CPER_SEC_CXL_MEM_MODULE_GUID)) {
- struct cxl_cper_event_rec *rec = acpi_hest_get_payload(gdata);
-
- cxl_cper_post_event(CXL_CPER_EVENT_MEM_MODULE, rec,
- gdata->error_data_length);
- } else {
- void *err = acpi_hest_get_payload(gdata);
-
- ghes_defer_non_standard_event(gdata, sev);
- log_non_standard_event(sec_type, fru_id, fru_text,
- sec_sev, err,
- gdata->error_data_length);
- }
- }
-
- /*
- * If no memory failure work is queued for abnormal synchronous
- * errors, do a force kill.
- */
- if (sync && !queued) {
- dev_err(ghes->dev,
- HW_ERR GHES_PFX "%s:%d: synchronous unrecoverable error (SIGBUS)\n",
- current->comm, task_pid_nr(current));
- force_sig(SIGBUS);
- }
-}
-
-static void __ghes_print_estatus(const char *pfx,
- const struct acpi_hest_generic *generic,
- const struct acpi_hest_generic_status *estatus)
-{
- static atomic_t seqno;
- unsigned int curr_seqno;
- char pfx_seq[64];
-
- if (pfx == NULL) {
- if (ghes_severity(estatus->error_severity) <=
- GHES_SEV_CORRECTED)
- pfx = KERN_WARNING;
- else
- pfx = KERN_ERR;
- }
- curr_seqno = atomic_inc_return(&seqno);
- snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
- printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
- pfx_seq, generic->header.source_id);
- cper_estatus_print(pfx_seq, estatus);
-}
-
-static int ghes_print_estatus(const char *pfx,
- const struct acpi_hest_generic *generic,
- const struct acpi_hest_generic_status *estatus)
-{
- /* Not more than 2 messages every 5 seconds */
- static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2);
- static DEFINE_RATELIMIT_STATE(ratelimit_uncorrected, 5*HZ, 2);
- struct ratelimit_state *ratelimit;
-
- if (ghes_severity(estatus->error_severity) <= GHES_SEV_CORRECTED)
- ratelimit = &ratelimit_corrected;
- else
- ratelimit = &ratelimit_uncorrected;
- if (__ratelimit(ratelimit)) {
- __ghes_print_estatus(pfx, generic, estatus);
- return 1;
- }
- return 0;
+ ghes_cper_handle_status(ghes->dev, ghes->generic,
+ estatus, is_hest_sync_notify(ghes));
}
static void __ghes_panic(struct ghes *ghes,
diff --git a/drivers/acpi/apei/ghes_cper.c b/drivers/acpi/apei/ghes_cper.c
index 2037046d9be8..bceac27ac274 100644
--- a/drivers/acpi/apei/ghes_cper.c
+++ b/drivers/acpi/apei/ghes_cper.c
@@ -13,7 +13,9 @@
*/
#include <linux/aer.h>
+#include <linux/bitfield.h>
#include <linux/cleanup.h>
+#include <linux/device.h>
#include <linux/err.h>
#include <linux/genalloc.h>
#include <linux/io.h>
@@ -21,11 +23,20 @@
#include <linux/kernel.h>
#include <linux/math64.h>
#include <linux/mm.h>
+#include <linux/mutex.h>
+#include <linux/string.h>
+#include <linux/uuid.h>
+#include <linux/sched/signal.h>
+#include <linux/task_work.h>
#include <linux/notifier.h>
+#include <linux/ras.h>
+#include <ras/ras_event.h>
#include <linux/ratelimit.h>
#include <linux/rcupdate.h>
#include <linux/sched/clock.h>
#include <linux/slab.h>
+#include <linux/vmcore_info.h>
+#include <linux/vmalloc.h>
#include <acpi/apei.h>
#include <acpi/acpi_io.h>
@@ -36,9 +47,500 @@
#include "apei-internal.h"
+ATOMIC_NOTIFIER_HEAD(ghes_report_chain);
+
+#ifndef CONFIG_ACPI_APEI
+void __weak arch_apei_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) { }
+#endif
+
static struct ghes_estatus_cache __rcu *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE];
static atomic_t ghes_estatus_cache_alloced;
+struct gen_pool *ghes_estatus_pool;
+static DEFINE_MUTEX(ghes_estatus_pool_lock);
+
+int ghes_estatus_pool_init(unsigned int num_ghes)
+{
+ unsigned long addr, len;
+ int rc;
+
+ len = GHES_ESTATUS_CACHE_AVG_SIZE * GHES_ESTATUS_CACHE_ALLOCED_MAX;
+ len += (num_ghes * GHES_ESOURCE_PREALLOC_MAX_SIZE);
+
+ mutex_lock(&ghes_estatus_pool_lock);
+
+ if (!ghes_estatus_pool) {
+ ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1);
+ if (!ghes_estatus_pool) {
+ rc = -ENOMEM;
+ goto out_unlock;
+ }
+ }
+
+ addr = (unsigned long)vmalloc(PAGE_ALIGN(len));
+ if (!addr) {
+ rc = -ENOMEM;
+ goto err_pool_alloc;
+ }
+
+ rc = gen_pool_add(ghes_estatus_pool, addr, PAGE_ALIGN(len), -1);
+ if (rc)
+ goto err_pool_add;
+
+ mutex_unlock(&ghes_estatus_pool_lock);
+ return 0;
+
+err_pool_add:
+ vfree((void *)addr);
+
+err_pool_alloc:
+ if (!gen_pool_avail(ghes_estatus_pool) &&
+ !gen_pool_size(ghes_estatus_pool)) {
+ gen_pool_destroy(ghes_estatus_pool);
+ ghes_estatus_pool = NULL;
+ }
+out_unlock:
+ mutex_unlock(&ghes_estatus_pool_lock);
+ return rc;
+}
+EXPORT_SYMBOL_GPL(ghes_estatus_pool_init);
+
+/**
+ * ghes_estatus_pool_region_free - free previously allocated memory
+ * from the ghes_estatus_pool.
+ * @addr: address of memory to free.
+ * @size: size of memory to free.
+ *
+ * Returns none.
+ */
+void ghes_estatus_pool_region_free(unsigned long addr, u32 size)
+{
+ gen_pool_free(ghes_estatus_pool, addr, size);
+}
+EXPORT_SYMBOL_GPL(ghes_estatus_pool_region_free);
+
+int ghes_severity(int severity)
+{
+ switch (severity) {
+ case CPER_SEV_INFORMATIONAL:
+ return GHES_SEV_NO;
+ case CPER_SEV_CORRECTED:
+ return GHES_SEV_CORRECTED;
+ case CPER_SEV_RECOVERABLE:
+ return GHES_SEV_RECOVERABLE;
+ case CPER_SEV_FATAL:
+ return GHES_SEV_PANIC;
+ default:
+ /* Unknown, go panic */
+ return GHES_SEV_PANIC;
+ }
+}
+
+/**
+ * struct ghes_task_work - for synchronous RAS event
+ *
+ * @twork: callback_head for task work
+ * @pfn: page frame number of corrupted page
+ * @flags: work control flags
+ *
+ * Structure to pass task work to be handled before
+ * returning to user-space via task_work_add().
+ */
+struct ghes_task_work {
+ struct callback_head twork;
+ u64 pfn;
+ int flags;
+};
+
+static void memory_failure_cb(struct callback_head *twork)
+{
+ struct ghes_task_work *twcb = container_of(twork, struct ghes_task_work, twork);
+ int ret;
+
+ ret = memory_failure(twcb->pfn, twcb->flags);
+ if (!ret || ret == -EHWPOISON || ret == -EOPNOTSUPP)
+ goto out;
+
+ pr_err("%#llx: Sending SIGBUS to %s:%d due to hardware memory corruption\n",
+ twcb->pfn, current->comm, task_pid_nr(current));
+ force_sig(SIGBUS);
+
+out:
+ gen_pool_free(ghes_estatus_pool, (unsigned long)twcb, sizeof(*twcb));
+}
+
+static bool ghes_do_memory_failure(u64 physical_addr, int flags)
+{
+ struct ghes_task_work *twcb;
+ unsigned long pfn;
+
+ if (!IS_ENABLED(CONFIG_ACPI_APEI_MEMORY_FAILURE))
+ return false;
+
+ pfn = PHYS_PFN(physical_addr);
+
+ if (flags == MF_ACTION_REQUIRED && current->mm) {
+ twcb = (void *)gen_pool_alloc(ghes_estatus_pool, sizeof(*twcb));
+ if (!twcb)
+ return false;
+
+ twcb->pfn = pfn;
+ twcb->flags = flags;
+ init_task_work(&twcb->twork, memory_failure_cb);
+ task_work_add(current, &twcb->twork, TWA_RESUME);
+ return true;
+ }
+
+ memory_failure_queue(pfn, flags);
+ return true;
+}
+
+bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata,
+ int sev, bool sync)
+{
+ int flags = -1;
+ int sec_sev = ghes_severity(gdata->error_severity);
+ struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata);
+
+ if (!(mem_err->validation_bits & CPER_MEM_VALID_PA))
+ return false;
+
+ /* iff following two events can be handled properly by now */
+ if (sec_sev == GHES_SEV_CORRECTED &&
+ (gdata->flags & CPER_SEC_ERROR_THRESHOLD_EXCEEDED))
+ flags = MF_SOFT_OFFLINE;
+ if (sev == GHES_SEV_RECOVERABLE && sec_sev == GHES_SEV_RECOVERABLE)
+ flags = sync ? MF_ACTION_REQUIRED : 0;
+
+ if (flags != -1)
+ return ghes_do_memory_failure(mem_err->physical_addr, flags);
+
+ return false;
+}
+
+bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
+ int sev, bool sync)
+{
+ struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata);
+ int flags = sync ? MF_ACTION_REQUIRED : 0;
+ int length = gdata->error_data_length;
+ char error_type[120];
+ bool queued = false;
+ int sec_sev, i;
+ char *p;
+
+ sec_sev = ghes_severity(gdata->error_severity);
+ if (length >= sizeof(*err)) {
+ log_arm_hw_error(err, sec_sev);
+ } else {
+ pr_warn(FW_BUG "arm error length: %d\n", length);
+ pr_warn(FW_BUG "length is too small\n");
+ pr_warn(FW_BUG "firmware-generated error record is incorrect\n");
+ return false;
+ }
+
+ if (sev != GHES_SEV_RECOVERABLE || sec_sev != GHES_SEV_RECOVERABLE)
+ return false;
+
+ p = (char *)(err + 1);
+ length -= sizeof(*err);
+
+ for (i = 0; i < err->err_info_num; i++) {
+ struct cper_arm_err_info *err_info;
+ bool is_cache, has_pa;
+
+ /* Ensure we have enough data for the error info header */
+ if (length < sizeof(*err_info))
+ break;
+
+ err_info = (struct cper_arm_err_info *)p;
+
+ /* Validate the claimed length before using it */
+ length -= err_info->length;
+ if (length < 0)
+ break;
+
+ is_cache = err_info->type & CPER_ARM_CACHE_ERROR;
+ has_pa = (err_info->validation_bits & CPER_ARM_INFO_VALID_PHYSICAL_ADDR);
+
+ /*
+ * The field (err_info->error_info & BIT(26)) is fixed to set to
+ * 1 in some old firmware of HiSilicon Kunpeng920. We assume that
+ * firmware won't mix corrected errors in an uncorrected section,
+ * and don't filter out 'corrected' error here.
+ */
+ if (is_cache && has_pa) {
+ queued |= ghes_do_memory_failure(err_info->physical_fault_addr, flags);
+ p += err_info->length;
+ continue;
+ }
+
+ cper_bits_to_str(error_type, sizeof(error_type),
+ FIELD_GET(CPER_ARM_ERR_TYPE_MASK, err_info->type),
+ cper_proc_error_type_strs,
+ ARRAY_SIZE(cper_proc_error_type_strs));
+
+ pr_warn_ratelimited(FW_WARN GHES_PFX
+ "Unhandled processor error type 0x%02x: %s%s\n",
+ err_info->type, error_type,
+ (err_info->type & ~CPER_ARM_ERR_TYPE_MASK) ? " with reserved bit(s)" : "");
+ p += err_info->length;
+ }
+
+ return queued;
+}
+
+/*
+ * PCIe AER errors need to be sent to the AER driver for reporting and
+ * recovery. The GHES severities map to the following AER severities and
+ * require the following handling:
+ *
+ * GHES_SEV_CORRECTABLE -> AER_CORRECTABLE
+ * These need to be reported by the AER driver but no recovery is
+ * necessary.
+ * GHES_SEV_RECOVERABLE -> AER_NONFATAL
+ * GHES_SEV_RECOVERABLE && CPER_SEC_RESET -> AER_FATAL
+ * These both need to be reported and recovered from by the AER driver.
+ * GHES_SEV_PANIC does not make it to this handling since the kernel must
+ * panic.
+ */
+void ghes_handle_aer(struct acpi_hest_generic_data *gdata)
+{
+#ifdef CONFIG_ACPI_APEI_PCIEAER
+ struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
+
+ if (gdata->error_data_length < sizeof(*pcie_err))
+ return;
+
+ if (pcie_err->validation_bits & CPER_PCIE_VALID_DEVICE_ID &&
+ pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO) {
+ struct aer_capability_regs *aer_info;
+ unsigned int devfn;
+ int aer_severity;
+
+ devfn = PCI_DEVFN(pcie_err->device_id.device,
+ pcie_err->device_id.function);
+ aer_severity = cper_severity_to_aer(gdata->error_severity);
+
+ /*
+ * If firmware reset the component to contain
+ * the error, we must reinitialize it before
+ * use, so treat it as a fatal AER error.
+ */
+ if (gdata->flags & CPER_SEC_RESET)
+ aer_severity = AER_FATAL;
+
+ aer_info = (void *)gen_pool_alloc(ghes_estatus_pool,
+ sizeof(struct aer_capability_regs));
+ if (!aer_info)
+ return;
+
+ aer_cap_regs_unpack(aer_info, pcie_err->aer_info, sizeof(pcie_err->aer_info));
+
+ aer_recover_queue(pcie_err->device_id.segment,
+ pcie_err->device_id.bus,
+ devfn, aer_severity, aer_info);
+ }
+#endif
+}
+
+void ghes_log_hwerr(int sev, guid_t *sec_type)
+{
+ if (sev != GHES_SEV_RECOVERABLE)
+ return;
+
+ if (guid_equal(sec_type, &CPER_SEC_PROC_ARM) ||
+ guid_equal(sec_type, &CPER_SEC_PROC_GENERIC) ||
+ guid_equal(sec_type, &CPER_SEC_PROC_IA)) {
+ hwerr_log_error_type(HWERR_RECOV_CPU);
+ return;
+ }
+
+ if (guid_equal(sec_type, &CPER_SEC_CXL_PROT_ERR) ||
+ guid_equal(sec_type, &CPER_SEC_CXL_GEN_MEDIA_GUID) ||
+ guid_equal(sec_type, &CPER_SEC_CXL_DRAM_GUID) ||
+ guid_equal(sec_type, &CPER_SEC_CXL_MEM_MODULE_GUID)) {
+ hwerr_log_error_type(HWERR_RECOV_CXL);
+ return;
+ }
+
+ if (guid_equal(sec_type, &CPER_SEC_PCIE) ||
+ guid_equal(sec_type, &CPER_SEC_PCI_X_BUS)) {
+ hwerr_log_error_type(HWERR_RECOV_PCI);
+ return;
+ }
+
+ if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
+ hwerr_log_error_type(HWERR_RECOV_MEMORY);
+ return;
+ }
+
+ hwerr_log_error_type(HWERR_RECOV_OTHERS);
+}
+
+/*
+ * The fields from "extended" on are absent from the 73-byte UEFI 2.1/2.2
+ * layout that older firmware still emits. Return the length needed for the
+ * fields the validation bits claim, so over-claiming is rejected without
+ * rejecting an honest short record.
+ */
+static u32 ghes_mem_err_min_len(u64 validation_bits)
+{
+ u32 len = sizeof(struct cper_sec_mem_err_old);
+
+ if (validation_bits & (CPER_MEM_VALID_ROW_EXT | CPER_MEM_VALID_CHIP_ID))
+ len = offsetof(struct cper_sec_mem_err, rank);
+ if (validation_bits & CPER_MEM_VALID_RANK_NUMBER)
+ len = offsetof(struct cper_sec_mem_err, mem_array_handle);
+ if (validation_bits & CPER_MEM_VALID_CARD_HANDLE)
+ len = offsetof(struct cper_sec_mem_err, mem_dev_handle);
+ if (validation_bits & CPER_MEM_VALID_MODULE_HANDLE)
+ len = sizeof(struct cper_sec_mem_err);
+
+ return len;
+}
+
+void ghes_cper_handle_status(struct device *dev,
+ const struct acpi_hest_generic *generic,
+ const struct acpi_hest_generic_status *estatus,
+ bool sync)
+{
+ int sev, sec_sev;
+ struct acpi_hest_generic_data *gdata;
+ guid_t *sec_type;
+ const guid_t *fru_id = &guid_null;
+ char *fru_text = "";
+ bool queued = false;
+
+ sev = ghes_severity(estatus->error_severity);
+ apei_estatus_for_each_section(estatus, gdata) {
+ sec_type = (guid_t *)gdata->section_type;
+ sec_sev = ghes_severity(gdata->error_severity);
+ fru_id = &guid_null;
+ fru_text = "";
+
+ if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
+ fru_id = (guid_t *)gdata->fru_id;
+
+ if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
+ fru_text = gdata->fru_text;
+
+ ghes_log_hwerr(sev, sec_type);
+ if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
+ struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata);
+
+ /*
+ * Check once for all three consumers below. The 73-byte
+ * UEFI 2.1/2.2 layout is the floor, matching
+ * cper_estatus_print_section() and making
+ * validation_bits safe to read.
+ */
+ if (gdata->error_data_length <
+ sizeof(struct cper_sec_mem_err_old))
+ continue;
+
+ /* Then require what the claimed fields actually need. */
+ if (gdata->error_data_length <
+ ghes_mem_err_min_len(mem_err->validation_bits)) {
+ pr_warn_ratelimited(FW_WARN GHES_PFX
+ "memory error section too small (%u) for the fields it claims\n",
+ gdata->error_data_length);
+ continue;
+ }
+
+ atomic_notifier_call_chain(&ghes_report_chain, sev, mem_err);
+
+ arch_apei_report_mem_error(sev, mem_err);
+ queued |= ghes_handle_memory_failure(gdata, sev, sync);
+ } else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
+ ghes_handle_aer(gdata);
+ } else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) {
+ queued |= ghes_handle_arm_hw_error(gdata, sev, sync);
+ } else if (guid_equal(sec_type, &CPER_SEC_CXL_PROT_ERR)) {
+ struct cxl_cper_sec_prot_err *prot_err = acpi_hest_get_payload(gdata);
+
+ cxl_cper_post_prot_err(prot_err, gdata->error_severity,
+ gdata->error_data_length);
+ } else if (guid_equal(sec_type, &CPER_SEC_CXL_GEN_MEDIA_GUID)) {
+ struct cxl_cper_event_rec *rec = acpi_hest_get_payload(gdata);
+
+ cxl_cper_post_event(CXL_CPER_EVENT_GEN_MEDIA, rec,
+ gdata->error_data_length);
+ } else if (guid_equal(sec_type, &CPER_SEC_CXL_DRAM_GUID)) {
+ struct cxl_cper_event_rec *rec = acpi_hest_get_payload(gdata);
+
+ cxl_cper_post_event(CXL_CPER_EVENT_DRAM, rec,
+ gdata->error_data_length);
+ } else if (guid_equal(sec_type, &CPER_SEC_CXL_MEM_MODULE_GUID)) {
+ struct cxl_cper_event_rec *rec = acpi_hest_get_payload(gdata);
+
+ cxl_cper_post_event(CXL_CPER_EVENT_MEM_MODULE, rec,
+ gdata->error_data_length);
+ } else {
+ void *err = acpi_hest_get_payload(gdata);
+
+ ghes_defer_non_standard_event(gdata, sev);
+ log_non_standard_event(sec_type, fru_id, fru_text,
+ sec_sev, err,
+ gdata->error_data_length);
+ }
+ }
+
+ /*
+ * If no memory failure work is queued for abnormal synchronous
+ * errors, do a force kill.
+ */
+ if (sync && !queued) {
+ dev_err(dev,
+ HW_ERR GHES_PFX "%s:%d: synchronous unrecoverable error (SIGBUS)\n",
+ current->comm, task_pid_nr(current));
+ force_sig(SIGBUS);
+ }
+}
+
+void __ghes_print_estatus(const char *pfx,
+ const struct acpi_hest_generic *generic,
+ const struct acpi_hest_generic_status *estatus)
+{
+ static atomic_t seqno;
+ unsigned int curr_seqno;
+ char pfx_seq[64];
+
+ if (pfx == NULL) {
+ if (ghes_severity(estatus->error_severity) <=
+ GHES_SEV_CORRECTED)
+ pfx = KERN_WARNING;
+ else
+ pfx = KERN_ERR;
+ }
+ curr_seqno = atomic_inc_return(&seqno);
+ snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
+ printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
+ pfx_seq, generic->header.source_id);
+ cper_estatus_print(pfx_seq, estatus);
+}
+
+int ghes_print_estatus(const char *pfx,
+ const struct acpi_hest_generic *generic,
+ const struct acpi_hest_generic_status *estatus)
+{
+ /* Not more than 2 messages every 5 seconds */
+ static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2);
+ static DEFINE_RATELIMIT_STATE(ratelimit_uncorrected, 5*HZ, 2);
+ struct ratelimit_state *ratelimit;
+
+ if (ghes_severity(estatus->error_severity) <= GHES_SEV_CORRECTED)
+ ratelimit = &ratelimit_corrected;
+ else
+ ratelimit = &ratelimit_uncorrected;
+ if (__ratelimit(ratelimit)) {
+ __ghes_print_estatus(pfx, generic, estatus);
+ return 1;
+ }
+ return 0;
+}
+
+#ifdef CONFIG_ACPI_APEI
static void __iomem *ghes_map(u64 pfn, enum fixed_addresses fixmap_idx)
{
phys_addr_t paddr;
@@ -284,6 +786,7 @@ void ghes_clear_estatus(struct ghes *ghes,
if (is_hest_type_generic_v2(ghes))
ghes_ack_error(ghes->generic_v2);
}
+#endif /* CONFIG_ACPI_APEI */
static BLOCKING_NOTIFIER_HEAD(vendor_record_notify_list);
diff --git a/include/acpi/ghes_cper.h b/include/acpi/ghes_cper.h
index 5821eca46d63..eb07ec98cc94 100644
--- a/include/acpi/ghes_cper.h
+++ b/include/acpi/ghes_cper.h
@@ -16,6 +16,8 @@
#ifndef ACPI_APEI_GHES_CPER_H
#define ACPI_APEI_GHES_CPER_H
+#include <linux/device.h>
+#include <linux/notifier.h>
#include <linux/workqueue.h>
#include <acpi/ghes.h>
@@ -57,6 +59,7 @@
((struct ghes_vendor_record_entry *)(vendor_entry) + 1))
extern struct gen_pool *ghes_estatus_pool;
+extern struct atomic_notifier_head ghes_report_chain;
static inline bool is_hest_type_generic_v2(struct ghes *ghes)
{
@@ -107,6 +110,23 @@ void ghes_estatus_cache_add(struct acpi_hest_generic *generic,
struct acpi_hest_generic_status *estatus);
void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
int sev);
+int ghes_severity(int severity);
+bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata,
+ int sev, bool sync);
+bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
+ int sev, bool sync);
+void ghes_handle_aer(struct acpi_hest_generic_data *gdata);
+void ghes_log_hwerr(int sev, guid_t *sec_type);
+void __ghes_print_estatus(const char *pfx,
+ const struct acpi_hest_generic *generic,
+ const struct acpi_hest_generic_status *estatus);
+int ghes_print_estatus(const char *pfx,
+ const struct acpi_hest_generic *generic,
+ const struct acpi_hest_generic_status *estatus);
+void ghes_cper_handle_status(struct device *dev,
+ const struct acpi_hest_generic *generic,
+ const struct acpi_hest_generic_status *estatus,
+ bool sync);
void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
int severity, u32 len);
void cxl_cper_register_prot_err_work(struct work_struct *work);
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 21/22] dt-bindings: firmware: add arm,ras-cper
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (19 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 20/22] ACPI: APEI: share GHES CPER helpers Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 22/22] RAS: add firmware-first CPER provider Ahmed Tiba
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain
Describe the DeviceTree node that exposes the Arm firmware-first CPER
provider and hook the file into MAINTAINERS so the binding has an
owner.
The initial user is the upstream zena-css platform, validated so far
on FVP.
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
.../devicetree/bindings/firmware/arm,ras-cper.yaml | 52 ++++++++++++++++++++++
MAINTAINERS | 5 +++
2 files changed, 57 insertions(+)
diff --git a/Documentation/devicetree/bindings/firmware/arm,ras-cper.yaml b/Documentation/devicetree/bindings/firmware/arm,ras-cper.yaml
new file mode 100644
index 000000000000..23d54008230d
--- /dev/null
+++ b/Documentation/devicetree/bindings/firmware/arm,ras-cper.yaml
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/firmware/arm,ras-cper.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Arm RAS CPER provider
+
+maintainers:
+ - Ahmed Tiba <ahmed.tiba@arm.com>
+
+description:
+ Arm Reliability, Availability and Serviceability (RAS) firmware can expose
+ a firmware-first CPER error source directly via DeviceTree. Firmware
+ provides the CPER Generic Error Status block and notifies the OS through
+ an interrupt.
+
+properties:
+ compatible:
+ const: arm,ras-cper
+
+ memory-region:
+ items:
+ - description:
+ CPER Generic Error Status block exposed by firmware.
+ - description:
+ Firmware-owned ack buffer. Firmware watches bit 0 and expects the
+ OS to set it once the current status block has been consumed
+ before the CPER buffer is overwritten.
+
+ interrupts:
+ maxItems: 1
+ description:
+ Interrupt used to signal that a new status record is ready.
+
+required:
+ - compatible
+ - memory-region
+ - interrupts
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+ error-handler {
+ compatible = "arm,ras-cper";
+ memory-region = <&ras_cper_buffer>, <&ras_cper_ack>;
+ interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
+ };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 84cb98ef4c49..8be23ad6d2c0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -23401,6 +23401,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: Documentation/devicetree/bindings/firmware/arm,ras-cper.yaml
+
RAS INFRASTRUCTURE
M: Tony Luck <tony.luck@intel.com>
M: Borislav Petkov <bp@alien8.de>
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v8 22/22] RAS: add firmware-first CPER provider
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
` (20 preceding siblings ...)
2026-12-03 13:40 ` [PATCH v8 21/22] dt-bindings: firmware: add arm,ras-cper Ahmed Tiba
@ 2026-12-03 13:40 ` Ahmed Tiba
21 siblings, 0 replies; 30+ messages in thread
From: Ahmed Tiba @ 2026-12-03 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
Mauro Carvalho Chehab, Shuai Xue, Len Brown, Saket Dumbre,
Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Dan Williams, Ira Weiny, Li Ming,
Mahesh J Salgaonkar, Oliver O'Halloran, Bjorn Helgaas,
Ahmed Tiba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Jonathan Corbet, Shuah Khan
Cc: linux-kernel, linux-acpi, acpica-devel, linux-cxl, linuxppc-dev,
linux-pci, devicetree, linux-edac, linux-doc, pawel.chmielewski,
rdunlap, justin.he, David.Hu2, Michael.Zhao2, icheng,
Dmitry.Lamerov, maciej.wieczor-retman, sourabhjain
Add a firmware-first CPER provider that reuses the shared
GHES helpers, wire it into the RAS Kconfig/Makefile and
document it in the admin guide.
Update MAINTAINERS now that the driver exists.
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
Documentation/admin-guide/RAS/main.rst | 15 ++
MAINTAINERS | 1 +
drivers/Makefile | 1 +
drivers/acpi/Kconfig | 5 +
drivers/acpi/acpi_extlog.c | 7 +-
drivers/acpi/apei/Kconfig | 1 +
drivers/acpi/apei/Makefile | 1 -
drivers/acpi/apei/ghes.c | 9 +-
drivers/acpi/apei/ghes_cper.c | 46 +++--
drivers/pci/pcie/aer.c | 4 +-
drivers/ras/Kconfig | 13 ++
drivers/ras/Makefile | 1 +
drivers/ras/cper-esource.c | 356 +++++++++++++++++++++++++++++++++
include/acpi/ghes_cper.h | 23 ++-
include/cxl/event.h | 2 +-
15 files changed, 456 insertions(+), 29 deletions(-)
diff --git a/Documentation/admin-guide/RAS/main.rst b/Documentation/admin-guide/RAS/main.rst
index c1040e5a5b35..b75c27f1e3c1 100644
--- a/Documentation/admin-guide/RAS/main.rst
+++ b/Documentation/admin-guide/RAS/main.rst
@@ -205,6 +205,21 @@ Architecture (MCA)\ [#f3]_.
.. [#f3] For more details about the Machine Check Architecture (MCA),
please read Documentation/arch/x86/x86_64/machinecheck.rst at the Kernel tree.
+Firmware-first CPER providers
+-----------------------------
+
+Some systems expose Common Platform Error Record (CPER) data through
+platform firmware, with the error source described in DeviceTree.
+Enable ``CONFIG_RAS_CPER_ESOURCE`` to support those providers. The
+current in-tree binding is
+``Documentation/devicetree/bindings/firmware/arm,ras-cper.yaml``.
+
+The DeviceTree node describes the firmware-owned status buffer and ack
+buffer used to exchange CPER data with the OS. The driver reuses the
+shared GHES CPER handling helpers, so parsing, logging, notifier
+delivery, and memory failure handling follow the same paths as ACPI
+GHES whether the error source is described by ACPI or DeviceTree.
+
EDAC - Error Detection And Correction
*************************************
diff --git a/MAINTAINERS b/MAINTAINERS
index 8be23ad6d2c0..7426c0406ace 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -23405,6 +23405,7 @@ RAS ERROR STATUS
M: Ahmed Tiba <ahmed.tiba@arm.com>
S: Maintained
F: Documentation/devicetree/bindings/firmware/arm,ras-cper.yaml
+F: drivers/ras/cper-esource.c
RAS INFRASTRUCTURE
M: Tony Luck <tony.luck@intel.com>
diff --git a/drivers/Makefile b/drivers/Makefile
index 27a664cb45ea..1a62b5aa718c 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -32,6 +32,7 @@ obj-y += char/ipmi/
obj-$(CONFIG_ACPI) += acpi/
obj-$(CONFIG_GHES_CPER_HELPERS) += acpi/apei/ghes_cper.o
+obj-$(CONFIG_GHES_CPER_PCIEAER_HELPERS) += acpi/apei/ghes_helpers.o
# PnP must come after ACPI since it will eventually need to check if acpi
# was used and do nothing if so
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 3cec674cf788..1687b819bdff 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -8,8 +8,13 @@ config ARCH_SUPPORTS_ACPI
config GHES_CPER_HELPERS
bool
+ select GENERIC_ALLOCATOR
select UEFI_CPER
+config GHES_CPER_PCIEAER_HELPERS
+ bool
+ depends on PCIEAER
+
menuconfig ACPI
bool "ACPI (Advanced Configuration and Power Interface) Support"
depends on ARCH_SUPPORTS_ACPI
diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index bf5f7b1a9aea..27c32f7b1f08 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -235,9 +235,10 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
struct cxl_cper_sec_prot_err *prot_err =
acpi_hest_get_payload(gdata);
- cxl_cper_post_prot_err(prot_err,
- gdata->error_severity,
- gdata->error_data_length);
+ if (IS_ENABLED(CONFIG_ACPI_APEI_PCIEAER))
+ cxl_cper_post_prot_err(prot_err,
+ gdata->error_severity,
+ gdata->error_data_length);
} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
diff --git a/drivers/acpi/apei/Kconfig b/drivers/acpi/apei/Kconfig
index ddb62638eb02..3a858b10f14c 100644
--- a/drivers/acpi/apei/Kconfig
+++ b/drivers/acpi/apei/Kconfig
@@ -38,6 +38,7 @@ config ACPI_APEI_GHES
config ACPI_APEI_PCIEAER
bool "APEI PCIe AER logging/recovering support"
depends on ACPI_APEI && PCIEAER
+ select GHES_CPER_PCIEAER_HELPERS
help
PCIe AER errors may be reported via APEI firmware first mode.
Turn on this option to enable the corresponding support.
diff --git a/drivers/acpi/apei/Makefile b/drivers/acpi/apei/Makefile
index 66588d6be56f..378863dfec77 100644
--- a/drivers/acpi/apei/Makefile
+++ b/drivers/acpi/apei/Makefile
@@ -5,7 +5,6 @@ obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o
ifeq ($(CONFIG_COMPILE_TEST)_$(CONFIG_CC_IS_CLANG)_$(call clang-min-version, 180000),y_y_)
KASAN_SANITIZE_ghes.o := n
endif
-obj-$(CONFIG_ACPI_APEI_PCIEAER) += ghes_helpers.o
obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o
einj-y := einj-core.o
einj-$(CONFIG_ACPI_APEI_EINJ_CXL) += einj-cxl.o
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 3a3a864ac5f6..6833edd819de 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -114,8 +114,15 @@ static DEFINE_SPINLOCK(ghes_notify_lock_irq);
static void ghes_do_proc(struct ghes *ghes,
const struct acpi_hest_generic_status *estatus)
{
+ unsigned int recovery = 0;
+
+ if (IS_ENABLED(CONFIG_ACPI_APEI_MEMORY_FAILURE))
+ recovery |= GHES_CPER_RECOVER_MEMORY;
+ if (IS_ENABLED(CONFIG_ACPI_APEI_PCIEAER))
+ recovery |= GHES_CPER_RECOVER_PCIE;
+
ghes_cper_handle_status(ghes->dev, ghes->generic,
- estatus, is_hest_sync_notify(ghes));
+ estatus, is_hest_sync_notify(ghes), recovery);
}
static void __ghes_panic(struct ghes *ghes,
diff --git a/drivers/acpi/apei/ghes_cper.c b/drivers/acpi/apei/ghes_cper.c
index bceac27ac274..330150f43f5e 100644
--- a/drivers/acpi/apei/ghes_cper.c
+++ b/drivers/acpi/apei/ghes_cper.c
@@ -42,8 +42,10 @@
#include <acpi/acpi_io.h>
#include <acpi/ghes_cper.h>
+#ifdef CONFIG_ACPI_APEI
#include <asm/fixmap.h>
#include <asm/tlbflush.h>
+#endif
#include "apei-internal.h"
@@ -169,12 +171,12 @@ static void memory_failure_cb(struct callback_head *twork)
gen_pool_free(ghes_estatus_pool, (unsigned long)twcb, sizeof(*twcb));
}
-static bool ghes_do_memory_failure(u64 physical_addr, int flags)
+static bool ghes_do_memory_failure(u64 physical_addr, int flags, bool recover)
{
struct ghes_task_work *twcb;
unsigned long pfn;
- if (!IS_ENABLED(CONFIG_ACPI_APEI_MEMORY_FAILURE))
+ if (!IS_ENABLED(CONFIG_MEMORY_FAILURE) || !recover)
return false;
pfn = PHYS_PFN(physical_addr);
@@ -196,7 +198,7 @@ static bool ghes_do_memory_failure(u64 physical_addr, int flags)
}
bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata,
- int sev, bool sync)
+ int sev, bool sync, bool recover)
{
int flags = -1;
int sec_sev = ghes_severity(gdata->error_severity);
@@ -213,13 +215,14 @@ bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata,
flags = sync ? MF_ACTION_REQUIRED : 0;
if (flags != -1)
- return ghes_do_memory_failure(mem_err->physical_addr, flags);
+ return ghes_do_memory_failure(mem_err->physical_addr, flags,
+ recover);
return false;
}
bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
- int sev, bool sync)
+ int sev, bool sync, bool recover)
{
struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata);
int flags = sync ? MF_ACTION_REQUIRED : 0;
@@ -270,7 +273,8 @@ bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
* and don't filter out 'corrected' error here.
*/
if (is_cache && has_pa) {
- queued |= ghes_do_memory_failure(err_info->physical_fault_addr, flags);
+ queued |= ghes_do_memory_failure(err_info->physical_fault_addr,
+ flags, recover);
p += err_info->length;
continue;
}
@@ -304,11 +308,14 @@ bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
* GHES_SEV_PANIC does not make it to this handling since the kernel must
* panic.
*/
-void ghes_handle_aer(struct acpi_hest_generic_data *gdata)
+void ghes_handle_aer(struct acpi_hest_generic_data *gdata, bool recover)
{
-#ifdef CONFIG_ACPI_APEI_PCIEAER
+#ifdef CONFIG_GHES_CPER_PCIEAER_HELPERS
struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
+ if (!recover)
+ return;
+
if (gdata->error_data_length < sizeof(*pcie_err))
return;
@@ -403,7 +410,7 @@ static u32 ghes_mem_err_min_len(u64 validation_bits)
void ghes_cper_handle_status(struct device *dev,
const struct acpi_hest_generic *generic,
const struct acpi_hest_generic_status *estatus,
- bool sync)
+ bool sync, unsigned int recovery)
{
int sev, sec_sev;
struct acpi_hest_generic_data *gdata;
@@ -451,16 +458,23 @@ void ghes_cper_handle_status(struct device *dev,
atomic_notifier_call_chain(&ghes_report_chain, sev, mem_err);
arch_apei_report_mem_error(sev, mem_err);
- queued |= ghes_handle_memory_failure(gdata, sev, sync);
+ queued |= ghes_handle_memory_failure(gdata, sev, sync,
+ recovery & GHES_CPER_RECOVER_MEMORY);
} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
- ghes_handle_aer(gdata);
+ ghes_handle_aer(gdata,
+ recovery & GHES_CPER_RECOVER_PCIE);
} else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) {
- queued |= ghes_handle_arm_hw_error(gdata, sev, sync);
+ queued |= ghes_handle_arm_hw_error(gdata, sev, sync,
+ recovery & GHES_CPER_RECOVER_MEMORY);
} else if (guid_equal(sec_type, &CPER_SEC_CXL_PROT_ERR)) {
- struct cxl_cper_sec_prot_err *prot_err = acpi_hest_get_payload(gdata);
+ if (recovery & GHES_CPER_RECOVER_PCIE) {
+ struct cxl_cper_sec_prot_err *prot_err;
- cxl_cper_post_prot_err(prot_err, gdata->error_severity,
- gdata->error_data_length);
+ prot_err = acpi_hest_get_payload(gdata);
+ cxl_cper_post_prot_err(prot_err,
+ gdata->error_severity,
+ gdata->error_data_length);
+ }
} else if (guid_equal(sec_type, &CPER_SEC_CXL_GEN_MEDIA_GUID)) {
struct cxl_cper_event_rec *rec = acpi_hest_get_payload(gdata);
@@ -868,7 +882,7 @@ struct work_struct *cxl_cper_prot_err_work;
void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
int severity, u32 len)
{
-#ifdef CONFIG_ACPI_APEI_PCIEAER
+#ifdef CONFIG_GHES_CPER_PCIEAER_HELPERS
struct cxl_cper_prot_err_work_data wd;
if (cxl_cper_sec_prot_err_valid(prot_err, len))
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 8708ca3257bb..ee41fd43e5fc 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -1014,7 +1014,7 @@ void aer_print_error(struct aer_err_info *info, int i)
}
}
-#ifdef CONFIG_ACPI_APEI_PCIEAER
+#ifdef CONFIG_GHES_CPER_PCIEAER_HELPERS
int cper_severity_to_aer(int cper_severity)
{
switch (cper_severity) {
@@ -1343,7 +1343,7 @@ static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)
pci_aer_handle_error(dev, info);
}
-#ifdef CONFIG_ACPI_APEI_PCIEAER
+#ifdef CONFIG_GHES_CPER_PCIEAER_HELPERS
#define AER_RECOVER_RING_SIZE 16
diff --git a/drivers/ras/Kconfig b/drivers/ras/Kconfig
index 070e17639faa..f416b71ea80a 100644
--- a/drivers/ras/Kconfig
+++ b/drivers/ras/Kconfig
@@ -56,6 +56,19 @@ config RAS_CEC_DEBUG
source "drivers/ras/amd/atl/Kconfig"
+config RAS_CPER_ESOURCE
+ bool "Firmware-first CPER error source block provider"
+ select GHES_CPER_HELPERS
+ select GHES_CPER_PCIEAER_HELPERS if PCIEAER
+ depends on OF_RESERVED_MEM && !CPU_BIG_ENDIAN
+ help
+ Enable support for firmware-first Common Platform Error Record
+ (CPER) error source block providers. The current in-tree user is
+ described by the arm,ras-cper DeviceTree binding. The driver
+ reuses the existing GHES CPER helpers so the error processing
+ matches the ACPI code paths, but it can be built even when ACPI is
+ disabled.
+
config RAS_FMPM
tristate "FRU Memory Poison Manager"
default m
diff --git a/drivers/ras/Makefile b/drivers/ras/Makefile
index 11f95d59d397..0de069557f31 100644
--- a/drivers/ras/Makefile
+++ b/drivers/ras/Makefile
@@ -2,6 +2,7 @@
obj-$(CONFIG_RAS) += ras.o
obj-$(CONFIG_DEBUG_FS) += debugfs.o
obj-$(CONFIG_RAS_CEC) += cec.o
+obj-$(CONFIG_RAS_CPER_ESOURCE) += cper-esource.o
obj-$(CONFIG_RAS_FMPM) += amd/fmpm.o
obj-y += amd/atl/
diff --git a/drivers/ras/cper-esource.c b/drivers/ras/cper-esource.c
new file mode 100644
index 000000000000..221b5f97e335
--- /dev/null
+++ b/drivers/ras/cper-esource.c
@@ -0,0 +1,356 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Firmware-first CPER error source provider.
+ *
+ * This driver shares the GHES CPER helpers so we keep the reporting and
+ * notifier behaviour identical to ACPI GHES.
+ *
+ * Copyright (C) 2026 ARM Ltd.
+ * Author: Ahmed Tiba <ahmed.tiba@arm.com>
+ */
+
+#include <linux/bitops.h>
+#include <linux/cper.h>
+#include <linux/device-id/of.h>
+#include <linux/idr.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/of_address.h>
+#include <linux/of_reserved_mem.h>
+#include <linux/panic.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include <acpi/ghes.h>
+#include <acpi/ghes_cper.h>
+
+static DEFINE_IDA(cper_esource_source_ids);
+static DEFINE_MUTEX(cper_esource_pool_lock);
+static bool cper_esource_pool_ready;
+
+struct cper_esource_ack {
+ void __iomem *addr;
+ bool present;
+};
+
+struct cper_esource {
+ struct device *dev;
+ void __iomem *status;
+ size_t status_len;
+
+ struct cper_esource_ack ack;
+
+ struct acpi_hest_generic generic;
+ struct acpi_hest_generic_status *estatus;
+
+ int irq;
+};
+
+static void __iomem *cper_esource_map_region(struct device *dev,
+ unsigned int index, size_t *size,
+ resource_size_t *start)
+{
+ resource_size_t resource_len;
+ struct resource res;
+ void __iomem *addr;
+
+ if (of_reserved_mem_region_to_resource(dev->of_node, index, &res))
+ return ERR_PTR(dev_err_probe(dev, -EINVAL,
+ "unable to resolve memory-region %u\n",
+ index));
+
+ resource_len = resource_size(&res);
+ if (!resource_len)
+ return ERR_PTR(dev_err_probe(dev, -EINVAL,
+ "memory-region %u has zero length\n",
+ index));
+ if (resource_len > SIZE_MAX)
+ return ERR_PTR(dev_err_probe(dev, -EOVERFLOW,
+ "memory-region %u is too large\n",
+ index));
+
+ *size = resource_len;
+ if (start)
+ *start = res.start;
+
+ addr = devm_ioremap(dev, res.start, *size);
+ if (!addr)
+ return ERR_PTR(dev_err_probe(dev, -ENOMEM,
+ "failed to map memory-region %u\n",
+ index));
+
+ return addr;
+}
+
+static void cper_esource_release_source_id(void *data)
+{
+ struct cper_esource *ctx = data;
+
+ ida_free(&cper_esource_source_ids, ctx->generic.header.source_id);
+}
+
+static int cper_esource_init_pool(void)
+{
+ struct device_node *np;
+ unsigned int count = 0;
+ int rc = 0;
+
+ mutex_lock(&cper_esource_pool_lock);
+ if (cper_esource_pool_ready)
+ goto out_unlock;
+
+ for_each_compatible_node(np, NULL, "arm,ras-cper")
+ if (of_device_is_available(np))
+ count++;
+
+ rc = ghes_estatus_pool_init(count ?: 1);
+ if (!rc)
+ cper_esource_pool_ready = true;
+
+out_unlock:
+ mutex_unlock(&cper_esource_pool_lock);
+ return rc;
+}
+
+static size_t cper_esource_estatus_len(struct acpi_hest_generic_status *estatus)
+{
+ if (estatus->raw_data_length)
+ return (size_t)estatus->raw_data_offset +
+ (size_t)estatus->raw_data_length;
+ else
+ return sizeof(*estatus) + (size_t)estatus->data_length;
+}
+
+static int cper_esource_get_estatus_len(struct cper_esource *ctx, size_t *len)
+{
+ if (!ctx->estatus->block_status)
+ return -ENOENT;
+
+ if (ctx->estatus->data_length >
+ ctx->status_len - sizeof(*ctx->estatus))
+ return -EINVAL;
+
+ if (cper_estatus_check_header(ctx->estatus))
+ return -EINVAL;
+
+ if (ctx->estatus->raw_data_length &&
+ (ctx->estatus->raw_data_offset > ctx->status_len ||
+ ctx->estatus->raw_data_length >
+ ctx->status_len - ctx->estatus->raw_data_offset))
+ return -EINVAL;
+
+ *len = cper_esource_estatus_len(ctx->estatus);
+ if (*len < sizeof(*ctx->estatus) || *len > ctx->status_len)
+ return -EINVAL;
+
+ return 0;
+}
+
+static void cper_esource_ack(struct cper_esource *ctx)
+{
+ u32 val;
+
+ if (!ctx->ack.present)
+ return;
+
+ val = readl(ctx->ack.addr);
+ writel(val | BIT(0), ctx->ack.addr);
+}
+
+static void cper_esource_clear_status(struct cper_esource *ctx)
+{
+ ctx->estatus->block_status = 0;
+ writel(0, ctx->status);
+}
+
+static void cper_esource_fatal(struct cper_esource *ctx)
+{
+ __ghes_print_estatus(KERN_EMERG, &ctx->generic, ctx->estatus);
+ add_taint(TAINT_MACHINE_CHECK, LOCKDEP_STILL_OK);
+ cper_esource_clear_status(ctx);
+ cper_esource_ack(ctx);
+ panic("GHES: fatal firmware-first CPER record from %s\n",
+ dev_name(ctx->dev));
+}
+
+static irqreturn_t cper_esource_process(struct cper_esource *ctx)
+{
+ unsigned int recovery = 0;
+ size_t estatus_len, snapshot_len;
+ int rc;
+ int sev;
+
+ if (!readl(ctx->status))
+ return IRQ_NONE;
+
+ memcpy_fromio(ctx->estatus, ctx->status, sizeof(*ctx->estatus));
+
+ rc = cper_esource_get_estatus_len(ctx, &estatus_len);
+ if (rc == -ENOENT)
+ return IRQ_NONE;
+ if (rc)
+ goto invalid;
+
+ memcpy_fromio(ctx->estatus, ctx->status, estatus_len);
+ rc = cper_esource_get_estatus_len(ctx, &snapshot_len);
+ if (rc || snapshot_len != estatus_len)
+ goto invalid;
+ if (cper_estatus_check(ctx->estatus))
+ goto invalid;
+
+ sev = ghes_severity(ctx->estatus->error_severity);
+ if (sev >= GHES_SEV_PANIC)
+ cper_esource_fatal(ctx);
+
+ if (!ghes_estatus_cached(ctx->estatus) &&
+ ghes_print_estatus(NULL, &ctx->generic, ctx->estatus))
+ ghes_estatus_cache_add(&ctx->generic, ctx->estatus);
+
+ if (IS_ENABLED(CONFIG_MEMORY_FAILURE))
+ recovery |= GHES_CPER_RECOVER_MEMORY;
+ if (IS_ENABLED(CONFIG_PCIEAER))
+ recovery |= GHES_CPER_RECOVER_PCIE;
+
+ ghes_cper_handle_status(ctx->dev, &ctx->generic, ctx->estatus, false,
+ recovery);
+ cper_esource_clear_status(ctx);
+ cper_esource_ack(ctx);
+
+ return IRQ_HANDLED;
+
+invalid:
+ dev_warn_ratelimited(ctx->dev, FW_WARN GHES_PFX
+ "Invalid error status block\n");
+ cper_esource_clear_status(ctx);
+ cper_esource_ack(ctx);
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t cper_esource_irq(int irq, void *data)
+{
+ struct cper_esource *ctx = data;
+
+ return cper_esource_process(ctx);
+}
+
+static int cper_esource_init_ack(struct cper_esource *ctx)
+{
+ struct device *dev = ctx->dev;
+ resource_size_t start;
+ size_t size;
+
+ ctx->ack.addr = cper_esource_map_region(dev, 1, &size, &start);
+ if (IS_ERR(ctx->ack.addr))
+ return PTR_ERR(ctx->ack.addr);
+
+ if (size < sizeof(u32))
+ return dev_err_probe(dev, -EINVAL,
+ "ack resource is smaller than 4 bytes\n");
+ if (!IS_ALIGNED(start, sizeof(u32)))
+ return dev_err_probe(dev, -EINVAL,
+ "ack resource is not naturally aligned\n");
+
+ ctx->ack.present = true;
+ return 0;
+}
+
+static int cper_esource_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct cper_esource *ctx;
+ resource_size_t status_start;
+ size_t size;
+ int source_id;
+ int rc;
+
+ ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
+ if (!ctx)
+ return -ENOMEM;
+
+ ctx->dev = dev;
+
+ ctx->status = cper_esource_map_region(dev, 0, &size, &status_start);
+ if (IS_ERR(ctx->status))
+ return PTR_ERR(ctx->status);
+
+ if (!IS_ALIGNED(status_start, sizeof(ctx->estatus->block_status)))
+ return dev_err_probe(dev, -EINVAL,
+ "status resource is not naturally aligned\n");
+
+ ctx->status_len = min_t(size_t, size, GHES_ESTATUS_MAX_SIZE);
+ if (size > ctx->status_len)
+ dev_warn(dev, "using the first %zu bytes of the status region\n",
+ ctx->status_len);
+ if (ctx->status_len < sizeof(*ctx->estatus))
+ return dev_err_probe(dev, -EINVAL,
+ "status region is smaller than a CPER header\n");
+
+ rc = cper_esource_init_ack(ctx);
+ if (rc)
+ return rc;
+
+ rc = cper_esource_init_pool();
+ if (rc)
+ return rc;
+
+ ctx->estatus = devm_kzalloc(dev, ctx->status_len, GFP_KERNEL);
+ if (!ctx->estatus)
+ return -ENOMEM;
+
+ /* Keep source_id 0 unused so a zeroed header is never treated as valid. */
+ source_id = ida_alloc_min(&cper_esource_source_ids, 1, GFP_KERNEL);
+ if (source_id < 0)
+ return source_id;
+ if (source_id > U16_MAX) {
+ ida_free(&cper_esource_source_ids, source_id);
+ return -ENOSPC;
+ }
+
+ ctx->generic.header.type = ACPI_HEST_TYPE_GENERIC_ERROR;
+ ctx->generic.header.source_id = source_id;
+
+ rc = devm_add_action_or_reset(dev, cper_esource_release_source_id,
+ ctx);
+ if (rc)
+ return rc;
+
+ ctx->generic.notify.type = ACPI_HEST_NOTIFY_EXTERNAL;
+ ctx->generic.error_block_length = ctx->status_len;
+
+ ctx->irq = platform_get_irq(pdev, 0);
+ if (ctx->irq < 0)
+ return ctx->irq;
+
+ rc = devm_request_irq(dev, ctx->irq, cper_esource_irq, 0,
+ dev_name(dev), ctx);
+ if (rc)
+ return dev_err_probe(dev, rc, "failed to request interrupt\n");
+
+ disable_irq(ctx->irq);
+ cper_esource_process(ctx);
+ enable_irq(ctx->irq);
+
+ return 0;
+}
+
+static const struct of_device_id cper_esource_of_match[] = {
+ { .compatible = "arm,ras-cper" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cper_esource_of_match);
+
+static struct platform_driver cper_esource_driver = {
+ .driver = {
+ .name = "cper-esource",
+ .of_match_table = cper_esource_of_match,
+ },
+ .probe = cper_esource_probe,
+};
+
+module_platform_driver(cper_esource_driver);
+
+MODULE_AUTHOR("Ahmed Tiba <ahmed.tiba@arm.com>");
+MODULE_DESCRIPTION("Firmware-first CPER provider");
+MODULE_LICENSE("GPL");
diff --git a/include/acpi/ghes_cper.h b/include/acpi/ghes_cper.h
index eb07ec98cc94..8183652257a4 100644
--- a/include/acpi/ghes_cper.h
+++ b/include/acpi/ghes_cper.h
@@ -16,14 +16,18 @@
#ifndef ACPI_APEI_GHES_CPER_H
#define ACPI_APEI_GHES_CPER_H
+#include <linux/bits.h>
#include <linux/device.h>
#include <linux/notifier.h>
#include <linux/workqueue.h>
#include <acpi/ghes.h>
-#include <asm/fixmap.h>
#include <cxl/event.h>
+#ifdef CONFIG_ACPI_APEI
+#include <asm/fixmap.h>
+#endif
+
#define GHES_PFX "GHES: "
#define GHES_ESTATUS_MAX_SIZE 65536
@@ -40,6 +44,11 @@
/* Prevent too many caches are allocated because of RCU */
#define GHES_ESTATUS_CACHE_ALLOCED_MAX (GHES_ESTATUS_CACHES_SIZE * 3 / 2)
+enum ghes_cper_recovery {
+ GHES_CPER_RECOVER_MEMORY = BIT(0),
+ GHES_CPER_RECOVER_PCIE = BIT(1),
+};
+
#define GHES_ESTATUS_CACHE_LEN(estatus_len) \
(sizeof(struct ghes_estatus_cache) + (estatus_len))
#define GHES_ESTATUS_FROM_CACHE(estatus_cache) \
@@ -108,14 +117,18 @@ void ghes_clear_estatus(struct ghes *ghes,
int ghes_estatus_cached(struct acpi_hest_generic_status *estatus);
void ghes_estatus_cache_add(struct acpi_hest_generic *generic,
struct acpi_hest_generic_status *estatus);
+int ghes_register_vendor_record_notifier(struct notifier_block *nb);
+void ghes_unregister_vendor_record_notifier(struct notifier_block *nb);
+int devm_ghes_register_vendor_record_notifier(struct device *dev,
+ struct notifier_block *nb);
void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
int sev);
int ghes_severity(int severity);
bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata,
- int sev, bool sync);
+ int sev, bool sync, bool recover);
bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
- int sev, bool sync);
-void ghes_handle_aer(struct acpi_hest_generic_data *gdata);
+ int sev, bool sync, bool recover);
+void ghes_handle_aer(struct acpi_hest_generic_data *gdata, bool recover);
void ghes_log_hwerr(int sev, guid_t *sec_type);
void __ghes_print_estatus(const char *pfx,
const struct acpi_hest_generic *generic,
@@ -126,7 +139,7 @@ int ghes_print_estatus(const char *pfx,
void ghes_cper_handle_status(struct device *dev,
const struct acpi_hest_generic *generic,
const struct acpi_hest_generic_status *estatus,
- bool sync);
+ bool sync, unsigned int recovery);
void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
int severity, u32 len);
void cxl_cper_register_prot_err_work(struct work_struct *work);
diff --git a/include/cxl/event.h b/include/cxl/event.h
index 91fb76d052b5..75d5e3013901 100644
--- a/include/cxl/event.h
+++ b/include/cxl/event.h
@@ -311,7 +311,7 @@ static inline int cxl_cper_prot_err_kfifo_get(struct cxl_cper_prot_err_work_data
}
#endif
-#ifdef CONFIG_ACPI_APEI_PCIEAER
+#ifdef CONFIG_GHES_CPER_PCIEAER_HELPERS
int cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err, u32 len);
int cxl_cper_setup_prot_err_work_data(struct cxl_cper_prot_err_work_data *wd,
struct cxl_cper_sec_prot_err *prot_err,
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH v8 12/22] efi/cper: validate the remaining length before reading a section
2026-12-03 13:40 ` [PATCH v8 12/22] efi/cper: validate the remaining length before reading a section Ahmed Tiba
@ 2026-12-03 13:52 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-12-03 13:52 UTC (permalink / raw)
To: Ahmed Tiba; +Cc: linux-cxl, linux-pci, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] efi/cper: Fixes trailer cites c4335fdd3822 instead of
1be72c8e0786
--
commit 6ca8a7519e24ea7df3b9fa23e96fe2862cd9f070
Author: Ahmed Tiba <ahmed.tiba@arm.com>
> efi/cper: validate the remaining length before reading a section
>
> cper_estatus_check() enters the section loop whenever any data remains.
> When a malformed status block leaves fewer than sizeof(*gdata) trailing
> bytes, acpi_hest_get_size() reads gdata->revision beyond the valid buffer
> before the existing record-size check can reject it.
>
> Require a complete generic data header before dereferencing the section.
>
> Fixes: c4335fdd3822 ("ACPI: APEI: fix the wrong iteration of generic error status block")
> Reported-by: sashiko-bot@kernel.org
> Link: https://sashiko.dev/#/message/20260708143557.91D601F000E9%40smtp.kernel.org
> Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
[Severity: Low]
Should the Fixes tag cite 1be72c8e0786 ("efi: cper: check section header
more appropriately") instead of c4335fdd3822 ("ACPI: APEI: fix the wrong
iteration of generic error status block")?
The earlier out-of-bounds read was fixed by 45b14a4ffcc1 ("efi: cper: Fix
possible out-of-bounds access"), which checked that sizeof(*gdata) bytes
remained before dereferencing gdata. The unguarded
acpi_hest_get_size(gdata) read was then reintroduced in 2021.
Citing the 2017 commit can cause stable backporting to target trees that
already have the earlier guard.
Fixes: 1be72c8e0786 ("efi: cper: check section header more appropriately")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-topics-ahmtib01-ras_ffh_arm_internal_review-v8-0-157aac88560b@arm.com?part=12
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v8 07/22] ACPI: APEI: GHES: free an estatus cache entry when no slot is found
2026-12-03 13:40 ` [PATCH v8 07/22] ACPI: APEI: GHES: free an estatus cache entry when no slot is found Ahmed Tiba
@ 2026-12-03 13:53 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-12-03 13:53 UTC (permalink / raw)
To: Ahmed Tiba; +Cc: linux-cxl, linux-pci, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ACPI: APEI: GHES: missing Fixes trailer for
ghes_estatus_cache_add() leak
--
commit 78b96b37def9b63b1e236f00b86d334b82efda8d
Author: Ahmed Tiba <ahmed.tiba@arm.com>
> ACPI: APEI: GHES: free an estatus cache entry when no slot is found
>
> ghes_estatus_cache_add() allocates a new cache entry before looking for a
> slot. If every populated slot has a zero average period, the selection loop
> can leave slot at -1. The unpublished entry and its allocation counter are
> then leaked.
>
> Return the entry to ghes_estatus_pool and balance the allocation counter
> when no slot is selected.
>
> Reported-by: sashiko-bot@kernel.org
> Link: https://sashiko.dev/#/message/20260617141000.8392A1F000E9%40smtp.kernel.org
> Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
[Severity: Low]
This fixes a leak introduced when the else branch freeing new_cache was
dropped while replacing cmpxchg() with xchg_release(). Should this include:
Fixes: dd3fa54b2eee ("apei/ghes: Use xchg_release() for updating new cache slot instead of cmpxchg()")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-topics-ahmtib01-ras_ffh_arm_internal_review-v8-0-157aac88560b@arm.com?part=7
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v8 11/22] ACPI: APEI: GHES: reset FRU metadata for each CPER section
2026-12-03 13:40 ` [PATCH v8 11/22] ACPI: APEI: GHES: reset FRU metadata for each CPER section Ahmed Tiba
@ 2026-12-03 13:54 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-12-03 13:54 UTC (permalink / raw)
To: Ahmed Tiba; +Cc: linux-cxl, linux-pci, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ACPI: APEI: redundant fru_id and fru_text init in ghes_do_proc()
--
commit 0d739dca5227548b4f00f1c242222832499b47e9
Author: Ahmed Tiba <ahmed.tiba@arm.com>
ACPI: APEI: GHES: reset FRU metadata for each CPER section
This commit resets fru_id and fru_text at the start of each CPER section
iteration in ghes_do_proc() so sections without FRU validation bits do not
inherit metadata from earlier sections.
Link: https://sashiko.dev/#/message/20260708144441.6E1181F000E9%40smtp.kernel.org
> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
> index 94f539f5d676f..84a8b7ee911f4 100644
> --- a/drivers/acpi/apei/ghes.c
> +++ b/drivers/acpi/apei/ghes.c
> @@ -998,6 +998,9 @@ static void ghes_do_proc(struct ghes *ghes,
> apei_estatus_for_each_section(estatus, gdata) {
> sec_type = (guid_t *)gdata->section_type;
> sec_sev = ghes_severity(gdata->error_severity);
> + fru_id = &guid_null;
> + fru_text = "";
[Severity: Low]
Can the function-scope declarations of fru_id and fru_text in ghes_do_proc()
be moved into the loop body (or into the final else branch where
log_non_standard_event() consumes them)?
With these unconditional resets at the start of every iteration, the outer
initializers (fru_id = &guid_null and fru_text = "") are now dead and
redundant, since neither variable is read before the loop or after it.
Moving the declarations into the loop also structurally prevents FRU
metadata from leaking across sections.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-topics-ahmtib01-ras_ffh_arm_internal_review-v8-0-157aac88560b@arm.com?part=11
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v8 05/22] ACPI: APEI: GHES: apply read-acknowledge masks directly
2026-12-03 13:40 ` [PATCH v8 05/22] ACPI: APEI: GHES: apply read-acknowledge masks directly Ahmed Tiba
@ 2026-12-03 13:58 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-12-03 13:58 UTC (permalink / raw)
To: Ahmed Tiba; +Cc: linux-cxl, linux-pci, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ACPI: APEI: false apei_read()/apei_write() bit_offset claim
in commit log
- [Low] ACPI: APEI: GHES: missing Fixes trailer for ghes_ack_error() fix
--
commit af58a14d28e306fe12ab5084c99fd989085fdb05
Author: Ahmed Tiba <ahmed.tiba@arm.com>
> ACPI: APEI: GHES: apply read-acknowledge masks directly
>
> apei_read() and apei_write() operate on the value described by the Generic
> Address Structure and already account for its bit offset. Shifting the
> GHESv2 Read Ack Preserve and Write masks by that offset a second time can
> modify the wrong bits and fail to acknowledge an error source.
[Severity: Medium]
Is this description of apei_read() and apei_write() accurate?
Neither function shifts by reg->bit_offset: apei_check_gar() only checks
that bit_width + bit_offset fits within access_bit_width, and apei_read()
and apei_write() perform raw unshifted reads and writes. Callers that need
bit_offset shifting do it themselves, as in __apei_exec_read_register().
Removing the shifts in ghes_ack_error() therefore ignores
read_ack_register.bit_offset completely rather than removing a duplicate
shift. This misdocuments the apei_read()/apei_write() contract and hides
that read_ack_register.bit_offset is no longer applied.
Applying read_ack_preserve and read_ack_write directly matches ACPI
full-register mask semantics (as in pcc_chan_reg_read_modify_write()), so
the commit message could state that rationale instead.
> Apply the firmware-provided masks directly to the value returned by
> apei_read().
>
> Reported-by: sashiko-bot@kernel.org
> Link: https://sashiko.dev/#/message/20260617141511.F13231F000E9%40smtp.kernel.org
> Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
[Severity: Low]
This looks like a bug fix for ghes_ack_error(). Should this include:
Fixes: 42aa56044662 ("acpi: apei: read ack upon ghes record consumption")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-topics-ahmtib01-ras_ffh_arm_internal_review-v8-0-157aac88560b@arm.com?part=5
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v8 13/22] ACPI: APEI: GHES: share macros via a private header
2026-12-03 13:40 ` [PATCH v8 13/22] ACPI: APEI: GHES: share macros via a private header Ahmed Tiba
@ 2026-12-03 14:00 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-12-03 14:00 UTC (permalink / raw)
To: Ahmed Tiba; +Cc: linux-cxl, linux-pci, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ACPI: APEI: driver-private GHES internals exposed in global
ghes_cper.h
--
commit ca14caa454315f863bdd0d79215b5663a8745fef
Author: Ahmed Tiba <ahmed.tiba@arm.com>
ACPI: APEI: GHES: share macros via a private header
This commit moves GHES CPER helper macros, struct ghes_vendor_record_entry,
and several estatus and lifecycle helper prototypes from
drivers/acpi/apei/ghes.c into a new header include/acpi/ghes_cper.h, dropping
static visibility on those functions in ghes.c.
> diff --git a/include/acpi/ghes_cper.h b/include/acpi/ghes_cper.h
> new file mode 100644
> index 0000000000000..fca7b55ab0148
> --- /dev/null
> +++ b/include/acpi/ghes_cper.h
> @@ -0,0 +1,103 @@
[ ... ]
> +#define GHES_ESOURCE_PREALLOC_MAX_SIZE 65536
> +
> +#define GHES_ESTATUS_POOL_MIN_ALLOC_ORDER 3
> +
> +/* This is just an estimation for memory pool allocation */
> +#define GHES_ESTATUS_CACHE_AVG_SIZE 512
> +
> +#define GHES_ESTATUS_CACHES_SIZE 4
> +
> +#define GHES_ESTATUS_IN_CACHE_MAX_NSEC 10000000000ULL
> +/* Prevent too many caches are allocated because of RCU */
> +#define GHES_ESTATUS_CACHE_ALLOCED_MAX (GHES_ESTATUS_CACHES_SIZE * 3 / 2)
> +
> +#define GHES_ESTATUS_CACHE_LEN(estatus_len) \
> + (sizeof(struct ghes_estatus_cache) + (estatus_len))
> +#define GHES_ESTATUS_FROM_CACHE(estatus_cache) \
> + ((struct acpi_hest_generic_status *) \
> + ((struct ghes_estatus_cache *)(estatus_cache) + 1))
> +
> +#define GHES_ESTATUS_NODE_LEN(estatus_len) \
> + (sizeof(struct ghes_estatus_node) + (estatus_len))
> +#define GHES_ESTATUS_FROM_NODE(estatus_node) \
> + ((struct acpi_hest_generic_status *) \
> + ((struct ghes_estatus_node *)(estatus_node) + 1))
> +
> +#define GHES_VENDOR_ENTRY_LEN(gdata_len) \
> + (sizeof(struct ghes_vendor_record_entry) + (gdata_len))
> +#define GHES_GDATA_FROM_VENDOR_ENTRY(vendor_entry) \
> + ((struct acpi_hest_generic_data *) \
> + ((struct ghes_vendor_record_entry *)(vendor_entry) + 1))
> +
> +static inline bool is_hest_type_generic_v2(struct ghes *ghes)
> +{
> + return ghes->generic->header.type == ACPI_HEST_TYPE_GENERIC_ERROR_V2;
> +}
> +
> +/*
> + * A platform may describe one error source for the handling of synchronous
> + * errors (e.g. MCE or SEA), or for handling asynchronous errors (e.g. SCI
> + * or External Interrupt). On x86, the HEST notifications are always
> + * asynchronous, so only SEA on ARM is delivered as a synchronous
> + * notification.
> + */
> +static inline bool is_hest_sync_notify(struct ghes *ghes)
> +{
> + u8 notify_type = ghes->generic->notify.type;
> +
> + return notify_type == ACPI_HEST_NOTIFY_SEA;
> +}
> +
> +struct ghes_vendor_record_entry {
> + struct work_struct work;
> + int error_severity;
> + char vendor_record[];
> +};
> +
> +#ifdef CONFIG_ACPI_APEI
> +struct ghes *ghes_new(struct acpi_hest_generic *generic);
> +void ghes_fini(struct ghes *ghes);
> +
> +int __ghes_peek_estatus(struct ghes *ghes,
> + struct acpi_hest_generic_status *estatus,
> + u64 *buf_paddr, enum fixed_addresses fixmap_idx);
> +int __ghes_check_estatus(struct ghes *ghes,
> + struct acpi_hest_generic_status *estatus);
> +int __ghes_read_estatus(struct acpi_hest_generic_status *estatus,
> + u64 buf_paddr, enum fixed_addresses fixmap_idx,
> + size_t buf_len);
> +int ghes_read_estatus(struct ghes *ghes,
> + struct acpi_hest_generic_status *estatus,
> + u64 *buf_paddr, enum fixed_addresses fixmap_idx);
> +void ghes_clear_estatus(struct ghes *ghes,
> + struct acpi_hest_generic_status *estatus,
> + u64 buf_paddr, enum fixed_addresses fixmap_idx);
> +#endif
[Severity: Low]
Should these driver-private declarations live in the global
include/acpi/ghes_cper.h header?
While drivers/ras/cper-esource.c (added in commit "RAS: add firmware-first
CPER provider") needs a shared header under include/acpi/ for GHES_PFX,
GHES_ESTATUS_MAX_SIZE, and the CPER reporting entry points, almost everything
added here is never used outside drivers/acpi/apei/.
GHES_ESTATUS_NODE_LEN(), GHES_ESTATUS_FROM_NODE(), and is_hest_sync_notify()
are only used in drivers/acpi/apei/ghes.c, while the pool/cache tuning macros,
vendor record definitions, and is_hest_type_generic_v2() are only used in
drivers/acpi/apei/ghes_cper.c.
The lifecycle and fixmap helpers (ghes_new() through ghes_clear_estatus()) are
shared only between ghes.c and ghes_cper.c, yet are exposed globally without
documenting their ownership or locking contracts: ghes_fini() does not free
the struct ghes allocated by ghes_new(), and the fixmap helpers require caller
serialization for fixmap_idx.
Keeping single-file internals local and placing the APEI-internal cross-file
prototypes in drivers/acpi/apei/apei-internal.h would keep
include/acpi/ghes_cper.h focused on the cross-subsystem API.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-topics-ahmtib01-ras_ffh_arm_internal_review-v8-0-157aac88560b@arm.com?part=13
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v8 04/22] ACPI: APEI: GHES: drain deferred work before freeing a source
2026-12-03 13:40 ` [PATCH v8 04/22] ACPI: APEI: GHES: drain deferred work before freeing a source Ahmed Tiba
@ 2026-12-03 14:00 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-12-03 14:00 UTC (permalink / raw)
To: Ahmed Tiba; +Cc: linux-cxl, linux-pci, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ACPI: APEI: irq_work_sync() in ghes_remove() leaves
concurrent UAF window
- [Low] ACPI: APEI: missing Fixes trailer for commit 21480547c8b8 in
ghes_remove()
--
commit 3ddf2ff751b2a3ebd22a2b95b293aa447a0715c3
Author: Ahmed Tiba <ahmed.tiba@arm.com>
> ACPI: APEI: GHES: drain deferred work before freeing a source
>
> Queued error status nodes retain a pointer to their struct ghes so that
> ghes_proc_in_irq() can process the record later. Device removal stops new
> notifications, but it can free that source while previously queued IRQ
> work still holds the pointer.
>
> Drain the global IRQ work after unregistering the notification source and
> before releasing the GHES resources.
>
> Reported-by: sashiko-bot@kernel.org
> Link: https://sashiko.dev/#/message/20260617140908.9FEA81F000E9%40smtp.kernel.org
> Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
[Severity: Low]
This looks like a bug fix for the deferred processing path introduced in
21480547c8b8 ("ghes: add the needed hooks for EDAC error report"). Should
this include:
Fixes: 21480547c8b8 ("ghes: add the needed hooks for EDAC error report")
> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
> index 03eee0b2500e9..dd3a698990e21 100644
> --- a/drivers/acpi/apei/ghes.c
> +++ b/drivers/acpi/apei/ghes.c
> @@ -1926,6 +1926,7 @@ static void ghes_remove(struct platform_device *ghes_dev)
> break;
> }
>
> + irq_work_sync(&ghes_proc_irq_work);
> ghes_fini(ghes);
>
> mutex_lock(&ghes_devs_mutex);
[Severity: Medium]
Can irq_work_sync(&ghes_proc_irq_work) return while another CPU is still
dereferencing struct ghes inside ghes_proc_in_irq()?
irq_work_single() clears IRQ_WORK_PENDING before invoking work->func(work)
and clears the single IRQ_WORK_BUSY bit afterward with atomic_cmpxchg().
Because ghes_proc_irq_work is shared across all CPUs and NMI/SEA/SDEI
sources, a second CPU can run it concurrently and clear IRQ_WORK_BUSY first.
On !CONFIG_PREEMPT_RT kernels where arch_irq_work_has_interrupt() is true
(x86 with APIC and arm64), irq_work_sync() only spins on IRQ_WORK_BUSY
without an RCU grace period. Because sdei_unregister_ghes() also skips
synchronize_rcu(), ghes_remove() can free struct ghes during ghes_do_proc():
CPU0 CPU1 CPU2
irq_work_single()
clear IRQ_WORK_PENDING
ghes_proc_in_irq()
pop ghes_A node
irq_work_queue()
irq_work_single()
clear IRQ_WORK_PENDING
ghes_proc_in_irq()
clear IRQ_WORK_BUSY
ghes_remove(ghes_A)
irq_work_sync()
/* BUSY == 0 */
ghes_fini(ghes_A)
kfree(ghes_A)
ghes_do_proc(ghes_A)
<-- use-after-free
Calling synchronize_rcu() after irq_work_sync(&ghes_proc_irq_work) would
wait for any in-flight ghes_proc_in_irq() to complete, since irq_work runs
with IRQs disabled on !CONFIG_PREEMPT_RT and in an RCU read-side critical
section on CONFIG_PREEMPT_RT.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-topics-ahmtib01-ras_ffh_arm_internal_review-v8-0-157aac88560b@arm.com?part=4
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v8 17/22] ACPI: APEI: GHES: move vendor record helpers
2026-12-03 13:40 ` [PATCH v8 17/22] ACPI: APEI: GHES: move vendor record helpers Ahmed Tiba
@ 2026-12-03 14:04 ` sashiko-bot
0 siblings, 0 replies; 30+ messages in thread
From: sashiko-bot @ 2026-12-03 14:04 UTC (permalink / raw)
To: Ahmed Tiba; +Cc: linux-cxl, linux-pci, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ACPI: APEI: missing linux/export.h include in ghes_cper.c for
EXPORT_SYMBOL_GPL
--
commit 32967a6148c7a2f76c7f1365d96d8c3c508d73ce
Author: Ahmed Tiba <ahmed.tiba@arm.com>
ACPI: APEI: GHES: move vendor record helpers
This commit moves the vendor record notifier helpers and deferred work
handler from ghes.c into ghes_cper.c so they can be shared with future
DT-based providers.
> diff --git a/drivers/acpi/apei/ghes_cper.c b/drivers/acpi/apei/ghes_cper.c
> index a3c0cf0448186..20826d9fb13ee 100644
> --- a/drivers/acpi/apei/ghes_cper.c
> +++ b/drivers/acpi/apei/ghes_cper.c
> @@ -18,6 +18,7 @@
> #include <linux/kernel.h>
> #include <linux/math64.h>
> #include <linux/mm.h>
> +#include <linux/notifier.h>
> #include <linux/ratelimit.h>
> #include <linux/rcupdate.h>
> #include <linux/sched/clock.h>
[ ... ]
> @@ -281,6 +282,74 @@ void ghes_clear_estatus(struct ghes *ghes,
> ghes_ack_error(ghes->generic_v2);
> }
>
> +static BLOCKING_NOTIFIER_HEAD(vendor_record_notify_list);
> +
> +int ghes_register_vendor_record_notifier(struct notifier_block *nb)
> +{
> + return blocking_notifier_chain_register(&vendor_record_notify_list, nb);
> +}
> +EXPORT_SYMBOL_GPL(ghes_register_vendor_record_notifier);
[Severity: Low]
Should drivers/acpi/apei/ghes_cper.c also include <linux/export.h> now
that it uses EXPORT_SYMBOL_GPL()? Without a direct include, make W=2
triggers a missing-include warning from scripts/misc-check.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-topics-ahmtib01-ras_ffh_arm_internal_review-v8-0-157aac88560b@arm.com?part=17
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2026-12-03 14:04 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 01/22] ACPI: APEI: GHES: wait for RCU readers before unmapping Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 02/22] EDAC: ghes: avoid traversing the GHES device list Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 03/22] ACPI: APEI: GHES: track error status pool allocation size Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 04/22] ACPI: APEI: GHES: drain deferred work before freeing a source Ahmed Tiba
2026-12-03 14:00 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 05/22] ACPI: APEI: GHES: apply read-acknowledge masks directly Ahmed Tiba
2026-12-03 13:58 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 06/22] ACPI: APEI: GHES: revalidate the error status length after copying Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 07/22] ACPI: APEI: GHES: free an estatus cache entry when no slot is found Ahmed Tiba
2026-12-03 13:53 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 08/22] efi/cper: include architecture ACPI declarations directly Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 09/22] ACPI: APEI: GHES: allow the error status pool to be extended Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 10/22] ACPI: APEI: GHES: keep task work valid through error reporting Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 11/22] ACPI: APEI: GHES: reset FRU metadata for each CPER section Ahmed Tiba
2026-12-03 13:54 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 12/22] efi/cper: validate the remaining length before reading a section Ahmed Tiba
2026-12-03 13:52 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 13/22] ACPI: APEI: GHES: share macros via a private header Ahmed Tiba
2026-12-03 14:00 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 14/22] ACPI: APEI: GHES: move CPER read helpers Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 15/22] ACPI: APEI: GHES: move GHESv2 ack and alloc helpers Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 16/22] ACPI: APEI: GHES: move estatus cache helpers Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 17/22] ACPI: APEI: GHES: move vendor record helpers Ahmed Tiba
2026-12-03 14:04 ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 18/22] ACPI: APEI: GHES: move CXL CPER helpers Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 19/22] ACPI: APEI: introduce GHES CPER helper configuration Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 20/22] ACPI: APEI: share GHES CPER helpers Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 21/22] dt-bindings: firmware: add arm,ras-cper Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 22/22] RAS: add firmware-first CPER provider Ahmed Tiba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox