[PATCH v4 12/12] efi/cper: Increase memory error location and detail buffer sizes

From: Pierre Gondois

Date: Fri Nov 13 2026 - 10:44:04 EST


Memory Error Section 2 descriptions can exceed the existing buffers.
Helpers require:

1. cper_mem_err2_location(): ~263 chars:
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. cper_dimm_err2_location(): 17 + strlen(bank) + strlen(device):
DIMM location: <bank> <device>
Or ~51 chars:
DIMM location: not present. DMI handle: 0xffffffff

3. print_mem_error2_other_detail(): ~65 + strlen(location) +
strlen(status):
APEI location: <location> status(0xffffffffffff13ff): <status>
section_status:0xff

Increase the size of:
- CPER_REC_LEN: used to store the output of [1] or [2]
- LOCATION_SIZE: used to store the output of [1] + [2]
- OTHER_DETAIL_LEN: used to store the output of [3]
(which includes the size of the location buffer).

Signed-off-by: Pierre Gondois <pierre.gondois@xxxxxxx>
---
drivers/edac/ghes_edac.c | 3 ++-
include/linux/cper.h | 4 ++--
include/linux/edac.h | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
index 33e3aa897c18..d3544dc20649 100644
--- a/drivers/edac/ghes_edac.c
+++ b/drivers/edac/ghes_edac.c
@@ -17,7 +17,8 @@
#include <linux/notifier.h>
#include <linux/string.h>

-#define OTHER_DETAIL_LEN 400
+/* Allow 65 formatting characters plus the longest status description (63). */
+#define OTHER_DETAIL_LEN (LOCATION_SIZE + 128)

struct ghes_pvt {
struct mem_ctl_info *mci;
diff --git a/include/linux/cper.h b/include/linux/cper.h
index db69995a43bf..a8eedc098bb0 100644
--- a/include/linux/cper.h
+++ b/include/linux/cper.h
@@ -29,9 +29,9 @@
* CPER record length contains the CPER fields which are relevant for further
* handling of a memory error in userspace (we don't carry all the fields
* defined in the UEFI spec because some of them don't make any sense.)
- * Currently, a length of 256 should be more than enough.
+ * Allow room for the wider fields in Memory Error Section 2.
*/
-#define CPER_REC_LEN 256
+#define CPER_REC_LEN 512
/*
* Severity definition for error_severity in struct cper_record_header
* and section_severity in struct cper_section_descriptor
diff --git a/include/linux/edac.h b/include/linux/edac.h
index f7a8218f9cc0..ef0569aa97be 100644
--- a/include/linux/edac.h
+++ b/include/linux/edac.h
@@ -48,7 +48,7 @@ static inline void opstate_init(void)
#define EDAC_MC_LABEL_LEN 31

/* Maximum size of the location string */
-#define LOCATION_SIZE 256
+#define LOCATION_SIZE 512

/* Defines the maximum number of labels that can be reported */
#define EDAC_MAX_LABELS 8
--
2.43.0