public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi/cper: Fix cper_arm_ctx_info alignment
@ 2025-02-21 11:15 Patrick Rudolph
  2025-02-23 16:33 ` Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Rudolph @ 2025-02-21 11:15 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Patrick Rudolph, linux-efi, linux-kernel

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.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
 drivers/firmware/efi/cper-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/cper-arm.c b/drivers/firmware/efi/cper-arm.c
index fa9c1c3bf168..f0a63d09d3c4 100644
--- a/drivers/firmware/efi/cper-arm.c
+++ b/drivers/firmware/efi/cper-arm.c
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] efi/cper: Fix cper_arm_ctx_info alignment
  2025-02-21 11:15 [PATCH] efi/cper: Fix cper_arm_ctx_info alignment Patrick Rudolph
@ 2025-02-23 16:33 ` Ard Biesheuvel
  0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2025-02-23 16:33 UTC (permalink / raw)
  To: Patrick Rudolph; +Cc: linux-efi, linux-kernel

On Fri, 21 Feb 2025 at 12:15, Patrick Rudolph
<patrick.rudolph@9elements.com> wrote:
>
> 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.
>
> Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>

Thanks. Both patched queued up now in efi/urgent


> ---
>  drivers/firmware/efi/cper-arm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/efi/cper-arm.c b/drivers/firmware/efi/cper-arm.c
> index fa9c1c3bf168..f0a63d09d3c4 100644
> --- a/drivers/firmware/efi/cper-arm.c
> +++ b/drivers/firmware/efi/cper-arm.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-23 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21 11:15 [PATCH] efi/cper: Fix cper_arm_ctx_info alignment Patrick Rudolph
2025-02-23 16:33 ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox