Skip to contentSkip to conversation

Make ELOG and GHES log and trace consistently

PATCH Superseded Fabio M. De Francesco 4 participants 15 messages Jun 3, 2025 – Jun 4, 2025

Subsystems (6)
ACPI PCI EDAC-core CXL +2 more subsystems

v3 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v3 cover Make ELOG and GHES log and trace consistently

When Firmware First is enabled, BIOS handles errors first and then it makes them available to the kernel via the Common Platform Error Record (CPER) sections (UEFI 2.10 Appendix N). Linux parses the CPER sections via one of two similar paths, either ELOG or GHES.

Currently, ELOG and GHES show some inconsistencies in how they print to the kernel log as well as in how they report to userspace via trace events.

Make the two mentioned paths act similarly for what relates to logging and tracing.

--- Changes for v3 ---

1/4, 2/4:
- collect tags; no functional changes
3/4:
- Invert logic of checks (Yazen)
- Select CONFIG_ACPI_APEI_PCIEAER (Yazen)
4/4:
- Check serial number only for CXL devices (Yazen)
- Replace "invalid" with "unknown" in the ouput of a pr_err() (Yazen)

--- Changes for v2 ---

- Add a patch to pass log levels to pci_print_aer() (Dan)
- Add a patch to trace CPER CXL Protocol Errors
- Rework commit messages (Dan)
- Use log_non_standard_event() (Bjorn)

--- Changes for v1 ---

- Drop the RFC prefix and restart from PATCH v1
- Drop patch 3/3 because a discussion on it has not yet been settled
- Drop namespacing in export of pci_print_aer while() (Dan)
- Don't use '#ifdef' in *.c files (Dan)
- Drop a reference on pdev after operation is complete (Dan)
- Don't log an error message if pdev is NULL (Dan)

--- Changes for RFC v2 ---

- 0/3: rework the subject line and the letter.
- 1/3: no changes.
- 2/3: trace CPER PCIe Section only if CONFIG_ACPI_APEI_PCIEAER is defined; the kernel test robot reported the use of two undefined symbols because the test for the config option was missing; rewrite the subject line and part of commit message.
- 3/3: no changes.

Fabio M. De Francesco (4):
ACPI: extlog: Trace CPER Non-standard Section Body PCI/AER: Modify pci_print_aer() to take log level
ACPI: extlog: Trace CPER PCI Express Error Section
ACPI: extlog: Trace CPER CXL Protocol Error Section

 drivers/acpi/Kconfig       |   1 +
 drivers/acpi/acpi_extlog.c | 102 +++++++++++++++++++++++++++++++++++++
 drivers/cxl/core/pci.c     |   2 +-
 drivers/cxl/core/ras.c     |   6 +++
 drivers/pci/pcie/aer.c     |  18 +++----
 drivers/ras/ras.c          |   1 +
 include/cxl/event.h        |   2 +
 include/linux/aer.h        |   8 ++-
 8 files changed, 128 insertions(+), 12 deletions(-)

10,448 lines not shown · raw message

Part of this message is not shown here. View the raw message.

#1 lore raw

PATCH v3 1/4 ACPI: extlog: Trace CPER Non-standard Section Body

ghes_do_proc() has a catch-all for unknown or unhandled CPER formats (UEFI v2.10 Appendix N 2.3), extlog_print() does not. This gap was noticed by a RAS test that injected CXL protocol errors which were notified to extlog_print() via the IOMCA (I/O Machine Check Architecture) mechanism. Bring parity to the extlog_print() path by including a similar log_non_standard_event().

---
 drivers/acpi/acpi_extlog.c | 6 ++++++
 drivers/ras/ras.c          | 1 +
 2 files changed, 7 insertions(+)
drivers/acpi/acpi_extlog.c +6 -0
index f6b9562779de0..47d11cb5c9120 100644
@@ -183,6 +183,12 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 			if (gdata->error_data_length >= sizeof(*mem))
 				trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,
 						       (u8)gdata->error_severity);
+		} 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);
 		}
 	}
 
drivers/ras/ras.c +1 -0
index a6e4792a1b2e9..ac0e132ccc3eb 100644
@@ -51,6 +51,7 @@ void log_non_standard_event(const guid_t *sec_type, const guid_t *fru_id,
 {
 	trace_non_standard_event(sec_type, fru_id, fru_text, sev, err, len);
 }
+EXPORT_SYMBOL_GPL(log_non_standard_event);
 
 void log_arm_hw_error(struct cper_sec_proc_arm *err)
 {
Signature · 1 line
2.49.0
maintainer Reviewed-by on v3 1/4
#2 lore raw

Re: [PATCH 1/4 v3] ACPI: extlog: Trace CPER Non-standard Section Body

Quoted 11 lines · Fabio M. De Francesco

ghes_do_proc() has a catch-all for unknown or unhandled CPER formats (UEFI v2.10 Appendix N 2.3), extlog_print() does not. This gap was noticed by a RAS test that injected CXL protocol errors which were notified to extlog_print() via the IOMCA (I/O Machine Check Architecture) mechanism. Bring parity to the extlog_print() path by including a similar log_non_standard_event().

Quoted 34 lines
---
 drivers/acpi/acpi_extlog.c | 6 ++++++
 drivers/ras/ras.c          | 1 +
 2 files changed, 7 insertions(+)
drivers/acpi/acpi_extlog.c +6 -0
index f6b9562779de0..47d11cb5c9120 100644
@@ -183,6 +183,12 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 			if (gdata->error_data_length >= sizeof(*mem))
 				trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,
 						       (u8)gdata->error_severity);
+		} 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);
 		}
 	}
 
