Linux EDAC development
 help / color / mirror / Atom feed
* [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog
@ 2026-11-17 11:10 Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 01/19] x86/APEI: Extract common CPER memory error reporting helper Pierre Gondois
                   ` (18 more replies)
  0 siblings, 19 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Radu Rendec, Avadhut Naik,
	Jonathan Cameron, Kai-Heng Feng, Dave Jiang,
	Fabio M. De Francesco, Breno Leitao, Dan Williams, Terry Bowman,
	linux-acpi, linux-edac, linuxppc-dev, linux-pci, acpica-devel

Hello,

This patchset should be applied on top of [1].

GHES and acpi_extlog handle many of the same CPER sections, but have
separate implementations that do not always report errors in the same
way. This series brings that code together so both paths can use the
same reporting helpers.

Most of the patches prepare for that move. MCE reporting for Memory
Error Section 2 is also added. In the MCE extended-log policy, tracing
and PCIe/CXL handling no longer depend on whether a RAS daemon is
registered. Only fatal CPER records are printed to the console, as
briefly suggested at [2]. For nonfatal records,
users need tracing enabled or a subsystem handler that reports the error.

With the common helper, GHES can emit memory trace events even without
an EDAC driver registered. CXL media records that cannot be queued are
reported through the nonstandard trace event instead of being dropped.

[1] https://lore.kernel.org/lkml/20261113132600.3355836-1-pierre.gondois@arm.com/
[2] https://lore.kernel.org/lkml/20240521183913.GGZkzqUSN1hdE-_OEY@fat_crate.local/

++++++++++++
+ Testing: +
++++++++++++

Some examples of kernel logs,
tested on x86/arm64:

CPER Memory Error section:
{1}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1
{1}[Hardware Error]: event severity: recoverable
{1}[Hardware Error]:  Error 0, type: recoverable
{1}[Hardware Error]:  fru_text: ABCDEFGHIJKLMNOPQRST
{1}[Hardware Error]:   section_type: memory error
{1}[Hardware Error]:    error_status: A read was issued to data that has been poisoned (0x00000000007f1a00)
{1}[Hardware Error]:   physical_address: 0xffffffffffffffff
{1}[Hardware Error]:   physical_address_mask: 0xffffffffffffffff
{1}[Hardware Error]:   node:65535 card:65535 module:65535 rank:65535 bank_group:255 bank_address:255 device:65535 row:262143 column:65535 bit_position:65535 requestor_id:0xffffffffffffffff responder_id:0xffffffffffffffff target_id:0xffffffffffffffff chip_id:7
{1}[Hardware Error]:   error_type: 15, physical memory map-out event
{1}[Hardware Error]:   DIMM location: not present. DMI handle: 0xfeff
$ [arm64 specific log]
EDAC MC0: 1 UE physical memory map-out event on unknown memory (node:65535 card:65535 module:65535 rank:65535 bank_group:255 bank_address:255 device:65535 row:262143 column:65535 bit_position:65535 requestor_id:0xffffffffffffffff responder_id:0xffffffffffffffff target_id:0xffffffffffffffff chip_id:7 DIMM location: not present. DMI handle: 0xfeff page:0xfffffffffffff offset:0xfff grain:1 - APEI location: node:65535 card:65535 module:65535 rank:65535 bank_group:255 bank_address:255 device:65535 row:262143 column:65535 bit_position:65535 requestor_id:0xffffffffffffffff responder_id:0xffffffffffffffff target_id:0xffffffffffffffff chip_id:7 DIMM location: not present. DMI handle: 0xfeff status(0x00000000007f1a00): A read was issued to data that has been poisoned)
Memory failure: 0xfffffffffffff: recovery action for non struct page pfn: Ignored

CPER Memory Error section 2:
{2}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1
{2}[Hardware Error]: event severity: recoverable
{2}[Hardware Error]:  Error 0, type: recoverable
{2}[Hardware Error]:  fru_text: ABCDEFGHIJKLMNOPQRST
{2}[Hardware Error]:   section_type: memory error 2
{2}[Hardware Error]:   error_status: A read was issued to data that has been poisoned (0x00000000007f1a00)
{2}[Hardware Error]:   physical_address: 0xffffffffffffffff
{2}[Hardware Error]:   physical_address_mask: 0xffffffffffffffff
{2}[Hardware Error]:   node:65535 card:65535 module:65535 rank:4294967295 bank_group:255 bank_address:255 device:4294967295 row:4294967295 column:4294967295 bit_position:4294967295 requestor_id:0xffffffffffffffff responder_id:0xffffffffffffffff target_id:0xffffffffffffffff chip_id:255
{2}[Hardware Error]:   error_type: 15, physical memory map-out event
{2}[Hardware Error]:   status: 0x01
{2}[Hardware Error]:   DIMM location: not present. DMI handle: 0x0000feff
$ [arm64 specific log]
EDAC MC0: 1 UE physical memory map-out event on unknown memory (node:65535 card:65535 module:65535 rank:4294967295 bank_group:255 bank_address:255 device:4294967295 row:4294967295 column:4294967295 bit_position:4294967295 requestor_id:0xffffffffffffffff responder_id:0xffffffffffffffff target_id:0xffffffffffffffff chip_id:255 DIMM location: not present. DMI handle: 0x0000feff page:0xfffffffffffff offset:0xfff grain:1 - APEI location: node:65535 card:65535 module:65535 rank:4294967295 bank_group:255 bank_address:255 device:4294967295 row:4294967295 column:4294967295 bit_position:4294967295 requestor_id:0xffffffffffffffff responder_id:0xffffffffffffffff target_id:0xffffffffffffffff chip_id:255 DIMM location: not present. DMI handle: 0x0000feff status(0x00000000007f1a00): A read was issued to data that has been poisoned section_status:0x01)
Memory failure: 0xfffffffffffff: recovery action for non struct page pfn: Ignored

Non standard (i.e. random GUID):
{3}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1
{3}[Hardware Error]: event severity: recoverable
{3}[Hardware Error]:  Error 0, type: recoverable
{3}[Hardware Error]:  fru_text: ABCDEFGHIJKLMNOPQRST
{3}[Hardware Error]:   section type: unknown, 12345678-1234-5678-9abc-def012345679
{3}[Hardware Error]:   section length: 0x21
{3}[Hardware Error]:   00000000: 746e7953 69746568 6f6e2063 6174736e  Synthetic nonsta
{3}[Hardware Error]:   00000010: 7261646e 50432064 65205245 746e6576  ndard CPER event
{3}[Hardware Error]:   00000020: 00                                               .

PCI:
{4}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1
{4}[Hardware Error]: event severity: recoverable
{4}[Hardware Error]:  Error 0, type: recoverable
{4}[Hardware Error]:  fru_text: ABCDEFGHIJKLMNOPQRST
{4}[Hardware Error]:   section_type: PCIe error
{4}[Hardware Error]:   port_type: 0, PCIe end point
{4}[Hardware Error]:   device_id: 0000:01:00.0
{4}[Hardware Error]:   slot: 0
{4}[Hardware Error]:   secondary_bus: 0x00
{4}[Hardware Error]:   vendor_id: 0x1234, device_id: 0x5678
{4}[Hardware Error]:   class_code: 000000
{4}[Hardware Error]:   aer_cor_status: 0x00000000, aer_cor_mask: 0x00000000
{4}[Hardware Error]:   aer_uncor_status: 0x00004000, aer_uncor_mask: 0x00000000
{4}[Hardware Error]:   aer_uncor_severity: 0x00000000
{4}[Hardware Error]:   TLP Header: 00000000 00000000 00000000 00000000
AER: 0000:01:00.0: no pci_dev found

Tracing:
x86:
extlog_mem_event: {1} recoverable error: physical memory map-out event physical addr: ffffffffffffffff (mask lsb: 0) node:65535 card:65535 module:65535 rank:65535 bank_group:255 bank_address:255 device:65535 row:262143 column:65535 bit_position:65535 requestor_id:0xffffffffffffffff responder_id:0xffffffffffffffff target_id:0xffffffffffffffff chip_id:7 DIMM location: not present. DMI handle: 0xfeff FRU: 00000000-0000-0000-0000-000000000000 ABCDEFGHIJKLMNOPQRST
mce_record: CPU: 0, MCGc/s: 100010a/0, MC255: bc0000000000009f, IPID: 0000000000000000, ADDR: ffffffffffffffff, MISC: 0000000000000080, SYND: 0000000000000000, RIP: 00:<0000000000000000>, TSC: 0, PPIN: 0, vendor: 2, CPUID: 663, time: 1794906879, socket: 0, APIC: 0, microcode: 1000065, vendor data: {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
extlog_mem2_event: {2} recoverable error: validation_bits: 0x3fffbf error_status: 0x7f1a00 physical_addr: 0xffffffffffffffff physical_addr_mask: 0xffffffffffffffff node: 65535 card: 65535 module: 65535 bank: 65535 device: 4294967295 row: 4294967295 column: 4294967295 rank: 4294967295 bit_pos: 4294967295 chip_id: 255 error_type: 15 status: 0x1 requestor_id: 0xffffffffffffffff responder_id: 0xffffffffffffffff target_id: 0xffffffffffffffff mem_array_handle: 0xfeff mem_dev_handle: 0xfeff FRU: 00000000-0000-0000-0000-000000000000 ABCDEFGHIJKLMNOPQRST
mce_record: CPU: 0, MCGc/s: 100010a/0, MC255: bc0000000000009f, IPID: 0000000000000000, ADDR: ffffffffffffffff, MISC: 0000000000000080, SYND: 0000000000000000, RIP: 00:<0000000000000000>, TSC: 0, PPIN: 0, vendor: 2, CPUID: 663, time: 1794906882, socket: 0, APIC: 0, microcode: 1000065, vendor data: {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
non_standard_event: severity: 2; sec type:78563412-3412-7856-9abc-def012345679; FRU: 00000000-0000-0000-0000-000000000000 ABCDEFGHIJKLMNOPQRST; data len:33; raw data:53 79 6e 74 68 65 74 69 63 20 6e 6f 6e 73 74 61 6e 64 61 72 64 20 43 50 45 52 20 65 76 65 6e 74 00

arm64:
extlog_mem_event: {1} recoverable error: physical memory map-out event physical addr: ffffffffffffffff (mask lsb: 0) node:65535 card:65535 module:65535 rank:65535 bank_group:255 bank_address:255 device:65535 row:262143 column:65535 bit_position:65535 requestor_id:0xffffffffffffffff responder_id:0xffffffffffffffff target_id:0xffffffffffffffff chip_id:7 DIMM location: not present. DMI handle: 0xfeff FRU: 00000000-0000-0000-0000-000000000000 ABCDEFGHIJKLMNOPQRST
mc_event: 1 Uncorrected error: physical memory map-out event on unknown memory (mc:0 location:-1:-1:-1 address:0xffffffffffffffff grain:1 syndrome:0x00000000 APEI location: node:65535 card:65535 module:65535 rank:65535 bank_group:255 bank_address:255 device:65535 row:262143 column:65535 bit_position:65535 requestor_id:0xffffffffffffffff responder_id:0xffffffffffffffff target_id:0xffffffffffffffff chip_id:7 DIMM location: not present. DMI handle: 0xfeff status(0x00000000007f1a00): A read was issued to data that has been poisoned)
memory_failure_event: pfn 0xfffffffffffff: recovery action for non struct page pfn: Ignored
extlog_mem2_event: {2} recoverable error: validation_bits: 0x3fffbf error_status: 0x7f1a00 physical_addr: 0xffffffffffffffff physical_addr_mask: 0xffffffffffffffff node: 65535 card: 65535 module: 65535 bank: 65535 device: 4294967295 row: 4294967295 column: 4294967295 rank: 4294967295 bit_pos: 4294967295 chip_id: 255 error_type: 15 status: 0x1 requestor_id: 0xffffffffffffffff responder_id: 0xffffffffffffffff target_id: 0xffffffffffffffff mem_array_handle: 0xfeff mem_dev_handle: 0xfeff FRU: 00000000-0000-0000-0000-000000000000 ABCDEFGHIJKLMNOPQRST
mc_event: 1 Uncorrected error: physical memory map-out event on unknown memory (mc:0 location:-1:-1:-1 address:0xffffffffffffffff grain:1 syndrome:0x00000000 APEI location: node:65535 card:65535 module:65535 rank:4294967295 bank_group:255 bank_address:255 device:4294967295 row:4294967295 column:4294967295 bit_position:4294967295 requestor_id:0xffffffffffffffff responder_id:0xffffffffffffffff target_id:0xffffffffffffffff chip_id:255 DIMM location: not present. DMI handle: 0x0000feff status(0x00000000007f1a00): A read was issued to data that has been poisoned section_status:0x01)
memory_failure_event: pfn 0xfffffffffffff: recovery action for non struct page pfn: Ignored
non_standard_event: severity: 2; sec type:78563412-3412-7856-9abc-def012345679; FRU: 00000000-0000-0000-0000-000000000000 ABCDEFGHIJKLMNOPQRST; data len:33; raw data:53 79 6e 74 68 65 74 69 63 20 6e 6f 6e 73 74 61 6e 64 61 72 64 20 43 50 45 52 20 65 76 65 6e 74 00

Pierre Gondois (19):
  x86/APEI: Extract common CPER memory error reporting helper
  x86/APEI: Report Memory Error Section 2 through MCE
  ras: Bound CPER FRU strings in trace events
  ACPI: APEI: Use empty FRU values if valid bit is absent
  PCI/AER: Embed aer_capability_regs copy in struct aer_recover_entry
  ACPI: APEI: Remove aer allocation in ghes_handle_aer()
  ACPI: extlog: Provide HEST generic data to extlog_print_pcie()
  ACPI: extlog: Align extlog_print_pcie() and ghes_handle_aer()
  ACPI: extlog: Report errors independently of RAS consumers
  ACPI: extlog: Simplify fatal record printing
  RAS: Remove unused ras_userspace_consumers()
  ACPI: extlog: Extract CPER reporting from acpi_extlog
  ACPI: APEI: Share helpers with the common CPER reporter
  ACPI: APEI: Return status from cxl_cper_post_event()
  ACPI: APEI: Extend common CPER reporting for GHES section types
  ACPI: extlog: Report error severity using GHES bindings in MCE
  ACPI: APEI: Share the extlog PCIe handler with GHES
  ACPI: APEI: Route GHES section reporting through extlog
  PCI/ERR: Avoid NULL bridge pointer

 arch/x86/include/asm/mce.h        |   5 +-
 arch/x86/kernel/acpi/apei.c       |   7 +
 arch/x86/kernel/cpu/mce/apei.c    |  43 ++++--
 drivers/acpi/acpi_extlog.c        | 138 ++---------------
 drivers/acpi/apei/Makefile        |   2 +-
 drivers/acpi/apei/apei-base.c     |   5 +
 drivers/acpi/apei/apei-internal.h |   7 +
 drivers/acpi/apei/extlog.c        | 236 ++++++++++++++++++++++++++++++
 drivers/acpi/apei/ghes.c          | 168 +++------------------
 drivers/pci/pcie/aer.c            |  34 ++---
 drivers/pci/pcie/err.c            |   5 +
 drivers/ras/debugfs.c             |  10 --
 drivers/ras/ras.c                 |   2 +-
 include/acpi/apei.h               |   1 +
 include/acpi/ghes.h               |   4 -
 include/linux/aer.h               |   2 +-
 include/linux/ras.h               |   2 -
 include/ras/ras_event.h           |   8 +-
 18 files changed, 345 insertions(+), 334 deletions(-)
 create mode 100644 drivers/acpi/apei/extlog.c

--
2.43.0

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v1 01/19] x86/APEI: Extract common CPER memory error reporting helper
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 02/19] x86/APEI: Report Memory Error Section 2 through MCE Pierre Gondois
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Qiuxu Zhuo, Radu Rendec,
	Avadhut Naik, Jonathan Cameron, Dave Jiang, Fabio M. De Francesco,
	Kai-Heng Feng, Breno Leitao, Dan Williams, Terry Bowman,
	linux-acpi, linux-edac, linuxppc-dev, linux-pci, acpica-devel

Prepare for reporting CPER Memory Error Section 2 records through MCE
by extracting apei_mce_report_mem_error_common().

No functional change.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 arch/x86/kernel/cpu/mce/apei.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c
index 0a89947e47bc8..b993ac78a3b36 100644
--- a/arch/x86/kernel/cpu/mce/apei.c
+++ b/arch/x86/kernel/cpu/mce/apei.c
@@ -26,24 +26,15 @@
 
 #include "internal.h"
 
-void apei_mce_report_mem_error(int severity, struct cper_sec_mem_err *mem_err)
+static void apei_mce_report_mem_error_common(int severity, u64 physical_addr,
+					     u64 physical_addr_mask)
 {
 	struct mce_hw_err err;
 	struct mce *m;
 	int lsb;
 
-	if (!(mem_err->validation_bits & CPER_MEM_VALID_PA))
-		return;
-
-	/*
-	 * Even if the ->validation_bits are set for address mask,
-	 * to be extra safe, check and reject an error radius '0',
-	 * and fall back to the default page size.
-	 */
-	if (mem_err->validation_bits & CPER_MEM_VALID_PA_MASK)
-		lsb = find_first_bit((void *)&mem_err->physical_addr_mask, PAGE_SHIFT);
-	else
-		lsb = PAGE_SHIFT;
+	/* Missing or zero masks default to page granularity. */
+	lsb = find_first_bit((void *)&physical_addr_mask, PAGE_SHIFT);
 
 	mce_prep_record(&err);
 	m = &err.m;
@@ -60,9 +51,21 @@ void apei_mce_report_mem_error(int severity, struct cper_sec_mem_err *mem_err)
 		m->tsc = rdtsc();
 	}
 
-	m->addr = mem_err->physical_addr;
+	m->addr = physical_addr;
 	mce_log(&err);
 }
+
+void apei_mce_report_mem_error(int severity, struct cper_sec_mem_err *mem_err)
+{
+	u64 mask = 0;
+
+	if (!(mem_err->validation_bits & CPER_MEM_VALID_PA))
+		return;
+	if (mem_err->validation_bits & CPER_MEM_VALID_PA_MASK)
+		mask = mem_err->physical_addr_mask;
+
+	apei_mce_report_mem_error_common(severity, mem_err->physical_addr, mask);
+}
 EXPORT_SYMBOL_GPL(apei_mce_report_mem_error);
 
 int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 02/19] x86/APEI: Report Memory Error Section 2 through MCE
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 01/19] x86/APEI: Extract common CPER memory error reporting helper Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 03/19] ras: Bound CPER FRU strings in trace events Pierre Gondois
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Avadhut Naik, Jonathan Cameron,
	Dave Jiang, Fabio M. De Francesco, Kai-Heng Feng, Breno Leitao,
	Dan Williams, Terry Bowman, linux-acpi, linux-edac, linuxppc-dev,
	linux-pci, acpica-devel

Add support for CPER Memory Error Section 2 through MCE, allowing
to emit an mce_record trace event. The implementation follows
the existing CPER Memory Error Section (1) implementation.

Fix the mismatch between the parameter definition/declaration
of apei_mce_report_mem_error().

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 arch/x86/include/asm/mce.h     |  5 ++++-
 arch/x86/kernel/acpi/apei.c    |  7 +++++++
 arch/x86/kernel/cpu/mce/apei.c | 12 ++++++++++++
 drivers/acpi/apei/apei-base.c  |  5 +++++
 drivers/acpi/apei/ghes.c       |  1 +
 include/acpi/apei.h            |  1 +
 6 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index 9995176d68790..4a590a250720d 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -336,8 +336,11 @@ extern void (*deferred_error_int_vector)(void);
  */
 
 struct cper_sec_mem_err;
-extern void apei_mce_report_mem_error(int corrected,
+struct cper_sec_mem_err2;
+extern void apei_mce_report_mem_error(int severity,
 				      struct cper_sec_mem_err *mem_err);
+extern void apei_mce_report_mem_error2(int severity,
+				      struct cper_sec_mem_err2 *mem_err);
 
 /*
  * Enumerate new IP types and HWID values in AMD processors which support
diff --git a/arch/x86/kernel/acpi/apei.c b/arch/x86/kernel/acpi/apei.c
index e21419e686eb3..96eb75b570e4e 100644
--- a/arch/x86/kernel/acpi/apei.c
+++ b/arch/x86/kernel/acpi/apei.c
@@ -46,6 +46,13 @@ void arch_apei_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
 #endif
 }
 
+void arch_apei_report_mem_error2(int sev, struct cper_sec_mem_err2 *mem_err)
+{
+#ifdef CONFIG_X86_MCE
+	apei_mce_report_mem_error2(sev, mem_err);
+#endif
+}
+
 int arch_apei_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id)
 {
 	return apei_smca_report_x86_error(ctx_info, lapic_id);
diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c
index b993ac78a3b36..2404faa60c325 100644
--- a/arch/x86/kernel/cpu/mce/apei.c
+++ b/arch/x86/kernel/cpu/mce/apei.c
@@ -68,6 +68,18 @@ void apei_mce_report_mem_error(int severity, struct cper_sec_mem_err *mem_err)
 }
 EXPORT_SYMBOL_GPL(apei_mce_report_mem_error);
 
+void apei_mce_report_mem_error2(int severity, struct cper_sec_mem_err2 *mem_err)
+{
+	u64 mask = 0;
+
+	if (!(mem_err->validation_bits & CPER_MEM2_VALID_PA))
+		return;
+	if (mem_err->validation_bits & CPER_MEM2_VALID_PA_MASK)
+		mask = mem_err->physical_addr_mask;
+
+	apei_mce_report_mem_error_common(severity, mem_err->physical_addr, mask);
+}
+
 int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id)
 {
 	const u64 *i_mce = ((const u64 *) (ctx_info + 1));
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index 7a06d30bd40e9..a2dbdfabeb6c7 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -773,6 +773,11 @@ void __weak arch_apei_report_mem_error(int sev,
 }
 EXPORT_SYMBOL_GPL(arch_apei_report_mem_error);
 
+void __weak arch_apei_report_mem_error2(int sev,
+					struct cper_sec_mem_err2 *mem_err)
+{
+}
+
 int apei_osc_setup(void)
 {
 	static u8 whea_uuid_str[] = "ed855e0c-6c90-47bf-a62a-26de0fc5ad5c";
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 07306af5a54b9..703f3b7f700a6 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -1030,6 +1030,7 @@ static void ghes_do_proc(struct ghes *ghes,
 			}
 
 			atomic_notifier_call_chain(&ghes_report_mem2_chain, sev, mem_err);
+			arch_apei_report_mem_error2(sev, mem_err);
 			queued |= ghes_handle_memory_failure2(gdata, sev, sync);
 		} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
 			ghes_handle_aer(gdata);
diff --git a/include/acpi/apei.h b/include/acpi/apei.h
index dc60f7db5524f..a92174793d9c2 100644
--- a/include/acpi/apei.h
+++ b/include/acpi/apei.h
@@ -52,6 +52,7 @@ int erst_clear(u64 record_id);
 
 int arch_apei_enable_cmcff(struct acpi_hest_header *hest_hdr, void *data);
 void arch_apei_report_mem_error(int sev, struct cper_sec_mem_err *mem_err);
+void arch_apei_report_mem_error2(int sev, struct cper_sec_mem_err2 *mem_err);
 
 #endif
 #endif
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 03/19] ras: Bound CPER FRU strings in trace events
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 01/19] x86/APEI: Extract common CPER memory error reporting helper Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 02/19] x86/APEI: Report Memory Error Section 2 through MCE Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 04/19] ACPI: APEI: Use empty FRU values if valid bit is absent Pierre Gondois
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Qiuxu Zhuo, Avadhut Naik,
	Jonathan Cameron, Fabio M. De Francesco, Kai-Heng Feng,
	Dave Jiang, Breno Leitao, Terry Bowman, Dan Williams, linux-acpi,
	linux-edac, linuxppc-dev, linux-pci, acpica-devel

CPER FRU text occupies a fixed 20-byte field and need not contain a NUL
terminator. Using __string() can read past the field and, for a short
nonstandard section, past the end of the firmware record.

Bound FRU text in the legacy memory and nonstandard trace events with
__string_len() and strnlen(), as already done for the Section 2 event.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 include/ras/ras_event.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
index ce759ee1cf4cc..069c7b3a5e6c0 100644
--- a/include/ras/ras_event.h
+++ b/include/ras/ras_event.h
@@ -39,7 +39,7 @@ TRACE_EVENT(extlog_mem_event,
 		__field(u64, pa)
 		__field(u8, pa_mask_lsb)
 		__field_struct(guid_t, fru_id)
-		__string(fru_text, fru_text)
+		__string_len(fru_text, fru_text, strnlen(fru_text, 20))
 		__field_struct(struct cper_mem_err_compact, data)
 	),
 
@@ -370,7 +370,7 @@ TRACE_EVENT(non_standard_event,
 	TP_STRUCT__entry(
 		__array(char, sec_type, UUID_SIZE)
 		__array(char, fru_id, UUID_SIZE)
-		__string(fru_text, fru_text)
+		__string_len(fru_text, fru_text, strnlen(fru_text, 20))
 		__field(u8, sev)
 		__field(u32, len)
 		__dynamic_array(u8, buf, len)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 04/19] ACPI: APEI: Use empty FRU values if valid bit is absent
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (2 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 03/19] ras: Bound CPER FRU strings in trace events Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 05/19] PCI/AER: Embed aer_capability_regs copy in struct aer_recover_entry Pierre Gondois
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Avadhut Naik, Jonathan Cameron,
	Fabio M. De Francesco, Dave Jiang, Kai-Heng Feng, Breno Leitao,
	Dan Williams, Terry Bowman, linux-acpi, linux-edac, linuxppc-dev,
	linux-pci, acpica-devel

When a status block contains multiple sections, a section without valid
FRU fields inherits pointers from the preceding section.

Use empty fru_id and fru_text values whenever the matching VALID
bit is not set instead of reusing the value of the previous loop.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/apei/ghes.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 703f3b7f700a6..444d8e82353a7 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -979,8 +979,8 @@ static void ghes_do_proc(struct ghes *ghes,
 	int sev, sec_sev;
 	struct acpi_hest_generic_data *gdata;
 	guid_t *sec_type;
-	const guid_t *fru_id = &guid_null;
-	char *fru_text = "";
+	const guid_t *fru_id;
+	const char *fru_text;
 	bool queued = false;
 	bool sync = is_hest_sync_notify(ghes);
 
@@ -990,9 +990,13 @@ static void ghes_do_proc(struct ghes *ghes,
 		sec_sev = ghes_severity(gdata->error_severity);
 		if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
 			fru_id = (guid_t *)gdata->fru_id;
+		else
+			fru_id = &guid_null;
 
 		if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
 			fru_text = gdata->fru_text;
+		else
+			fru_text = "";
 
 		ghes_log_hwerr(sev, sec_type);
 		if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 05/19] PCI/AER: Embed aer_capability_regs copy in struct aer_recover_entry
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (3 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 04/19] ACPI: APEI: Use empty FRU values if valid bit is absent Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:44   ` Lukas Wunner
  2026-11-17 11:10 ` [PATCH v1 06/19] ACPI: APEI: Remove aer allocation in ghes_handle_aer() Pierre Gondois
                   ` (13 subsequent siblings)
  18 siblings, 1 reply; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Avadhut Naik, Jonathan Cameron,
	Kai-Heng Feng, Fabio M. De Francesco, Dave Jiang, Breno Leitao,
	Terry Bowman, Dan Williams, linux-acpi, linux-edac, linuxppc-dev,
	linux-pci, acpica-devel

