Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 849599b702ef8 ("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

authored by

Sourabh Jain and committed by
Madhavan Srinivasan
04e707cb 20197b96

+13 -1
+13 -1
arch/powerpc/kexec/file_load_64.c
··· 450 450 kbuf->buffer = headers; 451 451 kbuf->mem = KEXEC_BUF_MEM_UNKNOWN; 452 452 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 + */ 453 458 kbuf->memsz = headers_sz + kdump_extra_elfcorehdr_size(cmem); 454 459 kbuf->top_down = false; 455 460 ··· 465 460 } 466 461 467 462 image->elf_load_addr = kbuf->mem; 468 - image->elf_headers_sz = headers_sz; 463 + 464 + /* 465 + * If CONFIG_CRASH_HOTPLUG is enabled, the elfcorehdr kexec segment 466 + * memsz can be larger than bufsz. Always initialize elf_headers_sz 467 + * with memsz. This ensures the correct size is reserved for elfcorehdr 468 + * memory in the FDT prepared for kdump. 469 + */ 470 + image->elf_headers_sz = kbuf->memsz; 469 471 image->elf_headers = headers; 470 472 out: 471 473 kfree(cmem);