drivers/ras/ras.c +1 -0
index a6e4792a1b2e9..ac0e132ccc3eb 100644
@@ -51,6 +51,7 @@ void log_non_standard_event(const guid_t *sec_type, const guid_t *fru_id,
 {
 	trace_non_standard_event(sec_type, fru_id, fru_text, sev, err, len);
 }
+EXPORT_SYMBOL_GPL(log_non_standard_event);
 
 void log_arm_hw_error(struct cper_sec_proc_arm *err)
 {
Reviewed-by on v3 1/4
#3 lore raw

RE: [PATCH 1/4 v3] ACPI: extlog: Trace CPER Non-standard Section Body

In reply to Fabio M. De Francesco
Quoted 11 lines

From: Fabio M. De Francesco <[email protected]> [...]
Subject: [PATCH 1/4 v3] ACPI: extlog: Trace CPER Non-standard Section Body

ghes_do_proc() has a catch-all for unknown or unhandled CPER formats (UEFI v2.10 Appendix N 2.3), extlog_print() does not. This gap was noticed by a RAS test that injected CXL protocol errors which were notified to extlog_print() via the IOMCA (I/O Machine Check
Architecture) mechanism. Bring parity to the extlog_print() path by including a similar log_non_standard_event().

Quoted 5 lines
Cc Dan Williams <[email protected]>
Signed-off-by Fabio M. De Francesco

<[email protected]>

#4 lore raw

PATCH v3 2/4 PCI/AER: Modify pci_print_aer() to take log level

In reply to Fabio M. De Francesco

Modify pci_print_aer() to take a printk() log level in preparation of a patch that logs PCIe Components and Link errors from ELOG.

---
 drivers/cxl/core/pci.c |  2 +-
 drivers/pci/pcie/aer.c | 16 ++++++++--------
 include/linux/aer.h    |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/cxl/core/pci.c +1 -1
index 3b80e9a76ba86..ad8d7939c2e1c 100644
@@ -885,7 +885,7 @@ static void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds)
 	if (!cxl_rch_get_aer_severity(&aer_regs, &severity))
 		return;
 
-	pci_print_aer(pdev, severity, &aer_regs);
+	pci_print_aer(KERN_ERR, pdev, severity, &aer_regs);
 
 	if (severity == AER_CORRECTABLE)
 		cxl_handle_rdport_cor_ras(cxlds, dport);
drivers/pci/pcie/aer.c +8 -8
index a1cf8c7ef628a..d0ebf7c15afa9 100644
@@ -760,7 +760,7 @@ int cper_severity_to_aer(int cper_severity)
 EXPORT_SYMBOL_GPL(cper_severity_to_aer);
 #endif
 
-void pci_print_aer(struct pci_dev *dev, int aer_severity,
+void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
 		   struct aer_capability_regs *aer)
 {
 	int layer, agent, tlp_header_valid = 0;
@@ -785,14 +785,15 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
 	info.mask = mask;
 	info.first_error = PCI_ERR_CAP_FEP(aer->cap_control);
 
-	pci_err(dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask);
+	pci_printk(level, dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n",
+		   status, mask);
 	__aer_print_error(dev, &info);
-	pci_err(dev, "aer_layer=%s, aer_agent=%s\n",
-		aer_error_layer[layer], aer_agent_string[agent]);
+	pci_printk(level, dev, "aer_layer=%s, aer_agent=%s\n",
+		   aer_error_layer[layer], aer_agent_string[agent]);
 
 	if (aer_severity != AER_CORRECTABLE)
-		pci_err(dev, "aer_uncor_severity: 0x%08x\n",
-			aer->uncor_severity);
+		pci_printk(level, dev, "aer_uncor_severity: 0x%08x\n",
+			   aer->uncor_severity);
 
 	if (tlp_header_valid)
 		pcie_print_tlp_log(dev, &aer->header_log, dev_fmt("  "));
@@ -1146,8 +1147,7 @@ static void aer_recover_work_func(struct work_struct *work)
 			       PCI_SLOT(entry.devfn), PCI_FUNC(entry.devfn));
 			continue;
 		}
-		pci_print_aer(pdev, entry.severity, entry.regs);
-
+		pci_print_aer(KERN_ERR, pdev, entry.severity, entry.regs);
 		/*
 		 * Memory for aer_capability_regs(entry.regs) is being
 		 * allocated from the ghes_estatus_pool to protect it from
include/linux/aer.h +2 -2
index 02940be66324e..45d0fb2e2e759 100644
@@ -64,8 +64,8 @@ static inline int pci_aer_clear_nonfatal_status(struct pci_dev *dev)
 static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; }
 #endif
 
-void pci_print_aer(struct pci_dev *dev, int aer_severity,
-		    struct aer_capability_regs *aer);
+void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
+		   struct aer_capability_regs *aer);
 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);
Signature · 1 line
2.49.0
#5 lore raw

Re: [PATCH 2/4 v3] PCI/AER: Modify pci_print_aer() to take log level

Quoted 2 lines · Fabio M. De Francesco

Modify pci_print_aer() to take a printk() log level in preparation of a patch that logs PCIe Components and Link errors from ELOG.

I think you need to rebase this patch on top of latest PCI changes. A patch to consolidate the AER error logging is pushed for v6.16 merge.

Quoted 80 lines
---
  drivers/cxl/core/pci.c |  2 +-
  drivers/pci/pcie/aer.c | 16 ++++++++--------
  include/linux/aer.h    |  4 ++--
  3 files changed, 11 insertions(+), 11 deletions(-)
drivers/cxl/core/pci.c +1 -1
index 3b80e9a76ba86..ad8d7939c2e1c 100644
@@ -885,7 +885,7 @@ static void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds)
  	if (!cxl_rch_get_aer_severity(&aer_regs, &severity))
  		return;
 
-	pci_print_aer(pdev, severity, &aer_regs);
+	pci_print_aer(KERN_ERR, pdev, severity, &aer_regs);
 
  	if (severity == AER_CORRECTABLE)
  		cxl_handle_rdport_cor_ras(cxlds, dport);
drivers/pci/pcie/aer.c +8 -8
index a1cf8c7ef628a..d0ebf7c15afa9 100644
@@ -760,7 +760,7 @@ int cper_severity_to_aer(int cper_severity)
  EXPORT_SYMBOL_GPL(cper_severity_to_aer);
  #endif
 
-void pci_print_aer(struct pci_dev *dev, int aer_severity,
+void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
  		   struct aer_capability_regs *aer)
  {
  	int layer, agent, tlp_header_valid = 0;
@@ -785,14 +785,15 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
  	info.mask = mask;
  	info.first_error = PCI_ERR_CAP_FEP(aer->cap_control);
 
-	pci_err(dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask);
+	pci_printk(level, dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n",
+		   status, mask);
  	__aer_print_error(dev, &info);
-	pci_err(dev, "aer_layer=%s, aer_agent=%s\n",
-		aer_error_layer[layer], aer_agent_string[agent]);
+	pci_printk(level, dev, "aer_layer=%s, aer_agent=%s\n",
+		   aer_error_layer[layer], aer_agent_string[agent]);
 
  	if (aer_severity != AER_CORRECTABLE)
-		pci_err(dev, "aer_uncor_severity: 0x%08x\n",
-			aer->uncor_severity);
+		pci_printk(level, dev, "aer_uncor_severity: 0x%08x\n",
+			   aer->uncor_severity);
 
  	if (tlp_header_valid)
  		pcie_print_tlp_log(dev, &aer->header_log, dev_fmt("  "));
@@ -1146,8 +1147,7 @@ static void aer_recover_work_func(struct work_struct *work)
  			       PCI_SLOT(entry.devfn), PCI_FUNC(entry.devfn));
  			continue;
  		}
-		pci_print_aer(pdev, entry.severity, entry.regs);
-
+		pci_print_aer(KERN_ERR, pdev, entry.severity, entry.regs);
  		/*
  		 * Memory for aer_capability_regs(entry.regs) is being
  		 * allocated from the ghes_estatus_pool to protect it from
include/linux/aer.h +2 -2
index 02940be66324e..45d0fb2e2e759 100644
@@ -64,8 +64,8 @@ static inline int pci_aer_clear_nonfatal_status(struct pci_dev *dev)
  static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; }
  #endif
 
-void pci_print_aer(struct pci_dev *dev, int aer_severity,
-		    struct aer_capability_regs *aer);
+void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
+		   struct aer_capability_regs *aer);
  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);
Signature · 2 lines
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
maintainer Reviewed-by on v3 2/4
#6 lore raw

Re: [PATCH 2/4 v3] PCI/AER: Modify pci_print_aer() to take log level

In reply to Fabio M. De Francesco
Quoted 5 lines · Fabio M. De Francesco

Modify pci_print_aer() to take a printk() log level in preparation of a patch that logs PCIe Components and Link errors from ELOG.

Quoted 78 lines
---
 drivers/cxl/core/pci.c |  2 +-
 drivers/pci/pcie/aer.c | 16 ++++++++--------
 include/linux/aer.h    |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/cxl/core/pci.c +1 -1
index 3b80e9a76ba86..ad8d7939c2e1c 100644
@@ -885,7 +885,7 @@ static void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds)
 	if (!cxl_rch_get_aer_severity(&aer_regs, &severity))
 		return;
 
-	pci_print_aer(pdev, severity, &aer_regs);
+	pci_print_aer(KERN_ERR, pdev, severity, &aer_regs);
 
 	if (severity == AER_CORRECTABLE)
 		cxl_handle_rdport_cor_ras(cxlds, dport);
drivers/pci/pcie/aer.c +8 -8
index a1cf8c7ef628a..d0ebf7c15afa9 100644
@@ -760,7 +760,7 @@ int cper_severity_to_aer(int cper_severity)
 EXPORT_SYMBOL_GPL(cper_severity_to_aer);
 #endif
 
-void pci_print_aer(struct pci_dev *dev, int aer_severity,
+void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
 		   struct aer_capability_regs *aer)
 {
 	int layer, agent, tlp_header_valid = 0;
@@ -785,14 +785,15 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
 	info.mask = mask;
 	info.first_error = PCI_ERR_CAP_FEP(aer->cap_control);
 
-	pci_err(dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask);
+	pci_printk(level, dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n",
+		   status, mask);
 	__aer_print_error(dev, &info);
-	pci_err(dev, "aer_layer=%s, aer_agent=%s\n",
-		aer_error_layer[layer], aer_agent_string[agent]);
+	pci_printk(level, dev, "aer_layer=%s, aer_agent=%s\n",
+		   aer_error_layer[layer], aer_agent_string[agent]);
 
 	if (aer_severity != AER_CORRECTABLE)
-		pci_err(dev, "aer_uncor_severity: 0x%08x\n",
-			aer->uncor_severity);
+		pci_printk(level, dev, "aer_uncor_severity: 0x%08x\n",
+			   aer->uncor_severity);
 
 	if (tlp_header_valid)
 		pcie_print_tlp_log(dev, &aer->header_log, dev_fmt("  "));
@@ -1146,8 +1147,7 @@ static void aer_recover_work_func(struct work_struct *work)
 			       PCI_SLOT(entry.devfn), PCI_FUNC(entry.devfn));
 			continue;
 		}
-		pci_print_aer(pdev, entry.severity, entry.regs);
-
+		pci_print_aer(KERN_ERR, pdev, entry.severity, entry.regs);
 		/*
 		 * Memory for aer_capability_regs(entry.regs) is being
 		 * allocated from the ghes_estatus_pool to protect it from
include/linux/aer.h +2 -2
index 02940be66324e..45d0fb2e2e759 100644
@@ -64,8 +64,8 @@ static inline int pci_aer_clear_nonfatal_status(struct pci_dev *dev)
 static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; }
 #endif
 
-void pci_print_aer(struct pci_dev *dev, int aer_severity,
-		    struct aer_capability_regs *aer);
+void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
+		   struct aer_capability_regs *aer);
 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);
#7 lore raw

PATCH v3 3/4 ACPI: extlog: Trace CPER PCI Express Error Section

In reply to Fabio M. De Francesco

I/O Machine Check Architecture events may signal failing PCIe components or links. The AER event contains details on what was happening on the wire when the error was signaled.

Trace the CPER PCIe Error section (UEFI v2.10, Appendix N.2.7) reported by the I/O MCA.

---
 drivers/acpi/Kconfig       |  1 +
 drivers/acpi/acpi_extlog.c | 32 ++++++++++++++++++++++++++++++++
 drivers/pci/pcie/aer.c     |  2 +-
 include/linux/aer.h        |  8 ++++++--
 4 files changed, 40 insertions(+), 3 deletions(-)
drivers/acpi/Kconfig +1 -0
index 7bc40c2735ac0..2bbd9e4868ad7 100644
@@ -493,6 +493,7 @@ config ACPI_EXTLOG
 	tristate "Extended Error Log support"
 	depends on X86_MCE && X86_LOCAL_APIC && EDAC
 	select UEFI_CPER
+	select ACPI_APEI_PCIEAER
 	help
 	  Certain usages such as Predictive Failure Analysis (PFA) require
 	  more information about the error than what can be described in
drivers/acpi/acpi_extlog.c +32 -0
index 47d11cb5c9120..b2928ff297eda 100644
@@ -132,6 +132,34 @@ static int print_extlog_rcd(const char *pfx,
 	return 1;
 }
 
+static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
+			      int severity)
+{
+	struct aer_capability_regs *aer;
+	struct pci_dev *pdev;
+	unsigned int devfn;
+	unsigned int bus;
+	int aer_severity;
+	int domain;
+
+	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(severity);
+	aer = (struct aer_capability_regs *)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);
+	pdev = pci_get_domain_bus_and_slot(domain, bus, devfn);
+	if (!pdev)
+		return;
+
+	pci_print_aer(KERN_DEBUG, pdev, aer_severity, aer);
+	pci_dev_put(pdev);
+}
+
 static int extlog_print(struct notifier_block *nb, unsigned long val,
 			void *data)
 {
@@ -183,6 +211,10 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 			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_PCIE)) {
+			struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
+
+			extlog_print_pcie(pcie_err, gdata->error_severity);
 		} else {
 			void *err = acpi_hest_get_payload(gdata);
 
drivers/pci/pcie/aer.c +1 -1
index d0ebf7c15afa9..627fcf4346983 100644
@@ -801,7 +801,7 @@ void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
 	trace_aer_event(dev_name(&dev->dev), (status & ~mask),
 			aer_severity, tlp_header_valid, &aer->header_log);
 }
-EXPORT_SYMBOL_NS_GPL(pci_print_aer, "CXL");
+EXPORT_SYMBOL_GPL(pci_print_aer);
 
 /**
  * add_error_device - list device to be handled
include/linux/aer.h +6 -2
index 45d0fb2e2e759..6ce433cee4625 100644
@@ -56,16 +56,20 @@ struct aer_capability_regs {
 #if defined(CONFIG_PCIEAER)
 int pci_aer_clear_nonfatal_status(struct pci_dev *dev);
 int pcie_aer_is_native(struct pci_dev *dev);
+void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
+		   struct aer_capability_regs *aer);
 #else
 static inline int pci_aer_clear_nonfatal_status(struct pci_dev *dev)
 {
 	return -EINVAL;
 }
 static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; }
+static inline void pci_print_aer(char *level, struct pci_dev *dev,
+				 int aer_severity,
+				 struct aer_capability_regs *aer)
+{ }
 #endif
 
-void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
-		   struct aer_capability_regs *aer);
 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);
Signature · 1 line
2.49.0
maintainer Reviewed-by on v3 3/4
#8 lore raw

Re: [PATCH 3/4 v3] ACPI: extlog: Trace CPER PCI Express Error Section

Quoted 9 lines · Fabio M. De Francesco

I/O Machine Check Architecture events may signal failing PCIe components or links. The AER event contains details on what was happening on the wire when the error was signaled.

Trace the CPER PCIe Error section (UEFI v2.10, Appendix N.2.7) reported by the I/O MCA.

Quoted 109 lines
---
 drivers/acpi/Kconfig       |  1 +
 drivers/acpi/acpi_extlog.c | 32 ++++++++++++++++++++++++++++++++
 drivers/pci/pcie/aer.c     |  2 +-
 include/linux/aer.h        |  8 ++++++--
 4 files changed, 40 insertions(+), 3 deletions(-)
drivers/acpi/Kconfig +1 -0
index 7bc40c2735ac0..2bbd9e4868ad7 100644
@@ -493,6 +493,7 @@ config ACPI_EXTLOG
 	tristate "Extended Error Log support"
 	depends on X86_MCE && X86_LOCAL_APIC && EDAC
 	select UEFI_CPER
+	select ACPI_APEI_PCIEAER
 	help
 	  Certain usages such as Predictive Failure Analysis (PFA) require
 	  more information about the error than what can be described in
drivers/acpi/acpi_extlog.c +32 -0
index 47d11cb5c9120..b2928ff297eda 100644
@@ -132,6 +132,34 @@ static int print_extlog_rcd(const char *pfx,
 	return 1;
 }
 
+static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
+			      int severity)
+{
+	struct aer_capability_regs *aer;
+	struct pci_dev *pdev;
+	unsigned int devfn;
+	unsigned int bus;
+	int aer_severity;
+	int domain;
+
+	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(severity);
+	aer = (struct aer_capability_regs *)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);
+	pdev = pci_get_domain_bus_and_slot(domain, bus, devfn);
+	if (!pdev)
+		return;
+
+	pci_print_aer(KERN_DEBUG, pdev, aer_severity, aer);
+	pci_dev_put(pdev);
+}
+
 static int extlog_print(struct notifier_block *nb, unsigned long val,
 			void *data)
 {
@@ -183,6 +211,10 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 			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_PCIE)) {
+			struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
+
+			extlog_print_pcie(pcie_err, gdata->error_severity);
 		} else {
 			void *err = acpi_hest_get_payload(gdata);
 
drivers/pci/pcie/aer.c +1 -1
index d0ebf7c15afa9..627fcf4346983 100644
@@ -801,7 +801,7 @@ void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
 	trace_aer_event(dev_name(&dev->dev), (status & ~mask),
 			aer_severity, tlp_header_valid, &aer->header_log);
 }
-EXPORT_SYMBOL_NS_GPL(pci_print_aer, "CXL");
+EXPORT_SYMBOL_GPL(pci_print_aer);
 
 /**
  * add_error_device - list device to be handled
include/linux/aer.h +6 -2
index 45d0fb2e2e759..6ce433cee4625 100644
@@ -56,16 +56,20 @@ struct aer_capability_regs {
 #if defined(CONFIG_PCIEAER)
 int pci_aer_clear_nonfatal_status(struct pci_dev *dev);
 int pcie_aer_is_native(struct pci_dev *dev);
+void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
+		   struct aer_capability_regs *aer);
 #else
 static inline int pci_aer_clear_nonfatal_status(struct pci_dev *dev)
 {
 	return -EINVAL;
 }
 static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; }
+static inline void pci_print_aer(char *level, struct pci_dev *dev,
+				 int aer_severity,
+				 struct aer_capability_regs *aer)
+{ }
 #endif
 
-void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
-		   struct aer_capability_regs *aer);
 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);
maintainer Reviewed-by on v3 3/4
#9 lore raw

Re: [PATCH 3/4 v3] ACPI: extlog: Trace CPER PCI Express Error Section

In reply to Fabio M. De Francesco
Quoted 9 lines · Fabio M. De Francesco

I/O Machine Check Architecture events may signal failing PCIe components or links. The AER event contains details on what was happening on the wire when the error was signaled.

Trace the CPER PCIe Error section (UEFI v2.10, Appendix N.2.7) reported by the I/O MCA.

Quoted 109 lines
---
 drivers/acpi/Kconfig       |  1 +
 drivers/acpi/acpi_extlog.c | 32 ++++++++++++++++++++++++++++++++
 drivers/pci/pcie/aer.c     |  2 +-
 include/linux/aer.h        |  8 ++++++--
 4 files changed, 40 insertions(+), 3 deletions(-)
drivers/acpi/Kconfig +1 -0
index 7bc40c2735ac0..2bbd9e4868ad7 100644
@@ -493,6 +493,7 @@ config ACPI_EXTLOG
 	tristate "Extended Error Log support"
 	depends on X86_MCE && X86_LOCAL_APIC && EDAC
 	select UEFI_CPER
+	select ACPI_APEI_PCIEAER
 	help
 	  Certain usages such as Predictive Failure Analysis (PFA) require
 	  more information about the error than what can be described in
drivers/acpi/acpi_extlog.c +32 -0
index 47d11cb5c9120..b2928ff297eda 100644
@@ -132,6 +132,34 @@ static int print_extlog_rcd(const char *pfx,
 	return 1;
 }
 
+static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
+			      int severity)
+{
+	struct aer_capability_regs *aer;
+	struct pci_dev *pdev;
+	unsigned int devfn;
+	unsigned int bus;
+	int aer_severity;
+	int domain;
+
+	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(severity);
+	aer = (struct aer_capability_regs *)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);
+	pdev = pci_get_domain_bus_and_slot(domain, bus, devfn);
+	if (!pdev)
+		return;
+
+	pci_print_aer(KERN_DEBUG, pdev, aer_severity, aer);
+	pci_dev_put(pdev);
+}
+
 static int extlog_print(struct notifier_block *nb, unsigned long val,
 			void *data)
 {
@@ -183,6 +211,10 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 			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_PCIE)) {
+			struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
+
+			extlog_print_pcie(pcie_err, gdata->error_severity);
 		} else {
 			void *err = acpi_hest_get_payload(gdata);
 
drivers/pci/pcie/aer.c +1 -1
index d0ebf7c15afa9..627fcf4346983 100644
@@ -801,7 +801,7 @@ void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
 	trace_aer_event(dev_name(&dev->dev), (status & ~mask),
 			aer_severity, tlp_header_valid, &aer->header_log);
 }
-EXPORT_SYMBOL_NS_GPL(pci_print_aer, "CXL");
+EXPORT_SYMBOL_GPL(pci_print_aer);
 
 /**
  * add_error_device - list device to be handled
include/linux/aer.h +6 -2
index 45d0fb2e2e759..6ce433cee4625 100644
@@ -56,16 +56,20 @@ struct aer_capability_regs {
 #if defined(CONFIG_PCIEAER)
 int pci_aer_clear_nonfatal_status(struct pci_dev *dev);
 int pcie_aer_is_native(struct pci_dev *dev);
+void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
+		   struct aer_capability_regs *aer);
 #else
 static inline int pci_aer_clear_nonfatal_status(struct pci_dev *dev)
 {
 	return -EINVAL;
 }
 static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; }
+static inline void pci_print_aer(char *level, struct pci_dev *dev,
+				 int aer_severity,
+				 struct aer_capability_regs *aer)
+{ }
 #endif
 
-void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
-		   struct aer_capability_regs *aer);
 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);
#10 lore raw

Re: [PATCH 3/4 v3] ACPI: extlog: Trace CPER PCI Express Error Section

In reply to Fabio M. De Francesco
Quoted 101 lines · Fabio M. De Francesco

I/O Machine Check Architecture events may signal failing PCIe components or links. The AER event contains details on what was happening on the wire when the error was signaled.

Trace the CPER PCIe Error section (UEFI v2.10, Appendix N.2.7) reported by the I/O MCA.

---
  drivers/acpi/Kconfig       |  1 +
  drivers/acpi/acpi_extlog.c | 32 ++++++++++++++++++++++++++++++++
  drivers/pci/pcie/aer.c     |  2 +-
  include/linux/aer.h        |  8 ++++++--
  4 files changed, 40 insertions(+), 3 deletions(-)
drivers/acpi/Kconfig +1 -0
index 7bc40c2735ac0..2bbd9e4868ad7 100644
@@ -493,6 +493,7 @@ config ACPI_EXTLOG
  	tristate "Extended Error Log support"
  	depends on X86_MCE && X86_LOCAL_APIC && EDAC
  	select UEFI_CPER
+	select ACPI_APEI_PCIEAER
  	help
  	  Certain usages such as Predictive Failure Analysis (PFA) require
  	  more information about the error than what can be described in
drivers/acpi/acpi_extlog.c +32 -0
index 47d11cb5c9120..b2928ff297eda 100644
@@ -132,6 +132,34 @@ static int print_extlog_rcd(const char *pfx,
  	return 1;
  }
 
+static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
+			      int severity)
+{
+	struct aer_capability_regs *aer;
+	struct pci_dev *pdev;
+	unsigned int devfn;
+	unsigned int bus;
+	int aer_severity;
+	int domain;
+
+	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(severity);
+	aer = (struct aer_capability_regs *)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);
+	pdev = pci_get_domain_bus_and_slot(domain, bus, devfn);
+	if (!pdev)
+		return;
+
+	pci_print_aer(KERN_DEBUG, pdev, aer_severity, aer);
+	pci_dev_put(pdev);
+}
+
  static int extlog_print(struct notifier_block *nb, unsigned long val,
  			void *data)
  {
@@ -183,6 +211,10 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
  			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_PCIE)) {
+			struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
+
+			extlog_print_pcie(pcie_err, gdata->error_severity);
  		} else {
  			void *err = acpi_hest_get_payload(gdata);
 
drivers/pci/pcie/aer.c +1 -1
index d0ebf7c15afa9..627fcf4346983 100644
@@ -801,7 +801,7 @@ void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
  	trace_aer_event(dev_name(&dev->dev), (status & ~mask),
  			aer_severity, tlp_header_valid, &aer->header_log);
  }
-EXPORT_SYMBOL_NS_GPL(pci_print_aer, "CXL");
+EXPORT_SYMBOL_GPL(pci_print_aer);
 
  /**
   * add_error_device - list device to be handled
include/linux/aer.h +2 -0
index 45d0fb2e2e759..6ce433cee4625 100644
@@ -56,16 +56,20 @@ struct aer_capability_regs {
  #if defined(CONFIG_PCIEAER)
  int pci_aer_clear_nonfatal_status(struct pci_dev *dev);
  int pcie_aer_is_native(struct pci_dev *dev);
+void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
+		   struct aer_capability_regs *aer);

include/linux/aer.h struct aer_capability_regs { · line 70

Quoted 10 lines
include/linux/aer.h +4 -0
  #else
  static inline int pci_aer_clear_nonfatal_status(struct pci_dev *dev)
  {
  	return -EINVAL;
  }
  static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; }
+static inline void pci_print_aer(char *level, struct pci_dev *dev,
+				 int aer_severity,
+				 struct aer_capability_regs *aer)
+{ }

This also needs rebase. With the patches queued for v6.16, you may not need to pass level any more.

Quoted 7 lines
include/linux/aer.h +0 -2
  #endif
 
-void pci_print_aer(char *level, struct pci_dev *dev, int aer_severity,
-		   struct aer_capability_regs *aer);
  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);
Signature · 2 lines
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
#11 lore raw

RE: [PATCH 3/4 v3] ACPI: extlog: Trace CPER PCI Express Error Section

In reply to Fabio M. De Francesco
Quoted 36 lines

From: Fabio M. De Francesco <[email protected]> [...]
Subject: [PATCH 3/4 v3] ACPI: extlog: Trace CPER PCI Express Error Section

I/O Machine Check Architecture events may signal failing PCIe components or links. The AER event contains details on what was happening on the wire when the error was signaled.

Trace the CPER PCIe Error section (UEFI v2.10, Appendix N.2.7) reported by the I/O MCA.

Cc: Dan Williams <[email protected]>
Signed-off-by: Fabio M. De Francesco
<[email protected]>
[...]

drivers/acpi/acpi_extlog.c +15 -0
@@ -132,6 +132,34 @@ static int print_extlog_rcd(const char *pfx,
 	return 1;
 }
 
+static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
+			      int severity)
+{
+	struct aer_capability_regs *aer;
+	struct pci_dev *pdev;
+	unsigned int devfn;
+	unsigned int bus;
+	int aer_severity;
+	int domain;
+
+	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(severity);

drivers/acpi/acpi_extlog.c static int print_extlog_rcd(const char *pfx, · line 159

Quoted 10 lines
drivers/acpi/acpi_extlog.c +10 -0
+	aer = (struct aer_capability_regs *)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);
+	pdev = pci_get_domain_bus_and_slot(domain, bus, devfn);
+	if (!pdev)
+		return;
+
+	pci_print_aer(KERN_DEBUG, pdev, aer_severity, aer);

Is there any reason not to use "KERN_ERR" log level?

Quoted 3 lines
drivers/acpi/acpi_extlog.c +3 -0
+	pci_dev_put(pdev);
+}
+ 
#12 lore raw

PATCH v3 4/4 ACPI: extlog: Trace CPER CXL Protocol Error Section

In reply to Fabio M. De Francesco

When Firmware First is enabled, BIOS handles errors first and then it makes them available to the kernel via the Common Platform Error Record (CPER) sections (UEFI 2.10 Appendix N). Linux parses the CPER sections via one of two similar paths, either ELOG or GHES. The errors managed by ELOG are signaled to the BIOS by the I/O Machine Check Architecture (I/O MCA).

Currently, ELOG and GHES show some inconsistencies in how they report to userspace via trace events.

Therefore, make the two mentioned paths act similarly by tracing the CPER CXL Protocol Error Section (UEFI v2.10, Appendix N.2.13).

---
 drivers/acpi/acpi_extlog.c | 64 ++++++++++++++++++++++++++++++++++++++
 drivers/cxl/core/ras.c     |  6 ++++
 include/cxl/event.h        |  2 ++
 3 files changed, 72 insertions(+)
drivers/acpi/acpi_extlog.c +64 -0
index b2928ff297eda..de4f617f32d49 100644
@@ -12,6 +12,7 @@
 #include <linux/ratelimit.h>
 #include <linux/edac.h>
 #include <linux/ras.h>
+#include <cxl/event.h>
 #include <acpi/ghes.h>
 #include <asm/cpu.h>
 #include <asm/mce.h>
@@ -160,6 +161,62 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
 	pci_dev_put(pdev);
 }
 
+static void
+extlog_cxl_cper_handle_prot_err(struct cxl_cper_sec_prot_err *prot_err,
+				int severity)
+{
+#ifdef CONFIG_ACPI_APEI_PCIEAER
+	struct cxl_cper_prot_err_work_data wd;
+	u8 *dvsec_start, *cap_start;
+
+	if (!(prot_err->valid_bits & PROT_ERR_VALID_AGENT_ADDRESS)) {
+		pr_err_ratelimited("CXL CPER invalid agent type\n");
+		return;
+	}
+
+	if (!(prot_err->valid_bits & PROT_ERR_VALID_ERROR_LOG)) {
+		pr_err_ratelimited("CXL CPER invalid protocol error log\n");
+		return;
+	}
+
+	if (prot_err->err_len != sizeof(struct cxl_ras_capability_regs)) {
+		pr_err_ratelimited("CXL CPER invalid RAS Cap size (%u)\n",
+				   prot_err->err_len);
+		return;
+	}
+
+	if ((prot_err->agent_type == RCD || prot_err->agent_type == DEVICE ||
+	     prot_err->agent_type == LD || prot_err->agent_type == FMLD) &&
+	    !(prot_err->valid_bits & PROT_ERR_VALID_SERIAL_NUMBER))
+		pr_warn(FW_WARN "CXL CPER no device serial number\n");
+
+	switch (prot_err->agent_type) {
+	case RCD:
+	case DEVICE:
+	case LD:
+	case FMLD:
+	case RP:
+	case DSP:
+	case USP:
+		memcpy(&wd.prot_err, prot_err, sizeof(wd.prot_err));
+
+		dvsec_start = (u8 *)(prot_err + 1);
+		cap_start = dvsec_start + prot_err->dvsec_len;
+
+		memcpy(&wd.ras_cap, cap_start, sizeof(wd.ras_cap));
+		wd.severity = cper_severity_to_aer(severity);
+		break;
+	default:
+		pr_err_ratelimited("CXL CPER reserved agent type: %d\n",
+				   prot_err->agent_type);
+		return;
+	}
+
+	cxl_cper_ras_handle_prot_err(&wd);
+
+#endif
+}
+
 static int extlog_print(struct notifier_block *nb, unsigned long val,
 			void *data)
 {
@@ -211,6 +268,12 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 			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_CXL_PROT_ERR)) {
+			struct cxl_cper_sec_prot_err *prot_err =
+				acpi_hest_get_payload(gdata);
+
+			extlog_cxl_cper_handle_prot_err(prot_err,
+							gdata->error_severity);
 		} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
 			struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
 
@@ -378,3 +441,4 @@ module_exit(extlog_exit);
 MODULE_AUTHOR("Chen, Gong <[email protected]>");
 MODULE_DESCRIPTION("Extended MCA Error Log Driver");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("CXL");
drivers/cxl/core/ras.c +6 -0
index 485a831695c70..56db290c88d35 100644
@@ -98,6 +98,12 @@ static void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data)
 		cxl_cper_trace_uncorr_prot_err(pdev, data->ras_cap);
 }
 
+void cxl_cper_ras_handle_prot_err(struct cxl_cper_prot_err_work_data *wd)
+{
+	cxl_cper_handle_prot_err(wd);
+}
+EXPORT_SYMBOL_NS_GPL(cxl_cper_ras_handle_prot_err, "CXL");
+
 static void cxl_cper_prot_err_work_fn(struct work_struct *work)
 {
 	struct cxl_cper_prot_err_work_data wd;
include/cxl/event.h +2 -0
index f9ae1796da85f..aef906e260330 100644
@@ -285,4 +285,6 @@ static inline int cxl_cper_prot_err_kfifo_get(struct cxl_cper_prot_err_work_data
 }
 #endif
 
+void cxl_cper_ras_handle_prot_err(struct cxl_cper_prot_err_work_data *wd);
+
 #endif /* _LINUX_CXL_EVENT_H */