commit e2abc47a5a1a ("ACPI: APEI: Fix AER info corruption when error
status data has multiple sections") passed to aer_recover_queue() a
newly allocated copy of pcie_err->aer_info instead of providing a
pointer to the ghes struct. This prevented corruptions of the ghes
record (in case the ghes record was re-used for a new error before
the previous error was logged).

To prepare for using a common logging/reporting structure for
ghes/MCE and merging extlog_print_pcie() / ghes_handle_aer() into
a common helper, remove the dependency of ghes_handle_aer() over
gen_pool_alloc().

To achieve the above, replace (struct aer_recover_entry).regs by a
plain struct instead of a pointer, allowing to remove the memory
allocation.

No functional change intended.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/pci/pcie/aer.c | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 8708ca3257bb8..57406494ec1f7 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -1352,7 +1352,7 @@ struct aer_recover_entry {
 	u8	devfn;
 	u16	domain;
 	int	severity;
-	struct aer_capability_regs *regs;
+	struct aer_capability_regs regs;
 };
 
 static DEFINE_KFIFO(aer_recover_ring, struct aer_recover_entry,
@@ -1374,24 +1374,14 @@ static void aer_recover_work_func(struct work_struct *work)
 					   PCI_SLOT(entry.devfn),
 					   PCI_FUNC(entry.devfn));
 		else
-			pci_print_aer(pdev, entry.severity, entry.regs);
+			pci_print_aer(pdev, entry.severity, &entry.regs);
 
-		regs = entry.regs;
+		regs = &entry.regs;
 		if (entry.severity == AER_CORRECTABLE)
 			err = regs->cor_status & ~regs->cor_mask;
 		else
 			err = regs->uncor_status & ~regs->uncor_mask;
 
-		/*
-		 * Memory for aer_capability_regs(entry.regs) is being
-		 * allocated from the ghes_estatus_pool to protect it from
-		 * overwriting when multiple sections are present in the
-		 * error status. Thus free the same after processing the
-		 * data.
-		 */
-		ghes_estatus_pool_region_free((unsigned long)entry.regs,
-					    sizeof(struct aer_capability_regs));
-
 		if (!pdev)
 			continue;
 
@@ -1429,9 +1419,9 @@ static DECLARE_WORK(aer_recover_work, aer_recover_work_func);
  *
  * Takes ownership of @aer_regs, which must have been allocated from
  * ghes_estatus_pool with a size of sizeof(struct aer_capability_regs).
- * The buffer is freed with ghes_estatus_pool_region_free() by the work
- * item that processes the record, or immediately if the queue is full.
- * The caller must not access or free @aer_regs after this call.
+ * Copies the registers into the queue entry and frees the supplied buffer
+ * before returning, including when the queue is full. The caller must not
+ * access or free @aer_regs after this call.
  */
 void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
 		       int severity, struct aer_capability_regs *aer_regs)
