Make ELOG log and trace consistently with GHES
v2 cover Make ELOG log and trace consistently with GHES
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 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 Errors
drivers/acpi/acpi_extlog.c | 96 ++++++++++++++++++++++++++++++++++++++ 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 | 13 +++++- 7 files changed, 126 insertions(+), 12 deletions(-)
Signature · 1 line
2.48.1
PATCH v2 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
@@ -182,6 +182,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
@@ -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.48.1
Re: [PATCH 1/4 v2] ACPI: extlog: Trace CPER Non-standard Section Body
Quoted 10 lines · On Tue, 29 Apr 2025 19:21:06 +0200 "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 toextlog_print()via the IOMCA (I/O Machine Check Architecture) mechanism. Bring parity to theextlog_print()path by including a similarlog_non_standard_event().Cc Dan Williams <[email protected]>Reviewed-by Dan Williams <[email protected]>Signed-off-by Fabio M. De Francesco <[email protected]>
Makes sense to me.
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@@ -182,6 +182,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@@ -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) {
PATCH v2 2/4 PCI/AER: Modify pci_print_aer() to take log level
In reply to Fabio M. De FrancescoModify 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
@@ -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
@@ -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
@@ -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.48.1
Re: [PATCH 2/4 v2] PCI/AER: Modify pci_print_aer() to take log level
Quoted 6 lines · On Tue, 29 Apr 2025 19:21:07 +0200 "Fabio M. De Francesco"…
Modify
pci_print_aer()to take aprintk()log level in preparation of a patch that logs PCIe Components and Link errors from ELOG.Cc Dan Williams <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Signed-off-by Fabio M. De Francesco <[email protected]>
Fair enough on reasoning and it does what you describe so
PATCH v2 3/4 ACPI: extlog: Trace CPER PCI Express Error Section
In reply to Fabio M. De FrancescoI/O Machine Check Arcitecture 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/acpi_extlog.c | 30 ++++++++++++++++++++++++++++++ drivers/pci/pcie/aer.c | 2 +- include/linux/aer.h | 13 +++++++++++-- 3 files changed, 42 insertions(+), 3 deletions(-)
drivers/acpi/acpi_extlog.c +30 -0
@@ -131,6 +131,32 @@ 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 ) { + 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) {
@@ -182,6 +208,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
@@ -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 +11 -2
@@ -56,17 +56,26 @@ 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); +#if defined(CONFIG_ACPI_APEI_PCIEAER )int cper_severity_to_aer (int cper_severity); +#else +static inline int cper_severity_to_aer (int cper_severity) {return 0 ; } +#endif +void aer_recover_queue (int domain,unsigned int bus,unsigned int devfn,int severity,struct aer_capability_regs *aer_regs);#endif //_AER_H_
Signature · 1 line
2.48.1
Re: [PATCH 3/4 v2] ACPI: extlog: Trace CPER PCI Express Error Section
Quoted 25 lines · Fabio M. De Francesco
I/O Machine Check Arcitecture 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 | 30 ++++++++++++++++++++++++++++++ drivers/pci/pcie/aer.c | 2 +- include/linux/aer.h | 13 +++++++++++-- 3 files changed, 42 insertions(+), 3 deletions(-)drivers/acpi/acpi_extlog.c +2
-0@@ -131,6 +131,32 @@ static int print_extlog_rcd(const char *pfx,return 1 ; } +static void extlog_print_pcie (struct cper_sec_pcie *pcie_err, +int severity)
drivers/acpi/acpi_extlog.c static int print_extlog_rcd(const char *pfx, · line 145
Quoted 10 lines
drivers/acpi/acpi_extlog.c +10
-0+{ +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 ) {
You can save an indentation level by inverting this check and returning early.
drivers/acpi/acpi_extlog.c static int print_extlog_rcd(const char *pfx, · line 146
Quoted 1 line
drivers/acpi/acpi_extlog.c +1
-0+ aer_severity =cper_severity_to_aer (severity);
I think it would help with clarity if all these lines were aligned on the "=".
drivers/acpi/acpi_extlog.c static int print_extlog_rcd(const char *pfx, · line 149
Quoted 3 lines
drivers/acpi/acpi_extlog.c +3
-0+ aer = (struct aer_capability_regs *)pcie_err->aer_info; + domain = pcie_err->device_id.segment; + bus = pcie_err->device_id.bus;
Many of these variables are passed unchanged to a single function below.
Why not pass them directly to the function?
Even if you split the function parameters across multiple lines, you will still have fewer lines. Plus you will not need to allocate the variables.
drivers/acpi/acpi_extlog.c static int print_extlog_rcd(const char *pfx, · line 154
Quoted 5 lines
drivers/acpi/acpi_extlog.c +5
-0+ 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 ;
Newline here, please.
drivers/acpi/acpi_extlog.c static int print_extlog_rcd(const char *pfx, · line 155
Quoted 1 line
drivers/acpi/acpi_extlog.c +1
-0+pci_print_aer (KERN_DEBUG , pdev, aer_severity, aer);
Why use a debug log level?
Quoted 41 lines
drivers/acpi/acpi_extlog.c +8
-0+pci_dev_put (pdev); + } +} +static int extlog_print (struct notifier_block *nb,unsigned long val,void *data) {@@ -182,6 +208,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@@ -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@@ -56,17 +56,26 @@ 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) +{ }
I think the "{ }" can just go at the end of the parameters.
include/linux/aer.h struct aer_capability_regs { · line 76
Quoted 8 lines
include/linux/aer.h +3
-2#endif -void pci_print_aer (char *level,struct pci_dev *dev,int aer_severity, -struct aer_capability_regs *aer); +#if defined(CONFIG_ACPI_APEI_PCIEAER )int cper_severity_to_aer (int cper_severity); +#else +static inline int cper_severity_to_aer (int cper_severity) {return 0 ; }
This may have an unintentional side effect.
'0' means AER_NONFATAL.
So the function will return that the error is an uncorrectable AER error that is potentially recoverable. At a minimum, this will incorrectly classify the error for data collection, and it could cause incorrect handling.
I guess the risk is minimal, since CONFIG_ACPI_APEI_PCIEAER will likely be enabled on systems that would use this.
Thanks,
Yazen
Re: [PATCH 3/4 v2] ACPI: extlog: Trace CPER PCI Express Error Section
Quoted 24 lines · Central European Summer Time Yazen Ghannam
Quoted 23 lines · Fabio M. De Francesco
I/O Machine Check Arcitecture 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 | 30 ++++++++++++++++++++++++++++++ drivers/pci/pcie/aer.c | 2 +- include/linux/aer.h | 13 +++++++++++-- 3 files changed, 42 insertions(+), 3 deletions(-)drivers/acpi/acpi_extlog.c +0
-0@@ -131,6 +131,32 @@ static int print_extlog_rcd(const char *pfx,return 1 ; }
Quoted 16 lines
drivers/acpi/acpi_extlog.c static int print_extlog_rcd(const char *pfx, · line 145
Quoted 12 lines
drivers/acpi/acpi_extlog.c +12
-0+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 ) {You can save an indentation level by inverting this check and returning early.
Nice idea, I'll do it.
Quoted 12 lines
drivers/acpi/acpi_extlog.c static int print_extlog_rcd(const char *pfx, · line 146
Quoted 2 lines
drivers/acpi/acpi_extlog.c +1
-0+ aer_severity =cper_severity_to_aer (severity);I think it would help with clarity if all these lines were aligned on the "=".
drivers/acpi/acpi_extlog.c static int print_extlog_rcd(const char *pfx, · line 149
Quoted 3 lines
drivers/acpi/acpi_extlog.c +3
-0+ aer = (struct aer_capability_regs *)pcie_err->aer_info; + domain = pcie_err->device_id.segment; + bus = pcie_err->device_id.bus;Many of these variables are passed unchanged to a single function below.
Quoted 6 lines
Why not pass them directly to the function?
Even if you split the function parameters across multiple lines, you will still have fewer lines. Plus you will not need to allocate the variables.
I think that the cost is minimal and readability is improved.
Quoted 9 lines
drivers/acpi/acpi_extlog.c static int print_extlog_rcd(const char *pfx, · line 154
Quoted 6 lines
drivers/acpi/acpi_extlog.c +5
-0+ 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 ;Newline here, please.
Sure.
Quoted 5 lines
drivers/acpi/acpi_extlog.c static int print_extlog_rcd(const char *pfx, · line 155
Quoted 2 lines
drivers/acpi/acpi_extlog.c +1
-0+pci_print_aer (KERN_DEBUG , pdev, aer_severity, aer);Why use a debug log level?
Dan Williams suggested the debug log level commenting v1.
Quoted 68 lines
Quoted 42 lines
drivers/acpi/acpi_extlog.c +8
-0+pci_dev_put (pdev); + } +} +static int extlog_print (struct notifier_block *nb,unsigned long val,void *data) {@@ -182,6 +208,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@@ -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@@ -56,17 +56,26 @@ 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) +{ }I think the "{ }" can just go at the end of the parameters.
include/linux/aer.h struct aer_capability_regs { · line 76
Quoted 8 lines
include/linux/aer.h +3
-2#endif -void pci_print_aer (char *level,struct pci_dev *dev,int aer_severity, -struct aer_capability_regs *aer); +#if defined(CONFIG_ACPI_APEI_PCIEAER )int cper_severity_to_aer (int cper_severity); +#else +static inline int cper_severity_to_aer (int cper_severity) {return 0 ; }This may have an unintentional side effect.
'0' means
AER_NONFATAL.
Quoted 8 lines
So the function will return that the error is an uncorrectable AER error that is potentially recoverable. At a minimum, this will incorrectly classify the error for data collection, and it could cause incorrect handling.
I guess the risk is minimal, since
CONFIG_ACPI_APEI_PCIEAERwill likely be enabled on systems that would use this.
Noted. Kconfig will select CONFIG_ACPI_APEI_PCIEAER.
Quoted 4 lines
Thanks,
Yazen
Thanks,
Fabio
PATCH v2 4/4 ACPI: extlog: Trace CPER CXL Protocol Errors
In reply to Fabio M. De FrancescoWhen 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 report to userspace via trace events.
Therfore make the two mentioned paths act similarly by tracing the CPER CXL Protocol Error Section (UEFI v2.10, Appendix N.2.13) signaled by the I/O Machine Check Architecture and reported by BIOS in FW-First.
--- drivers/acpi/acpi_extlog.c | 60 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/ras.c | 6 ++++ include/cxl/event.h | 2 ++ 3 files changed, 68 insertions(+)
drivers/acpi/acpi_extlog.c +60 -0
@@ -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>
@@ -157,6 +158,60 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, } } +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->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 invalid 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) {
@@ -208,6 +263,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_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);
@@ -375,3 +434,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
@@ -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
@@ -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.48.1
Re: [PATCH 4/4 v2] ACPI: extlog: Trace CPER CXL Protocol Errors
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.
Currently, ELOG and GHES show some inconsistencies in how they report to userspace via trace events.
Therfore make the two mentioned paths act similarly by tracing the CPER CXL Protocol Error Section (UEFI v2.10, Appendix N.2.13) signaled by the I/O Machine Check Architecture and reported by BIOS in FW-First.
Cc Dan Williams <[email protected]>Signed-off-by Fabio M. De Francesco <[email protected]>--- drivers/acpi/acpi_extlog.c | 60 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/ras.c | 6 ++++ include/cxl/event.h | 2 ++ 3 files changed, 68 insertions(+)drivers/acpi/acpi_extlog.c +1
-0@@ -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 165
Quoted 8 lines
drivers/acpi/acpi_extlog.c +5
-0@@ -157,6 +158,60 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, } } +static void +extlog_cxl_cper_handle_prot_err (struct cxl_cper_sec_prot_err *prot_err, +int severity) +{ +#ifdef CONFIG_ACPI_APEI_PCIEAER
Why not apply this check on the function prototype?
Reference: Documentation/process/coding-style.rst
Section 21) Conditional Compilation
Quoted 11 lines
drivers/acpi/acpi_extlog.c +11
-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" ); +return ; + } + +if (!(prot_err->valid_bits &PROT_ERR_VALID_ERROR_LOG )) { +pr_err_ratelimited ("CXL CPER invalid protocol error log\n" ); +return ;
drivers/acpi/acpi_extlog.c static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, · line 186
Quoted 10 lines
drivers/acpi/acpi_extlog.c +10
-0+ } + +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->valid_bits &PROT_ERR_VALID_SERIAL_NUMBER )) +pr_warn (FW_WARN "CXL CPER no device serial number\n" );
Is this a requirement (in the spec) that we should warn users about?
The UEFI spec says that serial number is only used if "CXL agent" is a "CXL device".
"CXL ports" won't have serial numbers. So this will be a false warning for port errors.
Quoted 9 lines
drivers/acpi/acpi_extlog.c +9
-0+ +switch (prot_err->agent_type) { +case RCD : +case DEVICE : +case LD : +case FMLD : +case RP : +case DSP : +case USP :
drivers/acpi/acpi_extlog.c static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, · line 205
Quoted 10 lines
drivers/acpi/acpi_extlog.c +10
-0+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 invalid agent type: %d\n",
"invalid" is too harsh given that the specs may be updated. Maybe say "reserved" or "unknown" or "unrecognized" instead.
Hopefully things will settle down to where a user will be able to have a system with newer CXL "agents" without *requiring* a kernel update. :)
Thanks,
Yazen
Re: [PATCH 4/4 v2] ACPI: extlog: Trace CPER CXL Protocol Errors
Quoted 37 lines · Central European Summer Time Yazen Ghannam
Quoted 36 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.
Currently, ELOG and GHES show some inconsistencies in how they report to userspace via trace events.
Therfore make the two mentioned paths act similarly by tracing the CPER CXL Protocol Error Section (UEFI v2.10, Appendix N.2.13) signaled by the I/O Machine Check Architecture and reported by BIOS in FW-First.
Cc Dan Williams <[email protected]>Signed-off-by Fabio M. De Francesco <[email protected]>--- drivers/acpi/acpi_extlog.c | 60 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/ras.c | 6 ++++ include/cxl/event.h | 2 ++ 3 files changed, 68 insertions(+)drivers/acpi/acpi_extlog.c +1
-0@@ -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> @@ -157,6 +158,60 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, } }
Quoted 8 lines
drivers/acpi/acpi_extlog.c static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, · line 165
Quoted 5 lines
drivers/acpi/acpi_extlog.c +5
-0+static void +extlog_cxl_cper_handle_prot_err (struct cxl_cper_sec_prot_err *prot_err, +int severity) +{ +#ifdef CONFIG_ACPI_APEI_PCIEAER Why not apply this check on the function prototype?
This function is static.
Quoted 28 lines
Reference:
Documentation/process/coding-style.rst
Section 21) Conditional CompilationQuoted 11 lines
drivers/acpi/acpi_extlog.c +11
-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" ); +return ; + } + +if (!(prot_err->valid_bits &PROT_ERR_VALID_ERROR_LOG )) { +pr_err_ratelimited ("CXL CPER invalid protocol error log\n" ); +return ;drivers/acpi/acpi_extlog.c static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, · line 186
Quoted 10 lines
drivers/acpi/acpi_extlog.c +10
-0+ } + +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->valid_bits &PROT_ERR_VALID_SERIAL_NUMBER )) +pr_warn (FW_WARN "CXL CPER no device serial number\n" );Is this a requirement (in the spec) that we should warn users about?
Quoted 6 lines
The UEFI spec says that serial number is only used if "CXL agent" is a "CXL device".
"CXL ports" won't have serial numbers. So this will be a false warning for port errors.
I'll add a test and print that warning only if agent is a device (RCD, DEVICE, LD, FMLD).
Quoted 24 lines
Quoted 10 lines
drivers/acpi/acpi_extlog.c +9
-0+ +switch (prot_err->agent_type) { +case RCD : +case DEVICE : +case LD : +case FMLD : +case RP : +case DSP : +case USP :drivers/acpi/acpi_extlog.c static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, · line 205
Quoted 10 lines
drivers/acpi/acpi_extlog.c +10
-0+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 invalid agent type: %d\n","invalid" is too harsh given that the specs may be updated. Maybe say "reserved" or "unknown" or "unrecognized" instead.
Quoted 3 lines
Hopefully things will settle down to where a user will be able to have a system with newer CXL "agents" without *requiring* a kernel update. :)
I'll replace "invalid" with "unknown".
Quoted 4 lines
Thanks,
Yazen
Thanks,
Fabio