Signature · 1 line
2.49.0
maintainer
#13 lore raw

Re: [PATCH 4/4 v3] ACPI: extlog: Trace CPER CXL Protocol Error Section

Quoted 33 lines · Fabio M. De Francesco

When Firmware First is enabled, BIOS handles errors first and then it makes them available to the kernel via the Common Platform Error Record (CPER) sections (UEFI 2.10 Appendix N). Linux parses the CPER sections via one of two similar paths, either ELOG or GHES. The errors managed by ELOG are signaled to the BIOS by the I/O Machine Check Architecture (I/O MCA).

Currently, ELOG and GHES show some inconsistencies in how they report to userspace via trace events.

Therefore, make the two mentioned paths act similarly by tracing the CPER CXL Protocol Error Section (UEFI v2.10, Appendix N.2.13).

---
 drivers/acpi/acpi_extlog.c | 64 ++++++++++++++++++++++++++++++++++++++
 drivers/cxl/core/ras.c     |  6 ++++
 include/cxl/event.h        |  2 ++
 3 files changed, 72 insertions(+)
drivers/acpi/acpi_extlog.c +1 -0
index b2928ff297eda..de4f617f32d49 100644
@@ -12,6 +12,7 @@
 #include <linux/ratelimit.h>
 #include <linux/edac.h>
 #include <linux/ras.h>