@@ -1441,17 +1431,18 @@ void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
 		.devfn		= devfn,
 		.domain		= domain,
 		.severity	= severity,
-		.regs		= aer_regs,
+		.regs		= *aer_regs,
 	};
 
+	ghes_estatus_pool_region_free((unsigned long)aer_regs,
+				      sizeof(struct aer_capability_regs));
+
 	if (kfifo_in_spinlocked(&aer_recover_ring, &entry, 1,
 				 &aer_recover_ring_lock)) {
 		schedule_work(&aer_recover_work);
 	} else {
 		pr_err("buffer overflow in recovery for %04x:%02x:%02x.%x\n",
 		       domain, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
-		ghes_estatus_pool_region_free((unsigned long)aer_regs,
-					      sizeof(struct aer_capability_regs));
 	}
 }
 EXPORT_SYMBOL_GPL(aer_recover_queue);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 06/19] ACPI: APEI: Remove aer allocation in ghes_handle_aer()
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (4 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 05/19] PCI/AER: Embed aer_capability_regs copy in struct aer_recover_entry Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 07/19] ACPI: extlog: Provide HEST generic data to extlog_print_pcie() Pierre Gondois
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Qiuxu Zhuo, Radu Rendec,
	Avadhut Naik, Jonathan Cameron, Dave Jiang, Kai-Heng Feng,
	Fabio M. De Francesco, Breno Leitao, Dan Williams, Terry Bowman,
	linux-acpi, linux-edac, linuxppc-dev, linux-pci, acpica-devel

aer_recover_queue() now copies the input aer_regs instead of
storing a pointer to the struct. Use a local variable to pass
aer_regs in ghes_handle_aer() and remove the memory allocation
introduced by:
commit e2abc47a5a1a ("ACPI: APEI: Fix AER info corruption when error
status data has multiple sections")

No functional change intended.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/apei/ghes.c | 25 +++----------------------
 drivers/pci/pcie/aer.c   | 17 +++++------------
 include/acpi/ghes.h      |  4 ----
 include/linux/aer.h      |  2 +-
 4 files changed, 9 insertions(+), 39 deletions(-)

diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 444d8e82353a7..3aecd3f828e58 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -228,20 +228,6 @@ int ghes_estatus_pool_init(unsigned int num_ghes)
 	return -ENOMEM;
 }
 
-/**
- * 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 int map_gen_v2(struct ghes *ghes)
 {
 	return apei_map_generic_address(&ghes->generic_v2->read_ack_register);
@@ -666,7 +652,7 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata)
 
 	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;
+		struct aer_capability_regs aer_info;
 		unsigned int devfn;
 		int aer_severity;
 
@@ -682,16 +668,11 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata)
 		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_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);
+				  devfn, aer_severity, &aer_info);
 	}
 #endif
 }
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 57406494ec1f7..d7ef84e3b988e 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -32,7 +32,6 @@
 #include <linux/slab.h>
 #include <linux/vmcore_info.h>
 #include <acpi/apei.h>
-#include <acpi/ghes.h>
 #include <ras/ras_event.h>
 
 #include "../pci.h"
@@ -1413,18 +1412,15 @@ static DECLARE_WORK(aer_recover_work, aer_recover_work_func);
  * @severity: AER_CORRECTABLE, AER_NONFATAL or AER_FATAL
  * @aer_regs: snapshot of the device's AER Capability registers
  *
- * Queue an error record received from firmware through APEI GHES.  The
- * record is processed later from a workqueue, which logs the error and,
+ * Queue an error record received from firmware. The record is processed
+ * later from a workqueue, which logs the error and,
  * for uncorrectable errors, attempts recovery of the device.
  *
- * Takes ownership of @aer_regs, which must have been allocated from
- * ghes_estatus_pool with a size of sizeof(struct aer_capability_regs).
- * Copies the registers into the queue entry and frees the supplied buffer
- * before returning, including when the queue is full. The caller must not
- * access or free @aer_regs after this call.
+ * Copies @aer_regs into the recovery queue. The caller retains ownership of
+ * the supplied snapshot and may reuse it after this function returns.
  */
 void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
