mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drivers/firmware/efi: Fix cper_ia_proc_ctx alignment
@ 2025-02-21  8:12 Patrick Rudolph
  2025-02-21  9:05 ` Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Rudolph @ 2025-02-21  8:12 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Patrick Rudolph, linux-efi, linux-kernel

According to the UEFI Common Platform Error Record appendix, the
IA32/X64 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-x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/cper-x86.c b/drivers/firmware/efi/cper-x86.c
index 438ed9eff6d0..3949d7b5e808 100644
--- a/drivers/firmware/efi/cper-x86.c
+++ b/drivers/firmware/efi/cper-x86.c
@@ -325,7 +325,7 @@ void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc)
 
 	ctx_info = (struct cper_ia_proc_ctx *)err_info;
 	for (i = 0; i < VALID_PROC_CXT_INFO_NUM(proc->validation_bits); i++) {
-		int size = sizeof(*ctx_info) + ctx_info->reg_arr_size;
+		int size = ALIGN(sizeof(*ctx_info) + ctx_info->reg_arr_size, 16);
 		int groupsize = 4;
 
 		printk("%sContext Information Structure %d:\n", pfx, i);
-- 
2.48.1


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

* Re: [PATCH] drivers/firmware/efi: Fix cper_ia_proc_ctx alignment
  2025-02-21  8:12 [PATCH] drivers/firmware/efi: Fix cper_ia_proc_ctx alignment Patrick Rudolph
@ 2025-02-21  9:05 ` Ard Biesheuvel
  0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2025-02-21  9:05 UTC (permalink / raw)
  To: Patrick Rudolph; +Cc: linux-efi, linux-kernel

On Fri, 21 Feb 2025 at 09:13, Patrick Rudolph
<patrick.rudolph@9elements.com> wrote:
>
> According to the UEFI Common Platform Error Record appendix, the
> IA32/X64 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-x86.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/efi/cper-x86.c b/drivers/firmware/efi/cper-x86.c
> index 438ed9eff6d0..3949d7b5e808 100644
> --- a/drivers/firmware/efi/cper-x86.c
> +++ b/drivers/firmware/efi/cper-x86.c
> @@ -325,7 +325,7 @@ void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc)
>
>         ctx_info = (struct cper_ia_proc_ctx *)err_info;
>         for (i = 0; i < VALID_PROC_CXT_INFO_NUM(proc->validation_bits); i++) {
> -               int size = sizeof(*ctx_info) + ctx_info->reg_arr_size;
> +               int size = ALIGN(sizeof(*ctx_info) + ctx_info->reg_arr_size, 16);
>                 int groupsize = 4;
>
>                 printk("%sContext Information Structure %d:\n", pfx, i);

Thanks for the patch. It seems ARM suffers from the same issue, mind
fixing that too?

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

end of thread, other threads:[~2025-02-21  9:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-21  8:12 [PATCH] drivers/firmware/efi: Fix cper_ia_proc_ctx alignment Patrick Rudolph
2025-02-21  9:05 ` Ard Biesheuvel

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

all inboxes | Powered by JetHome®