+#include <cxl/event.h>
 #include <acpi/ghes.h>
 #include <asm/cpu.h>
 #include <asm/mce.h>

drivers/acpi/acpi_extlog.c static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, · line 168

Quoted 8 lines
drivers/acpi/acpi_extlog.c +5 -0
@@ -160,6 +161,62 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
 	pci_dev_put(pdev);
 }
 
+static void
+extlog_cxl_cper_handle_prot_err(struct cxl_cper_sec_prot_err *prot_err,
+				int severity)
+{
+#ifdef CONFIG_ACPI_APEI_PCIEAER

The ifdef should be in a header file?

drivers/acpi/acpi_extlog.c static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, · line 173

Quoted 5 lines
drivers/acpi/acpi_extlog.c +5 -0
+	struct cxl_cper_prot_err_work_data wd;
+	u8 *dvsec_start, *cap_start;
+
+	if (!(prot_err->valid_bits & PROT_ERR_VALID_AGENT_ADDRESS)) {
+		pr_err_ratelimited("CXL CPER invalid agent type\n");

pr_warn_ratelimited()?

drivers/acpi/acpi_extlog.c static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, · line 178

Quoted 5 lines
drivers/acpi/acpi_extlog.c +5 -0
+		return;
+	}
+
+	if (!(prot_err->valid_bits & PROT_ERR_VALID_ERROR_LOG)) {
+		pr_err_ratelimited("CXL CPER invalid protocol error log\n");

pr_warn_ratelimited()?

drivers/acpi/acpi_extlog.c static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, · line 184

Quoted 6 lines
drivers/acpi/acpi_extlog.c +6 -0
+		return;
+	}
+
+	if (prot_err->err_len != sizeof(struct cxl_ras_capability_regs)) {
+		pr_err_ratelimited("CXL CPER invalid RAS Cap size (%u)\n",
+				   prot_err->err_len);

pr_warn_ratelimited()?

drivers/acpi/acpi_extlog.c static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, · line 191

Quoted 7 lines
drivers/acpi/acpi_extlog.c +7 -0
+		return;
+	}
+
+	if ((prot_err->agent_type == RCD || prot_err->agent_type == DEVICE ||
+	     prot_err->agent_type == LD || prot_err->agent_type == FMLD) &&
+	    !(prot_err->valid_bits & PROT_ERR_VALID_SERIAL_NUMBER))
+		pr_warn(FW_WARN "CXL CPER no device serial number\n");

Why are the earlier emits ratelimited, but not this one?

DJ

Quoted 77 lines
drivers/acpi/acpi_extlog.c +35 -0
+
+	switch (prot_err->agent_type) {
+	case RCD:
+	case DEVICE:
+	case LD:
+	case FMLD:
+	case RP:
+	case DSP:
+	case USP:
+		memcpy(&wd.prot_err, prot_err, sizeof(wd.prot_err));
+
+		dvsec_start = (u8 *)(prot_err + 1);
+		cap_start = dvsec_start + prot_err->dvsec_len;
+
+		memcpy(&wd.ras_cap, cap_start, sizeof(wd.ras_cap));
+		wd.severity = cper_severity_to_aer(severity);
+		break;
+	default:
+		pr_err_ratelimited("CXL CPER reserved agent type: %d\n",
+				   prot_err->agent_type);
+		return;
+	}
+
+	cxl_cper_ras_handle_prot_err(&wd);
+
+#endif
+}
+
 static int extlog_print(struct notifier_block *nb, unsigned long val,
 			void *data)
 {
@@ -211,6 +268,12 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 			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_CXL_PROT_ERR)) {
+			struct cxl_cper_sec_prot_err *prot_err =
+				acpi_hest_get_payload(gdata);
+
+			extlog_cxl_cper_handle_prot_err(prot_err,
+							gdata->error_severity);
 		} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
 			struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
 