-		       int severity, struct aer_capability_regs *aer_regs)
+		       int severity, const struct aer_capability_regs *aer_regs)
 {
 	struct aer_recover_entry entry = {
 		.bus		= bus,
@@ -1434,9 +1430,6 @@ void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
 		.regs		= *aer_regs,
 	};
 
-	ghes_estatus_pool_region_free((unsigned long)aer_regs,
-				      sizeof(struct aer_capability_regs));
-
 	if (kfifo_in_spinlocked(&aer_recover_ring, &entry, 1,
 				 &aer_recover_ring_lock)) {
 		schedule_work(&aer_recover_work);
diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h
index 3fdb7ea59f9cc..ef58e2251407e 100644
--- a/include/acpi/ghes.h
+++ b/include/acpi/ghes.h
@@ -84,15 +84,11 @@ 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
 
 int ghes_estatus_pool_init(unsigned int num_ghes);
diff --git a/include/linux/aer.h b/include/linux/aer.h
index 043ee76b6f538..0a5ec7956b487 100644
--- a/include/linux/aer.h
+++ b/include/linux/aer.h
@@ -79,6 +79,6 @@ void aer_cap_regs_unpack(struct aer_capability_regs *regs, const void *raw,
 			 size_t raw_len);
 int cper_severity_to_aer(int cper_severity);
 void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
-		       int severity, struct aer_capability_regs *aer_regs);
+		       int severity, const struct aer_capability_regs *aer_regs);
 #endif //_AER_H_
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 07/19] ACPI: extlog: Provide HEST generic data to extlog_print_pcie()
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (5 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 06/19] ACPI: APEI: Remove aer allocation in ghes_handle_aer() Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 08/19] ACPI: extlog: Align extlog_print_pcie() and ghes_handle_aer() Pierre Gondois
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Qiuxu Zhuo, Avadhut Naik,
	Jonathan Cameron, Fabio M. De Francesco, Kai-Heng Feng,
	Dave Jiang, Breno Leitao, Dan Williams,
	Kuppuswamy Sathyanarayanan, Terry Bowman, linux-acpi, linux-edac,
	linuxppc-dev, linux-pci, acpica-devel

Pass struct acpi_hest_generic_data to extlog_print_pcie() and derive
the payload, severity and length from it instead of passing them
individually. This reduces the number of arguments and makes the
section flags available for subsequent changes.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/acpi_extlog.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index 5565177be328f..125f7931b98bc 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -133,10 +133,10 @@ static int print_extlog_rcd(const char *pfx,
 	return 1;
 }
 
-static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
-			      int severity, u32 len)
+static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
 {
 #ifdef CONFIG_ACPI_APEI_PCIEAER
+	struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
 	struct aer_capability_regs aer_regs = {};
 	struct pci_dev *pdev;
 	unsigned int devfn;
@@ -144,9 +144,10 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
 	int aer_severity;
 	int domain;
 
-	if (len < sizeof(*pcie_err)) {
+	if (gdata->error_data_length < sizeof(*pcie_err)) {
 		pr_warn_ratelimited(FW_WARN
-				    "PCIe error section too small (%u)\n", len);
+				    "PCIe error section too small (%u)\n",
+				    gdata->error_data_length);
 		return;
 	}
 
@@ -154,7 +155,7 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
 	      pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO))
 		return;
 
-	aer_severity = cper_severity_to_aer(severity);
+	aer_severity = cper_severity_to_aer(gdata->error_severity);
 
 	aer_cap_regs_unpack(&aer_regs, pcie_err->aer_info, sizeof(pcie_err->aer_info));
 
@@ -245,10 +246,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 					       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);
-
-			extlog_print_pcie(pcie_err, gdata->error_severity,
-					  gdata->error_data_length);
+			extlog_print_pcie(gdata);
 		} else {
 			void *err = acpi_hest_get_payload(gdata);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 08/19] ACPI: extlog: Align extlog_print_pcie() and ghes_handle_aer()
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (6 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 07/19] ACPI: extlog: Provide HEST generic data to extlog_print_pcie() Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 09/19] ACPI: extlog: Report errors independently of RAS consumers Pierre Gondois
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Radu Rendec, Avadhut Naik,
	Jonathan Cameron, Kai-Heng Feng, Fabio M. De Francesco,
	Dave Jiang, Breno Leitao, Terry Bowman,
	Kuppuswamy Sathyanarayanan, linux-acpi, linux-edac, linuxppc-dev,
	linux-pci, acpica-devel

In order to unify extlog_print_pcie() with ghes_handle_aer() and
prepare to remove one of the functions, align the behaviour of the
2 functions. Thus:
- Submit the decoded snapshot through aer_recover_queue() instead of
  just printing the error.
- Override the mapped AER severity with AER_FATAL when CPER_SEC_RESET
  is set so the AER worker selects the frozen-channel recovery path
  when it finds an unmasked uncorrectable error.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/acpi_extlog.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index 125f7931b98bc..e09ea571c32f5 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -8,9 +8,11 @@
 
 #include <linux/module.h>
 #include <linux/acpi.h>
+#include <linux/aer.h>
 #include <linux/cper.h>
 #include <linux/ratelimit.h>
 #include <linux/edac.h>
+#include <linux/pci.h>
 #include <linux/ras.h>
 #include <cxl/event.h>
 #include <acpi/ghes.h>
@@ -138,7 +140,6 @@ static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
 #ifdef CONFIG_ACPI_APEI_PCIEAER
 	struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
 	struct aer_capability_regs aer_regs = {};
-	struct pci_dev *pdev;
 	unsigned int devfn;
 	unsigned int bus;
 	int aer_severity;
@@ -156,6 +157,9 @@ static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
 		return;
 
 	aer_severity = cper_severity_to_aer(gdata->error_severity);
+	/* A component reset by firmware needs reinitialization. */
+	if (gdata->flags & CPER_SEC_RESET)
+		aer_severity = AER_FATAL;
 
 	aer_cap_regs_unpack(&aer_regs, pcie_err->aer_info, sizeof(pcie_err->aer_info));
 
@@ -163,12 +167,7 @@ static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
 	bus = pcie_err->device_id.bus;
 	devfn = PCI_DEVFN(pcie_err->device_id.device,
 			  pcie_err->device_id.function);
-	pdev = pci_get_domain_bus_and_slot(domain, bus, devfn);
-	if (!pdev)
-		return;
-
-	pci_print_aer(pdev, aer_severity, &aer_regs);
-	pci_dev_put(pdev);
+	aer_recover_queue(domain, bus, devfn, aer_severity, &aer_regs);
 #endif
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 09/19] ACPI: extlog: Report errors independently of RAS consumers
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (7 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 08/19] ACPI: extlog: Align extlog_print_pcie() and ghes_handle_aer() Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 10/19] ACPI: extlog: Simplify fatal record printing Pierre Gondois
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Avadhut Naik, Qiuxu Zhuo,
	Jonathan Cameron, Fabio M. De Francesco, Dave Jiang,
	Kai-Heng Feng, Breno Leitao, Terry Bowman, Dan Williams,
	linux-acpi, linux-edac, linuxppc-dev, linux-pci, acpica-devel

The RAS consumer check removes:
- trace events when no daemon is registered
- CPER console report when one is registered
This ties tracing, PCIe recovery and CXL protocol delivery to daemon
registration, and can hide a fatal record when userspace cannot process
its trace event before a reset.

Remove the RAS consumer registration condition and:
- always emit trace events
- print the CPER record only for CPER_SEV_FATAL

[1] additionally suggested to have a cmdline parameter to dynamically
update the above policy. Keep a simple hard coded policy for now.

[1]
https://lore.kernel.org/lkml/20240521183913.GGZkzqUSN1hdE-_OEY@fat_crate.local/

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/acpi_extlog.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index e09ea571c32f5..16a16b12d8ccf 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -208,10 +208,9 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 	if (cper_estatus_len(tmp) > ELOG_ENTRY_LEN || cper_estatus_check(tmp))
 		return NOTIFY_DONE;
 
-	if (!ras_userspace_consumers()) {
+	/* Print fatal records regardless of RAS consumer registration. */
+	if (tmp->error_severity == CPER_SEV_FATAL)
 		print_extlog_rcd(NULL, tmp, cpu);
-		goto out;
-	}
 
 	/* log event via trace */
 	err_seq++;
@@ -255,7 +254,6 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 		}
 	}
 
-out:
 	mce->kflags |= MCE_HANDLED_EXTLOG;
 	return NOTIFY_OK;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 10/19] ACPI: extlog: Simplify fatal record printing
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (8 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 09/19] ACPI: extlog: Report errors independently of RAS consumers Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 11/19] RAS: Remove unused ras_userspace_consumers() Pierre Gondois
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Avadhut Naik, Jonathan Cameron,
	Kai-Heng Feng, Dave Jiang, Fabio M. De Francesco, Breno Leitao,
	Terry Bowman, Kuppuswamy Sathyanarayanan, Dan Williams,
	linux-acpi, linux-edac, linuxppc-dev, linux-pci, acpica-devel

Only fatal CPER records reach print_extlog_rcd().
Merge the two helpers, remove the unused prefix argument
and return value, and keep a single rate limiter.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/acpi_extlog.c | 39 ++++++++------------------------------
 1 file changed, 8 insertions(+), 31 deletions(-)

diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index 16a16b12d8ccf..1782a19eb474b 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -95,46 +95,23 @@ static struct acpi_hest_generic_status *extlog_elog_entry_check(int cpu, int ban
 	return estatus;
 }
 
-static void __print_extlog_rcd(const char *pfx,
-			       struct acpi_hest_generic_status *estatus, int cpu)
+static void print_extlog_rcd(struct acpi_hest_generic_status *estatus, int cpu)
 {
+	/* Not more than 2 messages every 5 seconds */
+	static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 2);
 	static atomic_t seqno;
 	unsigned int curr_seqno;
 	char pfx_seq[64];
 
-	if (!pfx) {
-		if (estatus->error_severity <= CPER_SEV_CORRECTED)
-			pfx = KERN_INFO;
-		else
-			pfx = KERN_ERR;
-	}
+	if (!__ratelimit(&ratelimit))
+		return;
+
 	curr_seqno = atomic_inc_return(&seqno);
-	snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}", pfx, curr_seqno);
+	snprintf(pfx_seq, sizeof(pfx_seq), KERN_ERR "{%u}", curr_seqno);
 	printk("%s""Hardware error detected on CPU%d\n", pfx_seq, cpu);
 	cper_estatus_print(pfx_seq, estatus);
 }
 
