Skip to content

Commit 04e707c

Browse files
sourabhjainsmaddy-kerneldev
authored andcommitted
powerpc/crash: adjust the elfcorehdr size
With crash hotplug support enabled, additional memory is allocated to the elfcorehdr kexec segment to accommodate resources added during memory hotplug events. However, the kdump FDT is not updated with the same size, which can result in elfcorehdr corruption in the kdump kernel. Update elf_headers_sz (the kimage member representing the size of the elfcorehdr kexec segment) to reflect the total memory allocated for the elfcorehdr segment instead of the elfcorehdr buffer size at the time of kdump load. This allows of_kexec_alloc_and_setup_fdt() to reserve the full elfcorehdr memory in the kdump FDT and prevents elfcorehdr corruption. Fixes: 849599b ("powerpc/crash: add crash memory hotplug support") Reviewed-by: Hari Bathini <hbathini@linux.ibm.com> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20260227171801.2238847-1-sourabhjain@linux.ibm.com
1 parent 20197b9 commit 04e707c

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

arch/powerpc/kexec/file_load_64.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,11 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf)
450450
kbuf->buffer = headers;
451451
kbuf->mem = KEXEC_BUF_MEM_UNKNOWN;
452452
kbuf->bufsz = headers_sz;
453+
454+
/*
455+
* Account for extra space required to accommodate additional memory
456+
* ranges in elfcorehdr due to memory hotplug events.
457+
*/
453458
kbuf->memsz = headers_sz + kdump_extra_elfcorehdr_size(cmem);
454459
kbuf->top_down = false;
455460

@@ -460,7 +465,14 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf)
460465
}
461466

462467
image->elf_load_addr = kbuf->mem;
463-
image->elf_headers_sz = headers_sz;
468+
469+
/*
470+
* If CONFIG_CRASH_HOTPLUG is enabled, the elfcorehdr kexec segment
471+
* memsz can be larger than bufsz. Always initialize elf_headers_sz
472+
* with memsz. This ensures the correct size is reserved for elfcorehdr
473+
* memory in the FDT prepared for kdump.
474+
*/
475+
image->elf_headers_sz = kbuf->memsz;
464476
image->elf_headers = headers;
465477
out:
466478
kfree(cmem);

0 commit comments

Comments
 (0)