Skip to contentSkip to conversation

efi/cper: Fix cper_arm_ctx_info alignment

PATCH In review Patrick Rudolph 2 participants 2 messages Feb 21, 2025 – Feb 23, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi/cper: Fix cper_arm_ctx_info alignment

According to the UEFI Common Platform Error Record appendix, the processor context information structure is a variable length structure, but "is padded with zeros if the size is not a multiple of 16 bytes".

Currently this isn't honoured, causing all but the first structure to be garbage when printed. Thus align the size to be a multiple of 16.

---
 drivers/firmware/efi/cper-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/cper-arm.c +1 -1
index fa9c1c3bf168..f0a63d09d3c4 100644
@@ -311,7 +311,7 @@ void cper_print_proc_arm(const char *pfx,
 	ctx_info = (struct cper_arm_ctx_info *)err_info;
 	max_ctx_type = ARRAY_SIZE(arm_reg_ctx_strs) - 1;
 	for (i = 0; i < proc->context_info_num; i++) {
-		int size = sizeof(*ctx_info) + ctx_info->size;
+		int size = ALIGN(sizeof(*ctx_info) + ctx_info->size, 16);
 
 		printk("%sContext info structure %d:\n", pfx, i);
 		if (len < size) {
Signature · 1 line
2.48.1
maintainer
#1 lore raw
Quoted 9 lines · Patrick Rudolph

According to the UEFI Common Platform Error Record appendix, the processor context information structure is a variable length structure, but "is padded with zeros if the size is not a multiple of 16 bytes".

Currently this isn't honoured, causing all but the first structure to be garbage when printed. Thus align the size to be a multiple of 16.

Thanks. Both patched queued up now in efi/urgent

Quoted 20 lines
---
 drivers/firmware/efi/cper-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/cper-arm.c +1 -2
index fa9c1c3bf168..f0a63d09d3c4 100644
@@ -311,7 +311,7 @@ void cper_print_proc_arm(const char *pfx,
        ctx_info = (struct cper_arm_ctx_info *)err_info;
        max_ctx_type = ARRAY_SIZE(arm_reg_ctx_strs) - 1;
        for (i = 0; i < proc->context_info_num; i++) {
-               int size = sizeof(*ctx_info) + ctx_info->size;
+               int size = ALIGN(sizeof(*ctx_info) + ctx_info->size, 16);
 
                printk("%sContext info structure %d:\n", pfx, i);
                if (len < size) {
--

2.48.1