-static int print_extlog_rcd(const char *pfx,
-			    struct acpi_hest_generic_status *estatus, int cpu)
-{
-	/* 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 (estatus->error_severity == CPER_SEV_CORRECTED ||
-	    (estatus->error_severity == CPER_SEV_INFORMATIONAL))
-		ratelimit = &ratelimit_corrected;
-	else
-		ratelimit = &ratelimit_uncorrected;
-	if (__ratelimit(ratelimit)) {
-		__print_extlog_rcd(pfx, estatus, cpu);
-		return 0;
-	}
-
-	return 1;
-}
-
 static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
 {
 #ifdef CONFIG_ACPI_APEI_PCIEAER
@@ -210,7 +187,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 
 	/* Print fatal records regardless of RAS consumer registration. */
 	if (tmp->error_severity == CPER_SEV_FATAL)
-		print_extlog_rcd(NULL, tmp, cpu);
+		print_extlog_rcd(tmp, cpu);
 
 	/* log event via trace */
 	err_seq++;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 11/19] RAS: Remove unused ras_userspace_consumers()
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (9 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 10/19] ACPI: extlog: Simplify fatal record printing Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 12/19] ACPI: extlog: Extract CPER reporting from acpi_extlog Pierre Gondois
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Qiuxu Zhuo, Avadhut Naik,
	Jonathan Cameron, Fabio M. De Francesco, Kai-Heng Feng,
	Dave Jiang, Breno Leitao, Terry Bowman, Dan Williams, linux-acpi,
	linux-edac, linuxppc-dev, linux-pci, acpica-devel

Remove the unused ras_userspace_consumers() and atomic
trace_count as the previous patch made extlog select
CPER console output by severity.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/ras/debugfs.c | 10 ----------
 include/linux/ras.h   |  2 --
 2 files changed, 12 deletions(-)

diff --git a/drivers/ras/debugfs.c b/drivers/ras/debugfs.c
index 42afd3de68b22..838cc689b9989 100644
--- a/drivers/ras/debugfs.c
+++ b/drivers/ras/debugfs.c
@@ -5,20 +5,12 @@
 
 static struct dentry *ras_debugfs_dir;
 
-static atomic_t trace_count = ATOMIC_INIT(0);
-
 struct dentry *ras_get_debugfs_root(void)
 {
 	return ras_debugfs_dir;
 }
 EXPORT_SYMBOL_GPL(ras_get_debugfs_root);
 
-int ras_userspace_consumers(void)
-{
-	return atomic_read(&trace_count);
-}
-EXPORT_SYMBOL_GPL(ras_userspace_consumers);
-
 static int trace_show(struct seq_file *m, void *v)
 {
 	return 0;
@@ -26,13 +18,11 @@ static int trace_show(struct seq_file *m, void *v)
 
 static int trace_open(struct inode *inode, struct file *file)
 {
-	atomic_inc(&trace_count);
 	return single_open(file, trace_show, NULL);
 }
 
 static int trace_release(struct inode *inode, struct file *file)
 {
-	atomic_dec(&trace_count);
 	return single_release(inode, file);
 }
 
diff --git a/include/linux/ras.h b/include/linux/ras.h
index 468941bfe855f..3159f9a0877ed 100644
--- a/include/linux/ras.h
+++ b/include/linux/ras.h
@@ -7,11 +7,9 @@
 #include <linux/cper.h>
 
 #ifdef CONFIG_DEBUG_FS
-int ras_userspace_consumers(void);
 void ras_debugfs_init(void);
 int ras_add_daemon_trace(void);
 #else
-static inline int ras_userspace_consumers(void) { return 0; }
 static inline void ras_debugfs_init(void) { }
 static inline int ras_add_daemon_trace(void) { return 0; }
 #endif
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 12/19] ACPI: extlog: Extract CPER reporting from acpi_extlog
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (10 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 11/19] RAS: Remove unused ras_userspace_consumers() Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 13/19] ACPI: APEI: Share helpers with the common CPER reporter Pierre Gondois
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Qiuxu Zhuo, Avadhut Naik,
	Jonathan Cameron, Fabio M. De Francesco, Dave Jiang,
	Kai-Heng Feng, Breno Leitao, Terry Bowman, linux-acpi, linux-edac,
	linuxppc-dev, linux-pci, acpica-devel

Extract the CPER reporting code to a separate file in order
to re-use it in the GHES code in a later patch.

CONFIG_ACPI_EXTLOG selects ACPI_APEI_GHES and acpi_extlog_report()
will be used in ghes.c, built with CONFIG_ACPI_APEI_GHES. Thus also
build extlog.c under CONFIG_ACPI_APEI_GHES.

Relax the definition of extlog_mem[|2]_event tracepoints to
CONFIG_ACPI_APEI_GHES. The common reporter references them even
when CONFIG_ACPI_EXTLOG is disabled. Guard its memory trace calls
with CONFIG_RAS because GHES can be enabled without RAS.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/acpi_extlog.c        |  90 +---------------
 drivers/acpi/apei/Makefile        |   2 +-
 drivers/acpi/apei/apei-internal.h |   2 +
 drivers/acpi/apei/extlog.c        | 171 ++++++++++++++++++++++++++++++
 drivers/acpi/apei/ghes.c          |   1 -
 drivers/ras/ras.c                 |   2 +-
 include/ras/ras_event.h           |   4 +-
 7 files changed, 178 insertions(+), 94 deletions(-)
 create mode 100644 drivers/acpi/apei/extlog.c

diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index 1782a19eb474b..47b2e5f133911 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -8,20 +8,13 @@
 
 #include <linux/module.h>
 #include <linux/acpi.h>
-#include <linux/aer.h>
 #include <linux/cper.h>
 #include <linux/ratelimit.h>
-#include <linux/edac.h>
-#include <linux/pci.h>
-#include <linux/ras.h>
-#include <cxl/event.h>
-#include <acpi/ghes.h>
 #include <asm/cpu.h>
 #include <asm/mce.h>
 #include <asm/msr.h>
 
 #include "apei/apei-internal.h"
-#include <ras/ras_event.h>
 
 #define EXT_ELOG_ENTRY_MASK	GENMASK_ULL(51, 0) /* elog entry address mask */
 
@@ -112,42 +105,6 @@ static void print_extlog_rcd(struct acpi_hest_generic_status *estatus, int cpu)
 	cper_estatus_print(pfx_seq, estatus);
 }
 
-static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
-{
-#ifdef CONFIG_ACPI_APEI_PCIEAER
-	struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
-	struct aer_capability_regs aer_regs = {};
-	unsigned int devfn;
-	unsigned int bus;
-	int aer_severity;
-	int domain;
-
-	if (gdata->error_data_length < sizeof(*pcie_err)) {
-		pr_warn_ratelimited(FW_WARN
-				    "PCIe error section too small (%u)\n",
-				    gdata->error_data_length);
-		return;
-	}
-
-	if (!(pcie_err->validation_bits & CPER_PCIE_VALID_DEVICE_ID &&
-	      pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO))
-		return;
-
-	aer_severity = cper_severity_to_aer(gdata->error_severity);
-	/* A component reset by firmware needs reinitialization. */
-	if (gdata->flags & CPER_SEC_RESET)
-		aer_severity = AER_FATAL;
-
-	aer_cap_regs_unpack(&aer_regs, pcie_err->aer_info, sizeof(pcie_err->aer_info));
-
-	domain = pcie_err->device_id.segment;
-	bus = pcie_err->device_id.bus;
-	devfn = PCI_DEVFN(pcie_err->device_id.device,
-			  pcie_err->device_id.function);
-	aer_recover_queue(domain, bus, devfn, aer_severity, &aer_regs);
-#endif
-}
-
 static int extlog_print(struct notifier_block *nb, unsigned long val,
 			void *data)
 {
@@ -155,11 +112,6 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 	int	bank = mce->bank;
 	int	cpu = mce->extcpu;
 	struct acpi_hest_generic_status *estatus, *tmp;
-	struct acpi_hest_generic_data *gdata;
-	const guid_t *fru_id;
-	char *fru_text;
-	guid_t *sec_type;
-	static u32 err_seq;
 
 	estatus = extlog_elog_entry_check(cpu, bank);
 	if (!estatus)
@@ -189,47 +141,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 	if (tmp->error_severity == CPER_SEV_FATAL)
 		print_extlog_rcd(tmp, cpu);
 
-	/* log event via trace */
-	err_seq++;
-	apei_estatus_for_each_section(tmp, gdata) {
-		if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
-			fru_id = (guid_t *)gdata->fru_id;
-		else
-			fru_id = &guid_null;
-		if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
-			fru_text = gdata->fru_text;
-		else
-			fru_text = "";
-		sec_type = (guid_t *)gdata->section_type;
-		if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
-			struct cper_sec_mem_err *mem = acpi_hest_get_payload(gdata);
-
-			if (gdata->error_data_length >= sizeof(*mem))
-				trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,
-						       (u8)gdata->error_severity);
-		} else if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM2)) {
-			struct cper_sec_mem_err2 *mem = acpi_hest_get_payload(gdata);
-
-			if (gdata->error_data_length >= sizeof(*mem))
-				trace_extlog_mem2_event(mem, err_seq, fru_id, fru_text,
-							(u8)gdata->error_severity);
-		} 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_PCIE)) {
-			extlog_print_pcie(gdata);
-		} else {
-			void *err = acpi_hest_get_payload(gdata);
-
-			log_non_standard_event(sec_type, fru_id, fru_text,
-					       gdata->error_severity, err,
-					       gdata->error_data_length);
-		}
-	}
+	acpi_extlog_report(tmp);
 
 	mce->kflags |= MCE_HANDLED_EXTLOG;
 	return NOTIFY_OK;
diff --git a/drivers/acpi/apei/Makefile b/drivers/acpi/apei/Makefile
index 66588d6be56fe..6e83cd110db9a 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 extlog.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/apei-internal.h b/drivers/acpi/apei/apei-internal.h
index 77c10a7a7a9f4..a7c70adf91478 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -9,6 +9,8 @@
 
 #include <linux/acpi.h>
 
+void acpi_extlog_report(const struct acpi_hest_generic_status *estatus);
+
 struct apei_exec_context;
 
 typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
