Skip to content

Commit 7020586

Browse files
fdefrancrafaeljw
authored andcommitted
ACPI: APEI: GHES: Add helper for CPER CXL protocol errors checks
Move the CPER CXL protocol errors validity check out of cxl_cper_post_prot_err() to new cxl_cper_sec_prot_err_valid() and limit the serial number check only to CXL agents that are CXL devices (UEFI v2.10, Appendix N.2.13). Export the new symbol for reuse by ELOG. Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Hanjun Guo <guohanjun@huawei.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Signed-off-by: Fabio M. De Francesco <fabio.m.de.francesco@linux.intel.com> [ rjw: Subject tweak ] Link: https://patch.msgid.link/20260114101543.85926-4-fabio.m.de.francesco@linux.intel.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent e778ffe commit 7020586

4 files changed

Lines changed: 45 additions & 17 deletions

File tree

drivers/acpi/apei/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_ACPI_APEI) += apei.o
33
obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o
4+
obj-$(CONFIG_ACPI_APEI_PCIEAER) += ghes_helpers.o
45
obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o
56
einj-y := einj-core.o
67
einj-$(CONFIG_ACPI_APEI_EINJ_CXL) += einj-cxl.o

drivers/acpi/apei/ghes.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -741,24 +741,8 @@ static void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
741741
struct cxl_cper_prot_err_work_data wd;
742742
u8 *dvsec_start, *cap_start;
743743

744-
if (!(prot_err->valid_bits & PROT_ERR_VALID_AGENT_ADDRESS)) {
745-
pr_err_ratelimited("CXL CPER invalid agent type\n");
744+
if (cxl_cper_sec_prot_err_valid(prot_err))
746745
return;
747-
}
748-
749-
if (!(prot_err->valid_bits & PROT_ERR_VALID_ERROR_LOG)) {
750-
pr_err_ratelimited("CXL CPER invalid protocol error log\n");
751-
return;
752-
}
753-
754-
if (prot_err->err_len != sizeof(struct cxl_ras_capability_regs)) {
755-
pr_err_ratelimited("CXL CPER invalid RAS Cap size (%u)\n",
756-
prot_err->err_len);
757-
return;
758-
}
759-
760-
if (!(prot_err->valid_bits & PROT_ERR_VALID_SERIAL_NUMBER))
761-
pr_warn(FW_WARN "CXL CPER no device serial number\n");
762746

763747
guard(spinlock_irqsave)(&cxl_cper_prot_err_work_lock);
764748

drivers/acpi/apei/ghes_helpers.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
// Copyright(c) 2025 Intel Corporation. All rights reserved
3+
4+
#include <linux/printk.h>
5+
#include <cxl/event.h>
6+
7+
int cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err)
8+
{
9+
if (!(prot_err->valid_bits & PROT_ERR_VALID_AGENT_ADDRESS)) {
10+
pr_err_ratelimited("CXL CPER invalid agent type\n");
11+
return -EINVAL;
12+
}
13+
14+
if (!(prot_err->valid_bits & PROT_ERR_VALID_ERROR_LOG)) {
15+
pr_err_ratelimited("CXL CPER invalid protocol error log\n");
16+
return -EINVAL;
17+
}
18+
19+
if (prot_err->err_len != sizeof(struct cxl_ras_capability_regs)) {
20+
pr_err_ratelimited("CXL CPER invalid RAS Cap size (%u)\n",
21+
prot_err->err_len);
22+
return -EINVAL;
23+
}
24+
25+
if ((prot_err->agent_type == RCD || prot_err->agent_type == DEVICE ||
26+
prot_err->agent_type == LD || prot_err->agent_type == FMLD) &&
27+
!(prot_err->valid_bits & PROT_ERR_VALID_SERIAL_NUMBER))
28+
pr_warn_ratelimited(FW_WARN
29+
"CXL CPER no device serial number\n");
30+
31+
return 0;
32+
}
33+
EXPORT_SYMBOL_GPL(cxl_cper_sec_prot_err_valid);

include/cxl/event.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,14 @@ static inline int cxl_cper_prot_err_kfifo_get(struct cxl_cper_prot_err_work_data
320320
}
321321
#endif
322322

323+
#ifdef CONFIG_ACPI_APEI_PCIEAER
324+
int cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err);
325+
#else
326+
static inline int
327+
cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err)
328+
{
329+
return -EOPNOTSUPP;
330+
}
331+
#endif
332+
323333
#endif /* _LINUX_CXL_EVENT_H */

0 commit comments

Comments
 (0)