@@ -378,3 +441,4 @@ module_exit(extlog_exit);
 MODULE_AUTHOR("Chen, Gong <[email protected]>");
 MODULE_DESCRIPTION("Extended MCA Error Log Driver");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("CXL");
drivers/cxl/core/ras.c +6 -0
index 485a831695c70..56db290c88d35 100644
@@ -98,6 +98,12 @@ static void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data)
 		cxl_cper_trace_uncorr_prot_err(pdev, data->ras_cap);
 }
 
+void cxl_cper_ras_handle_prot_err(struct cxl_cper_prot_err_work_data *wd)
+{
+	cxl_cper_handle_prot_err(wd);
+}
+EXPORT_SYMBOL_NS_GPL(cxl_cper_ras_handle_prot_err, "CXL");
+
 static void cxl_cper_prot_err_work_fn(struct work_struct *work)
 {
 	struct cxl_cper_prot_err_work_data wd;
include/cxl/event.h +2 -0
index f9ae1796da85f..aef906e260330 100644
@@ -285,4 +285,6 @@ static inline int cxl_cper_prot_err_kfifo_get(struct cxl_cper_prot_err_work_data
 }
 #endif
 
+void cxl_cper_ras_handle_prot_err(struct cxl_cper_prot_err_work_data *wd);
+
 #endif /* _LINUX_CXL_EVENT_H */
Reviewed-by on v3 4/4
#14 lore raw

Re: [PATCH 4/4 v3] ACPI: extlog: Trace CPER CXL Protocol Error Section

In reply to Fabio M. De Francesco
Quoted 9 lines · Fabio M. De Francesco

When Firmware First is enabled, BIOS handles errors first and then it makes them available to the kernel via the Common Platform Error Record (CPER) sections (UEFI 2.10 Appendix N). Linux parses the CPER sections via one of two similar paths, either ELOG or GHES. The errors managed by ELOG are signaled to the BIOS by the I/O Machine Check Architecture (I/O MCA).

Currently, ELOG and GHES show some inconsistencies in how they report to userspace via trace events.

Quoted 6 lines

Therefore, make the two mentioned paths act similarly by tracing the CPER CXL Protocol Error Section (UEFI v2.10, Appendix N.2.13).

---

Quoted 126 lines
  drivers/acpi/acpi_extlog.c | 64 ++++++++++++++++++++++++++++++++++++++
  drivers/cxl/core/ras.c     |  6 ++++
  include/cxl/event.h        |  2 ++
  3 files changed, 72 insertions(+)
drivers/acpi/acpi_extlog.c +64 -0
index b2928ff297eda..de4f617f32d49 100644
@@ -12,6 +12,7 @@
  #include <linux/ratelimit.h>
  #include <linux/edac.h>
  #include <linux/ras.h>
+#include <cxl/event.h>
  #include <acpi/ghes.h>
  #include <asm/cpu.h>
  #include <asm/mce.h>
@@ -160,6 +161,62 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
  	pci_dev_put(pdev);
  }
 