diff --git a/drivers/acpi/apei/extlog.c b/drivers/acpi/apei/extlog.c
new file mode 100644
index 0000000000000..8eef33a4326a7
--- /dev/null
+++ b/drivers/acpi/apei/extlog.c
@@ -0,0 +1,171 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Common CPER section reporting.
+ *
+ * Copyright (C) 2013 Intel Corp.
+ * Author: Chen, Gong <gong.chen@intel.com>
+ */
+
+#include <linux/acpi.h>
+#include <linux/aer.h>
+#include <linux/cper.h>
+#include <linux/export.h>
+#include <linux/pci.h>
+#include <linux/ratelimit.h>
+#include <linux/ras.h>
+#include <cxl/event.h>
+#include <acpi/ghes.h>
+#include <ras/ras_event.h>
+
+#include "apei-internal.h"
+
+static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
+{
+#ifdef CONFIG_ACPI_APEI_PCIEAER
+	struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
+	struct aer_capability_regs aer_regs = {};
+	unsigned int devfn;
+	unsigned int bus;
+	int aer_severity;
+	int domain;
+
+	if (gdata->error_data_length < sizeof(*pcie_err)) {
+		pr_warn_ratelimited(FW_WARN
+				    "PCIe error section too small (%u)\n",
+				    gdata->error_data_length);
+		return;
+	}
+
+	if (!(pcie_err->validation_bits & CPER_PCIE_VALID_DEVICE_ID &&
+	      pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO))
+		return;
+
+	aer_severity = cper_severity_to_aer(gdata->error_severity);
+	/* A component reset by firmware needs reinitialization. */
+	if (gdata->flags & CPER_SEC_RESET)
+		aer_severity = AER_FATAL;
+
+	aer_cap_regs_unpack(&aer_regs, pcie_err->aer_info, sizeof(pcie_err->aer_info));
+
+	domain = pcie_err->device_id.segment;
+	bus = pcie_err->device_id.bus;
+	devfn = PCI_DEVFN(pcie_err->device_id.device,
+			  pcie_err->device_id.function);
+	aer_recover_queue(domain, bus, devfn, aer_severity, &aer_regs);
+#endif
+}
+
+/**
+ * acpi_extlog_mem_error - trace a validated CPER memory section
+ * @gdata: section header followed by its payload
+ * @err_seq: sequence number shared by sections in the same error record
+ *
+ * The caller must validate the payload length, including any optional fields
+ * claimed by the memory validation bits, before calling this function.
+ */
+static void acpi_extlog_mem_error(struct acpi_hest_generic_data *gdata, u32 err_seq)
+{
+#ifdef CONFIG_RAS
+	struct cper_sec_mem_err *mem = acpi_hest_get_payload(gdata);
+	const guid_t *fru_id;
+	const char *fru_text;
+
+	if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
+		fru_id = (guid_t *)gdata->fru_id;
+	else
+		fru_id = &guid_null;
+	if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
+		fru_text = gdata->fru_text;
+	else
+		fru_text = "";
+
+	trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,
+			       (u8)gdata->error_severity);
+#endif
+}
+
+/**
+ * acpi_extlog_mem2_error - trace a validated CPER memory section 2
+ * @gdata: section header followed by its payload
+ * @err_seq: sequence number shared by sections in the same error record
+ *
+ * The caller must validate the payload length before calling this function.
+ */
+static void acpi_extlog_mem2_error(struct acpi_hest_generic_data *gdata, u32 err_seq)
+{
+#ifdef CONFIG_RAS
+	struct cper_sec_mem_err2 *mem = acpi_hest_get_payload(gdata);
+	const guid_t *fru_id;
+	const char *fru_text;
+
+	if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
+		fru_id = (guid_t *)gdata->fru_id;
+	else
+		fru_id = &guid_null;
+	if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
+		fru_text = gdata->fru_text;
+	else
+		fru_text = "";
+
+	trace_extlog_mem2_event(mem, err_seq, fru_id, fru_text,
+				(u8)gdata->error_severity);
+#endif
+}
+
+/**
+ * acpi_extlog_report - report sections of a validated generic error status block
+ * @estatus: caller-owned status block, already checked by cper_estatus_check()
+ *
+ * The caller handles console output and firmware acknowledgment. Section
+ * processing, including PCIe recovery, does not depend on RAS consumers.
+ */
+void acpi_extlog_report(const struct acpi_hest_generic_status *estatus)
+{
+	static atomic_t seqno = ATOMIC_INIT(0);
+	struct acpi_hest_generic_data *gdata;
+	const guid_t *fru_id;
+	const char *fru_text;
+	guid_t *sec_type;
+	u32 err_seq;
+
+	/* log event via trace */
+	err_seq = atomic_inc_return(&seqno);
+	apei_estatus_for_each_section(estatus, gdata) {
+		if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
+			fru_id = (guid_t *)gdata->fru_id;
+		else
+			fru_id = &guid_null;
+		if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
+			fru_text = gdata->fru_text;
+		else
+			fru_text = "";
+		sec_type = (guid_t *)gdata->section_type;
+		if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
+			struct cper_sec_mem_err *mem = acpi_hest_get_payload(gdata);
+
+			if (gdata->error_data_length >= sizeof(*mem))
+				acpi_extlog_mem_error(gdata, err_seq);
+		} else if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM2)) {
+			struct cper_sec_mem_err2 *mem = acpi_hest_get_payload(gdata);
+
+			if (gdata->error_data_length >= sizeof(*mem))
+				acpi_extlog_mem2_error(gdata, err_seq);
+		} 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_PCIE)) {
+			extlog_print_pcie(gdata);
+		} else {
+			void *err = acpi_hest_get_payload(gdata);
+
+			log_non_standard_event(sec_type, fru_id, fru_text,
+					       gdata->error_severity, err,
+					       gdata->error_data_length);
+		}
+	}
+}
+EXPORT_SYMBOL_FOR_MODULES(acpi_extlog_report, "acpi_extlog");
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 3aecd3f828e58..49d40af791bbb 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -779,7 +779,6 @@ void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
 	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)
 {
diff --git a/drivers/ras/ras.c b/drivers/ras/ras.c
index c6b14202a5e92..0ac774a500176 100644
--- a/drivers/ras/ras.c
+++ b/drivers/ras/ras.c
@@ -109,7 +109,7 @@ static int __init ras_init(void)
 }
 subsys_initcall(ras_init);
 
-#if defined(CONFIG_ACPI_EXTLOG) || defined(CONFIG_ACPI_EXTLOG_MODULE)
+#ifdef CONFIG_ACPI_APEI_GHES
 EXPORT_TRACEPOINT_SYMBOL_GPL(extlog_mem_event);
 EXPORT_TRACEPOINT_SYMBOL_GPL(extlog_mem2_event);
 #endif
diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
index 069c7b3a5e6c0..8df7fb349612a 100644
--- a/include/ras/ras_event.h
+++ b/include/ras/ras_event.h
@@ -14,7 +14,7 @@
 #include <linux/cper.h>
 
 /*
- * MCE Extended Error Log trace event
+ * CPER memory events from MCE Extended Error Log and GHES.
  *
  * These events are generated when hardware detects a corrected or
  * uncorrected event.
@@ -22,7 +22,7 @@
 
 /* memory trace event */
 
-#if defined(CONFIG_ACPI_EXTLOG) || defined(CONFIG_ACPI_EXTLOG_MODULE)
+#ifdef CONFIG_ACPI_APEI_GHES
 TRACE_EVENT(extlog_mem_event,
 	TP_PROTO(struct cper_sec_mem_err *mem,
 		 u32 err_seq,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 13/19] ACPI: APEI: Share helpers with the common CPER reporter
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (11 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 12/19] ACPI: extlog: Extract CPER reporting from acpi_extlog Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 14/19] ACPI: APEI: Return status from cxl_cper_post_event() Pierre Gondois
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Qiuxu Zhuo, Avadhut Naik,
	Jonathan Cameron, Kai-Heng Feng, Fabio M. De Francesco,
	Dave Jiang, Breno Leitao, Terry Bowman, Dan Williams, linux-acpi,
	linux-edac, linuxppc-dev, linux-pci, acpica-devel

Prepare a following patch by renaming/exporting some ghes internal
functions to extlog.c. Namely:
- Rename ghes_mem_err_min_len() to acpi_extlog_mem_err_min_len()
- cxl_cper_post_event() ghes_severity() are not static anymore.

No functional change intended.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/apei/apei-internal.h |  5 +++++
 drivers/acpi/apei/extlog.c        | 22 ++++++++++++++++++++++
 drivers/acpi/apei/ghes.c          | 31 ++++---------------------------
 3 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
index a7c70adf91478..f7f0ab8e5ed7f 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -8,7 +8,12 @@
 #define APEI_INTERNAL_H
 
 #include <linux/acpi.h>
+#include <cxl/event.h>
 
+int ghes_severity(int severity);
+void cxl_cper_post_event(enum cxl_event_type event_type,
+			 struct cxl_cper_event_rec *rec, u32 len);
+u32 acpi_extlog_mem_err_min_len(u64 validation_bits);
 void acpi_extlog_report(const struct acpi_hest_generic_status *estatus);
 
 struct apei_exec_context;
diff --git a/drivers/acpi/apei/extlog.c b/drivers/acpi/apei/extlog.c
index 8eef33a4326a7..8d9b91a764902 100644
--- a/drivers/acpi/apei/extlog.c
+++ b/drivers/acpi/apei/extlog.c
@@ -55,6 +55,28 @@ static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
 #endif
 }
 
+/*
+ * 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.
+ */
+u32 acpi_extlog_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;
+}
+
 /**
  * acpi_extlog_mem_error - trace a validated CPER memory section
  * @gdata: section header followed by its payload
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 49d40af791bbb..b51b621208ed1 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -52,7 +52,6 @@
 #include <acpi/apei.h>
 #include <asm/fixmap.h>
 #include <asm/tlbflush.h>
-#include <cxl/event.h>
 #include <ras/ras_event.h>
 
 #include "apei-internal.h"
@@ -308,7 +307,7 @@ static void ghes_fini(struct ghes *ghes)
 		unmap_gen_v2(ghes);
 }
 
-static inline int ghes_severity(int severity)
+int ghes_severity(int severity)
 {
 	switch (severity) {
 	case CPER_SEV_INFORMATIONAL:
@@ -824,8 +823,8 @@ DEFINE_KFIFO(cxl_cper_fifo, struct cxl_cper_work_data, CXL_CPER_FIFO_DEPTH);
 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)
+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;
 
@@ -931,28 +930,6 @@ static void ghes_log_hwerr(int sev, guid_t *sec_type)
 	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)
 {
@@ -994,7 +971,7 @@ static void ghes_do_proc(struct ghes *ghes,
 
 			/* Then require what the claimed fields actually need. */
 			if (gdata->error_data_length <
-			    ghes_mem_err_min_len(mem_err->validation_bits)) {
+			    acpi_extlog_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);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 14/19] ACPI: APEI: Return status from cxl_cper_post_event()
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (12 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 13/19] ACPI: APEI: Share helpers with the common CPER reporter Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 15/19] ACPI: APEI: Extend common CPER reporting for GHES section types Pierre Gondois
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Radu Rendec, Avadhut Naik,
	Jonathan Cameron, Fabio M. De Francesco, Kai-Heng Feng,
	Dave Jiang, Breno Leitao, Terry Bowman, Dan Williams,
	Kuppuswamy Sathyanarayanan, linux-acpi, linux-edac, linuxppc-dev,
	linux-pci, acpica-devel

Callers cannot tell whether cxl_cper_post_event() queued a CPER event or
discarded it. Return 0 if success and 1 if aborted. Existing callers
continue to ignore the result for now.

A worker that is already scheduled still processes the queued event, so
its schedule_work() return value does not indicate a delivery failure.

This prepares for a following patch moving PCI/CXL handling to
extlog.c.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/apei/apei-internal.h |  4 ++--
 drivers/acpi/apei/ghes.c          | 15 ++++++++-------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
index f7f0ab8e5ed7f..5063c743b4cf0 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -11,8 +11,8 @@
 #include <cxl/event.h>
 
 int ghes_severity(int severity);
-void cxl_cper_post_event(enum cxl_event_type event_type,
-			 struct cxl_cper_event_rec *rec, u32 len);
+int cxl_cper_post_event(enum cxl_event_type event_type,
+			struct cxl_cper_event_rec *rec, u32 len);
 u32 acpi_extlog_mem_err_min_len(u64 validation_bits);
 void acpi_extlog_report(const struct acpi_hest_generic_status *estatus);
 
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index b51b621208ed1..623ac2a7f7a75 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -823,42 +823,43 @@ DEFINE_KFIFO(cxl_cper_fifo, struct cxl_cper_work_data, CXL_CPER_FIFO_DEPTH);
 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)
