From e393fd00a4a06d305afbec244c38f98491ce5b1d Mon Sep 17 00:00:00 2001 From: Maximilian Brune Date: Wed, 27 Aug 2025 21:12:43 +0200 Subject: [PATCH] include/cper.h: Update cper_ia32x64_context_t Use flexible array member cper_ia32x64_context to simplify the struct usage. Change-Id: I729cb914031b55b2b58bc9e459ee0ea15c7626e8 Signed-off-by: Maximilian Brune Reviewed-on: https://review.coreboot.org/c/coreboot/+/90479 Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) --- src/arch/x86/acpi_bert_storage.c | 6 ++---- src/include/cper.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/arch/x86/acpi_bert_storage.c b/src/arch/x86/acpi_bert_storage.c index e9b9fc563a..321f66ac54 100644 --- a/src/arch/x86/acpi_bert_storage.c +++ b/src/arch/x86/acpi_bert_storage.c @@ -550,8 +550,6 @@ cper_ia32x64_context_t *cper_new_ia32x64_context_msr( cper_ia32x64_proc_error_section_t *x86err, u32 addr, int num) { cper_ia32x64_context_t *ctx; - int i; - msr_t *dest; ctx = new_cper_ia32x64_ctx(status, x86err, CPER_IA32X64_CTX_MSR, num * sizeof(msr_t)); if (!ctx) @@ -564,9 +562,9 @@ cper_ia32x64_context_t *cper_new_ia32x64_context_msr( */ ctx->msr_addr = addr; - dest = (msr_t *)((u8 *)(ctx + 1)); /* point to the Register Array */ + msr_t *dest = (msr_t *)(ctx->register_array); /* point to the Register Array */ - for (i = 0 ; i < num ; i++) + for (int i = 0 ; i < num ; i++) *(dest + i) = rdmsr(addr + i); return ctx; } diff --git a/src/include/cper.h b/src/include/cper.h index d0f7b30581..4dec2a2247 100644 --- a/src/include/cper.h +++ b/src/include/cper.h @@ -289,7 +289,7 @@ typedef struct cper_ia32x64_context { u16 array_size; u32 msr_addr; u64 mmap_addr; - /* N bytes of register array */ + u8 register_array[]; /* N bytes of register array */ } __packed cper_ia32x64_context_t; /* IA32/X64 Processor Context Information, Types field (Table N.13) */