+static void
+extlog_cxl_cper_handle_prot_err(struct cxl_cper_sec_prot_err *prot_err,
+				int severity)
+{
+#ifdef CONFIG_ACPI_APEI_PCIEAER
+	struct cxl_cper_prot_err_work_data wd;
+	u8 *dvsec_start, *cap_start;
+
+	if (!(prot_err->valid_bits & PROT_ERR_VALID_AGENT_ADDRESS)) {
+		pr_err_ratelimited("CXL CPER invalid agent type\n");
+		return;
+	}
+
+	if (!(prot_err->valid_bits & PROT_ERR_VALID_ERROR_LOG)) {
+		pr_err_ratelimited("CXL CPER invalid protocol error log\n");
+		return;
+	}
+
+	if (prot_err->err_len != sizeof(struct cxl_ras_capability_regs)) {
+		pr_err_ratelimited("CXL CPER invalid RAS Cap size (%u)\n",
+				   prot_err->err_len);
+		return;
+	}
+
+	if ((prot_err->agent_type == RCD || prot_err->agent_type == DEVICE ||
+	     prot_err->agent_type == LD || prot_err->agent_type == FMLD) &&
+	    !(prot_err->valid_bits & PROT_ERR_VALID_SERIAL_NUMBER))
+		pr_warn(FW_WARN "CXL CPER no device serial number\n");
+
+	switch (prot_err->agent_type) {
+	case RCD:
+	case DEVICE:
+	case LD:
+	case FMLD:
+	case RP:
+	case DSP:
+	case USP:
+		memcpy(&wd.prot_err, prot_err, sizeof(wd.prot_err));
+
+		dvsec_start = (u8 *)(prot_err + 1);
+		cap_start = dvsec_start + prot_err->dvsec_len;
+
+		memcpy(&wd.ras_cap, cap_start, sizeof(wd.ras_cap));
+		wd.severity = cper_severity_to_aer(severity);
+		break;
+	default:
+		pr_err_ratelimited("CXL CPER reserved agent type: %d\n",
+				   prot_err->agent_type);
+		return;
+	}
+
+	cxl_cper_ras_handle_prot_err(&wd);
+
+#endif
+}
+
  static int extlog_print(struct notifier_block *nb, unsigned long val,
  			void *data)
  {
@@ -211,6 +268,12 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
  			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_CXL_PROT_ERR)) {
+			struct cxl_cper_sec_prot_err *prot_err =
+				acpi_hest_get_payload(gdata);
+
+			extlog_cxl_cper_handle_prot_err(prot_err,
+							gdata->error_severity);
  		} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
  			struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
 
@@ -378,3 +441,4 @@ module_exit(extlog_exit);
  MODULE_AUTHOR("Chen, Gong <[email protected]>");
  MODULE_DESCRIPTION("Extended MCA Error Log Driver");
  MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("CXL");
drivers/cxl/core/ras.c +6 -0
index 485a831695c70..56db290c88d35 100644
@@ -98,6 +98,12 @@ static void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data)
  		cxl_cper_trace_uncorr_prot_err(pdev, data->ras_cap);
  }
 
+void cxl_cper_ras_handle_prot_err(struct cxl_cper_prot_err_work_data *wd)
+{
+	cxl_cper_handle_prot_err(wd);
+}
+EXPORT_SYMBOL_NS_GPL(cxl_cper_ras_handle_prot_err, "CXL");
+
  static void cxl_cper_prot_err_work_fn(struct work_struct *work)
  {
  	struct cxl_cper_prot_err_work_data wd;
include/cxl/event.h +2 -0
index f9ae1796da85f..aef906e260330 100644
@@ -285,4 +285,6 @@ static inline int cxl_cper_prot_err_kfifo_get(struct cxl_cper_prot_err_work_data
  }
  #endif
 
+void cxl_cper_ras_handle_prot_err(struct cxl_cper_prot_err_work_data *wd);
+
  #endif /* _LINUX_CXL_EVENT_H */
Signature · 2 lines
Sathyanarayanan Kuppuswamy
Linux Kernel Developer