+int 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;
+		return 1;
 	}
 
 	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;
+		return 1;
 	}
 
 	if (!(rec->hdr.validation_bits & CPER_CXL_COMP_EVENT_LOG_VALID)) {
 		pr_err(FW_WARN "CXL CPER invalid event\n");
-		return;
+		return 1;
 	}
 
 	guard(raw_spinlock_irqsave)(&cxl_cper_work_lock);
 
 	if (!cxl_cper_work)
-		return;
+		return 1;
 
 	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;
+		return 1;
 	}
 
 	schedule_work(cxl_cper_work);
+	return 0;
 }
 
 int cxl_cper_register_work(struct work_struct *work)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 15/19] ACPI: APEI: Extend common CPER reporting for GHES section types
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (13 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 14/19] ACPI: APEI: Return status from cxl_cper_post_event() Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 16/19] ACPI: extlog: Report error severity using GHES bindings in MCE Pierre Gondois
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Qiuxu Zhuo, Radu Rendec,
	Avadhut Naik, Jonathan Cameron, Fabio M. De Francesco,
	Kai-Heng Feng, Dave Jiang, Breno Leitao, Dan Williams,
	Kuppuswamy Sathyanarayanan, Terry Bowman, linux-acpi, linux-edac,
	linuxppc-dev, linux-pci, acpica-devel

Add ARM processor tracing and CXL media delivery to acpi_extlog_report()
to prepare for GHES reuse. Trace CXL records as nonstandard events when
validation or queueing fails, preserving their payload and FRU metadata.

Reuse acpi_extlog_mem_err_min_len() to accept legacy 73-byte memory
sections while rejecting records with missing fields marked valid.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/apei/extlog.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/apei/extlog.c b/drivers/acpi/apei/extlog.c
index 8d9b91a764902..8cae5bdacf1c6 100644
--- a/drivers/acpi/apei/extlog.c
+++ b/drivers/acpi/apei/extlog.c
@@ -153,6 +153,8 @@ void acpi_extlog_report(const struct acpi_hest_generic_status *estatus)
 	/* log event via trace */
 	err_seq = atomic_inc_return(&seqno);
 	apei_estatus_for_each_section(estatus, gdata) {
+		int fallback_log = 0;
+
 		if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
 			fru_id = (guid_t *)gdata->fru_id;
 		else
@@ -165,8 +167,13 @@ void acpi_extlog_report(const struct acpi_hest_generic_status *estatus)
 		if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
 			struct cper_sec_mem_err *mem = acpi_hest_get_payload(gdata);
 
-			if (gdata->error_data_length >= sizeof(*mem))
-				acpi_extlog_mem_error(gdata, err_seq);
+			if (gdata->error_data_length <
+			    sizeof(struct cper_sec_mem_err_old))
+				continue;
+			if (gdata->error_data_length <
+			    acpi_extlog_mem_err_min_len(mem->validation_bits))
+				continue;
+			acpi_extlog_mem_error(gdata, err_seq);
 		} else if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM2)) {
 			struct cper_sec_mem_err2 *mem = acpi_hest_get_payload(gdata);
 
@@ -181,7 +188,31 @@ void acpi_extlog_report(const struct acpi_hest_generic_status *estatus)
 					       gdata->error_data_length);
 		} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
 			extlog_print_pcie(gdata);
+		} else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) {
+			struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata);
+
+			if (gdata->error_data_length >= sizeof(*err))
+				log_arm_hw_error(err, ghes_severity(gdata->error_severity));
+		} else if (guid_equal(sec_type, &CPER_SEC_CXL_GEN_MEDIA_GUID)) {
+			struct cxl_cper_event_rec *rec = acpi_hest_get_payload(gdata);
+
+			fallback_log = 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);
+
+			fallback_log = 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);
+
+			fallback_log = cxl_cper_post_event(CXL_CPER_EVENT_MEM_MODULE, rec,
+							   gdata->error_data_length);
 		} else {
+			fallback_log = 1;
+		}
+
+		if (fallback_log) {
 			void *err = acpi_hest_get_payload(gdata);
 
 			log_non_standard_event(sec_type, fru_id, fru_text,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 16/19] ACPI: extlog: Report error severity using GHES bindings in MCE
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (14 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 15/19] ACPI: APEI: Extend common CPER reporting for GHES section types Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 17/19] ACPI: APEI: Share the extlog PCIe handler with GHES Pierre Gondois
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Radu Rendec, Avadhut Naik,
	Jonathan Cameron, Kai-Heng Feng, Fabio M. De Francesco,
	Dave Jiang, Breno Leitao, Dan Williams, Terry Bowman, linux-acpi,
	linux-edac, linuxppc-dev, linux-pci, acpica-devel

MCE extended logs report raw CPER severity values to
log_non_standard_event(). GHES relies on the GHES bindings in
ghes_do_proc(). The rasdaemon interprets the severity
as a GHES_SEV_* value.

Translate the CPER severity with ghes_severity() before reporting
the event.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/apei/extlog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/apei/extlog.c b/drivers/acpi/apei/extlog.c
index 8cae5bdacf1c6..bd407436928b4 100644
--- a/drivers/acpi/apei/extlog.c
+++ b/drivers/acpi/apei/extlog.c
@@ -216,7 +216,7 @@ void acpi_extlog_report(const struct acpi_hest_generic_status *estatus)
 			void *err = acpi_hest_get_payload(gdata);
 
 			log_non_standard_event(sec_type, fru_id, fru_text,
-					       gdata->error_severity, err,
+					       ghes_severity(gdata->error_severity), err,
 					       gdata->error_data_length);
 		}
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 17/19] ACPI: APEI: Share the extlog PCIe handler with GHES
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (15 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 16/19] ACPI: extlog: Report error severity using GHES bindings in MCE Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 18/19] ACPI: APEI: Route GHES section reporting through extlog Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 19/19] PCI/ERR: Avoid NULL bridge pointer Pierre Gondois
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Radu Rendec, Avadhut Naik,
	Jonathan Cameron, Dave Jiang, Fabio M. De Francesco,
	Kai-Heng Feng, Breno Leitao, Dan Williams, Terry Bowman,
	linux-acpi, linux-edac, linuxppc-dev, linux-pci, acpica-devel

Remove ghes_handle_aer() and re-use the existing extlog_print_pcie()
to have a common PCIe logging handler. Update the function
documentation.

Except for the warning ("PCIe error section too small"),
no functional change intended.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/apei/apei-internal.h |  1 +
 drivers/acpi/apei/extlog.c        | 14 +++++++-
 drivers/acpi/apei/ghes.c          | 54 ++-----------------------------
 3 files changed, 16 insertions(+), 53 deletions(-)

diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
index 5063c743b4cf0..22a33a21017a3 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -14,6 +14,7 @@ int ghes_severity(int severity);
 int cxl_cper_post_event(enum cxl_event_type event_type,
 			struct cxl_cper_event_rec *rec, u32 len);
 u32 acpi_extlog_mem_err_min_len(u64 validation_bits);
+void extlog_print_pcie(struct acpi_hest_generic_data *gdata);
 void acpi_extlog_report(const struct acpi_hest_generic_status *estatus);
 
 struct apei_exec_context;
diff --git a/drivers/acpi/apei/extlog.c b/drivers/acpi/apei/extlog.c
index bd407436928b4..42ba8ba13804f 100644
--- a/drivers/acpi/apei/extlog.c
+++ b/drivers/acpi/apei/extlog.c
@@ -19,7 +19,19 @@
 
 #include "apei-internal.h"
 
-static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
+/*
+ * PCIe AER errors need to be sent to the AER driver for reporting and
+ * recovery. The CPER severities map to the following AER severities and
+ * require the following handling:
+ *
+ * CPER_SEV_CORRECTED or CPER_SEV_INFORMATIONAL -> AER_CORRECTABLE
+ *     These need to be reported by the AER driver but no recovery is
+ *     necessary.
+ * CPER_SEV_RECOVERABLE -> AER_NONFATAL
+ * CPER_SEV_FATAL or CPER_SEC_RESET -> AER_FATAL
+ *     These both need to be reported and recovered from by the AER driver.
+ */
+void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
 {
 #ifdef CONFIG_ACPI_APEI_PCIEAER
 	struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 623ac2a7f7a75..7d2864fa14503 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -18,6 +18,7 @@
  */
 
 #include <linux/arm_sdei.h>
+#include <linux/atomic.h>
 #include <linux/kernel.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
@@ -37,9 +38,7 @@
 #include <linux/llist.h>
 #include <linux/genalloc.h>
 #include <linux/kfifo.h>
-#include <linux/pci.h>
 #include <linux/pfn.h>
-#include <linux/aer.h>
 #include <linux/nmi.h>
 #include <linux/sched/clock.h>
 #include <linux/uuid.h>
@@ -627,55 +626,6 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
 	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_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 BLOCKING_NOTIFIER_HEAD(vendor_record_notify_list);
 
 int ghes_register_vendor_record_notifier(struct notifier_block *nb)
@@ -995,7 +945,7 @@ static void ghes_do_proc(struct ghes *ghes,
 			arch_apei_report_mem_error2(sev, mem_err);
 			queued |= ghes_handle_memory_failure2(gdata, sev, sync);
 		} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
-			ghes_handle_aer(gdata);
+			extlog_print_pcie(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)) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 18/19] ACPI: APEI: Route GHES section reporting through extlog
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (16 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 17/19] ACPI: APEI: Share the extlog PCIe handler with GHES Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:10 ` [PATCH v1 19/19] PCI/ERR: Avoid NULL bridge pointer Pierre Gondois
  18 siblings, 0 replies; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Radu Rendec, Avadhut Naik,
	Jonathan Cameron, Kai-Heng Feng, Dave Jiang,
	Fabio M. De Francesco, Breno Leitao, Dan Williams, Terry Bowman,
	Kuppuswamy Sathyanarayanan, linux-acpi, linux-edac, linuxppc-dev,
	linux-pci, acpica-devel

Use acpi_extlog_report() for GHES section reporting and remove the
duplicate dispatch code.

GHES memory sections now emit extlog trace events independently of EDAC
registration, using the CPER section severity and one sequence number
per status block. CXL events that cannot be queued fall back to the
nonstandard trace event.

Report all sections before running the remaining GHES handlers. Keep
memory recovery, SIGBUS handling and notifier calls in GHES.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/apei/apei-internal.h |  1 -
 drivers/acpi/apei/extlog.c        |  2 +-
 drivers/acpi/apei/ghes.c          | 57 +++++++------------------------
 3 files changed, 13 insertions(+), 47 deletions(-)

diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
index 22a33a21017a3..5063c743b4cf0 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -14,7 +14,6 @@ int ghes_severity(int severity);
 int cxl_cper_post_event(enum cxl_event_type event_type,
 			struct cxl_cper_event_rec *rec, u32 len);
 u32 acpi_extlog_mem_err_min_len(u64 validation_bits);
-void extlog_print_pcie(struct acpi_hest_generic_data *gdata);
 void acpi_extlog_report(const struct acpi_hest_generic_status *estatus);
 
 struct apei_exec_context;
diff --git a/drivers/acpi/apei/extlog.c b/drivers/acpi/apei/extlog.c
index 42ba8ba13804f..d1677d299e389 100644
--- a/drivers/acpi/apei/extlog.c
+++ b/drivers/acpi/apei/extlog.c
@@ -31,7 +31,7 @@
  * CPER_SEV_FATAL or CPER_SEC_RESET -> AER_FATAL
  *     These both need to be reported and recovered from by the AER driver.
  */
-void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
+static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
 {
 #ifdef CONFIG_ACPI_APEI_PCIEAER
 	struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 7d2864fa14503..221f0a81c94f6 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -566,9 +566,7 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
 	char *p;
 
 	sec_sev = ghes_severity(gdata->error_severity);
-	if (length >= sizeof(*err)) {
-		log_arm_hw_error(err, sec_sev);
-	} else {
+	if (length < sizeof(*err)) {
 		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");
@@ -884,34 +882,23 @@ static void ghes_log_hwerr(int sev, guid_t *sec_type)
 static void ghes_do_proc(struct ghes *ghes,
 			 const struct acpi_hest_generic_status *estatus)
 {
-	int sev, sec_sev;
+	int sev;
 	struct acpi_hest_generic_data *gdata;
 	guid_t *sec_type;
-	const guid_t *fru_id;
-	const char *fru_text;
 	bool queued = false;
 	bool sync = is_hest_sync_notify(ghes);
 
+	acpi_extlog_report(estatus);
+
 	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);
-		if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
-			fru_id = (guid_t *)gdata->fru_id;
-		else
-			fru_id = &guid_null;
-
-		if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
-			fru_text = gdata->fru_text;
-		else
-			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
+			 * Check once for all 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.
@@ -944,37 +931,17 @@ static void ghes_do_proc(struct ghes *ghes,
 			atomic_notifier_call_chain(&ghes_report_mem2_chain, sev, mem_err);
 			arch_apei_report_mem_error2(sev, mem_err);
 			queued |= ghes_handle_memory_failure2(gdata, sev, sync);
-		} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
-			extlog_print_pcie(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 if (guid_equal(sec_type, &CPER_SEC_PCIE) ||
+			   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)) {
+			/* Reporting and subsystem delivery are handled by extlog. */
+			continue;
 		} 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);
 		}
 	}
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v1 19/19] PCI/ERR: Avoid NULL bridge pointer
  2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
                   ` (17 preceding siblings ...)
  2026-11-17 11:10 ` [PATCH v1 18/19] ACPI: APEI: Route GHES section reporting through extlog Pierre Gondois
@ 2026-11-17 11:10 ` Pierre Gondois
  2026-11-17 11:50   ` Lukas Wunner
  18 siblings, 1 reply; 22+ messages in thread
From: Pierre Gondois @ 2026-11-17 11:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ashok Raj, James Morse, Mark Brown, Pierre Gondois,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, Tony Luck,
	Hanjun Guo, Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Qiuxu Zhuo, Avadhut Naik,
	Radu Rendec, Jonathan Cameron, Dave Jiang, Kai-Heng Feng,
	Fabio M. De Francesco, Breno Leitao, Terry Bowman,
	Kuppuswamy Sathyanarayanan, linux-acpi, linux-edac, linuxppc-dev,
	linux-pci, acpica-devel

Return PCI_ERS_RESULT_DISCONNECT when no upstream bridge is available,
avoiding a NULL pointer dereference in pci_walk_bridge().

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/pci/pcie/err.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 1a7fc71c79d8a..402dc74c7fe49 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -233,6 +233,11 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
 	else
 		bridge = pci_upstream_bridge(dev);
 
+	if (!bridge) {
+		pci_warn(dev, "no upstream bridge\n");
+		return PCI_ERS_RESULT_DISCONNECT;
+	}
+
 	pci_walk_bridge(bridge, pci_pm_runtime_get_sync, NULL);
 
 	pci_dbg(bridge, "broadcast error_detected message\n");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 05/19] PCI/AER: Embed aer_capability_regs copy in struct aer_recover_entry
  2026-11-17 11:10 ` [PATCH v1 05/19] PCI/AER: Embed aer_capability_regs copy in struct aer_recover_entry Pierre Gondois
@ 2026-11-17 11:44   ` Lukas Wunner
  0 siblings, 0 replies; 22+ messages in thread
From: Lukas Wunner @ 2026-11-17 11:44 UTC (permalink / raw)
  To: Pierre Gondois
  Cc: linux-kernel, Ashok Raj, James Morse, Mark Brown, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Rafael J. Wysocki, Len Brown, Tony Luck, Hanjun Guo,
	Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Avadhut Naik, Jonathan Cameron,
	Kai-Heng Feng, Fabio M. De Francesco, Dave Jiang, Breno Leitao,
	Terry Bowman, Dan Williams, linux-acpi, linux-edac, linuxppc-dev,
	linux-pci, acpica-devel

On Tue, Nov 17, 2026 at 12:10:15PM +0100, Pierre Gondois wrote:
> commit e2abc47a5a1a ("ACPI: APEI: Fix AER info corruption when error
> status data has multiple sections") passed to aer_recover_queue() a
> newly allocated copy of pcie_err->aer_info instead of providing a
> pointer to the ghes struct. This prevented corruptions of the ghes
> record (in case the ghes record was re-used for a new error before
> the previous error was logged).

Since commit eddba19b8b5f ("PCI/AER: Support Advisory Non-Fatal Errors"),
aer_regs is modified for a recursive invocation of __pci_print_aer().
The copy is necessary because we don't want to modify a buffer owned by
platform firmware.

> +++ b/drivers/pci/pcie/aer.c
> @@ -1352,7 +1352,7 @@ struct aer_recover_entry {
>  	u8	devfn;
>  	u16	domain;
>  	int	severity;
> -	struct aer_capability_regs *regs;
> +	struct aer_capability_regs regs;
>  };

This increases stack usage significantly in aer_recover_queue(),
which is not good.  A kzalloc() allocation may be better suited
for such a large struct, instead of relying on the stack.

> @@ -1374,24 +1374,14 @@ static void aer_recover_work_func(struct work_struct *work)
>  					   PCI_SLOT(entry.devfn),
>  					   PCI_FUNC(entry.devfn));
>  		else
> -			pci_print_aer(pdev, entry.severity, entry.regs);
> +			pci_print_aer(pdev, entry.severity, &entry.regs);
>  
> -		regs = entry.regs;
> +		regs = &entry.regs;
>  		if (entry.severity == AER_CORRECTABLE)
>  			err = regs->cor_status & ~regs->cor_mask;
>  		else
>  			err = regs->uncor_status & ~regs->uncor_mask;
>  
> -		/*
> -		 * Memory for aer_capability_regs(entry.regs) is being
> -		 * allocated from the ghes_estatus_pool to protect it from
> -		 * overwriting when multiple sections are present in the
> -		 * error status. Thus free the same after processing the
> -		 * data.
> -		 */
> -		ghes_estatus_pool_region_free((unsigned long)entry.regs,
> -					    sizeof(struct aer_capability_regs));
> -

So you're removing the call to ghes_estatus_pool_region_free() from the
worker...

> @@ -1441,17 +1431,18 @@ void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
>  		.devfn		= devfn,
>  		.domain		= domain,
>  		.severity	= severity,
> -		.regs		= aer_regs,
> +		.regs		= *aer_regs,
>  	};
>  
> +	ghes_estatus_pool_region_free((unsigned long)aer_regs,
> +				      sizeof(struct aer_capability_regs));
> +

... and instead call it earlier, before even launching the worker.
So where's the benefit?  You've traded less memory usage in the
pool for higher stack usage.  How is that useful?

Thanks,

Lukas

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v1 19/19] PCI/ERR: Avoid NULL bridge pointer
  2026-11-17 11:10 ` [PATCH v1 19/19] PCI/ERR: Avoid NULL bridge pointer Pierre Gondois
@ 2026-11-17 11:50   ` Lukas Wunner
  0 siblings, 0 replies; 22+ messages in thread
From: Lukas Wunner @ 2026-11-17 11:50 UTC (permalink / raw)
  To: Pierre Gondois
  Cc: linux-kernel, Ashok Raj, James Morse, Mark Brown, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Rafael J. Wysocki, Len Brown, Tony Luck, Hanjun Guo,
	Mauro Carvalho Chehab, Shuai Xue, Mahesh J Salgaonkar,
	Oliver O'Halloran, Bjorn Helgaas, Maciej Wieczor-Retman,
	Pawel Chmielewski, Yazen Ghannam, Qiuxu Zhuo, Avadhut Naik,
	Radu Rendec, Jonathan Cameron, Dave Jiang, Kai-Heng Feng,
	Fabio M. De Francesco, Breno Leitao, Terry Bowman,
	Kuppuswamy Sathyanarayanan, linux-acpi, linux-edac, linuxppc-dev,
	linux-pci, acpica-devel

On Tue, Nov 17, 2026 at 12:10:29PM +0100, Pierre Gondois wrote:
> Return PCI_ERS_RESULT_DISCONNECT when no upstream bridge is available,
> avoiding a NULL pointer dereference in pci_walk_bridge().

How can that happen?  If it can happen (which I doubt), why isn't this
patch tagged for stable?

Why is it at the end of this series?  Does the series somehow make it
possible that there's no upstream bridge?  Which patch does that?
If the preceding patches are not the cause of a potential NULL
pointer deref, why isn't this patch submitted separately from the series?

Thanks,

Lukas

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2026-11-17 11:50 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 11:10 [PATCH v1 00/19] ACPI: APEI: Share CPER reporting between GHES and extlog Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 01/19] x86/APEI: Extract common CPER memory error reporting helper Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 02/19] x86/APEI: Report Memory Error Section 2 through MCE Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 03/19] ras: Bound CPER FRU strings in trace events Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 04/19] ACPI: APEI: Use empty FRU values if valid bit is absent Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 05/19] PCI/AER: Embed aer_capability_regs copy in struct aer_recover_entry Pierre Gondois
2026-11-17 11:44   ` Lukas Wunner
2026-11-17 11:10 ` [PATCH v1 06/19] ACPI: APEI: Remove aer allocation in ghes_handle_aer() Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 07/19] ACPI: extlog: Provide HEST generic data to extlog_print_pcie() Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 08/19] ACPI: extlog: Align extlog_print_pcie() and ghes_handle_aer() Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 09/19] ACPI: extlog: Report errors independently of RAS consumers Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 10/19] ACPI: extlog: Simplify fatal record printing Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 11/19] RAS: Remove unused ras_userspace_consumers() Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 12/19] ACPI: extlog: Extract CPER reporting from acpi_extlog Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 13/19] ACPI: APEI: Share helpers with the common CPER reporter Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 14/19] ACPI: APEI: Return status from cxl_cper_post_event() Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 15/19] ACPI: APEI: Extend common CPER reporting for GHES section types Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 16/19] ACPI: extlog: Report error severity using GHES bindings in MCE Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 17/19] ACPI: APEI: Share the extlog PCIe handler with GHES Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 18/19] ACPI: APEI: Route GHES section reporting through extlog Pierre Gondois
2026-11-17 11:10 ` [PATCH v1 19/19] PCI/ERR: Avoid NULL bridge pointer Pierre Gondois
2026-11-17 11:50   ` Lukas Wunner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox