* [PATCH] powerpc/crash: adjust the elfcorehdr size
@ 2026-02-18 5:01 Sourabh Jain
2026-02-20 10:24 ` Hari Bathini
0 siblings, 1 reply; 3+ messages in thread
From: Sourabh Jain @ 2026-02-18 5:01 UTC (permalink / raw)
To: linuxppc-dev
Cc: Sourabh Jain, Hari Bathini, Madhavan Srinivasan,
Mahesh Salgaonkar, Michael Ellerman, Ritesh Harjani (IBM),
Shivang Upadhyay
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")
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Cc: Shivang Upadhyay <shivangu@linux.ibm.com>
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
---
arch/powerpc/kexec/file_load_64.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index e7ef8b2a2554..ed76326f4b57 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -460,7 +460,7 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf)
}
image->elf_load_addr = kbuf->mem;
- image->elf_headers_sz = headers_sz;
+ image->elf_headers_sz = kbuf->memsz;
image->elf_headers = headers;
out:
kfree(cmem);
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/crash: adjust the elfcorehdr size
2026-02-18 5:01 [PATCH] powerpc/crash: adjust the elfcorehdr size Sourabh Jain
@ 2026-02-20 10:24 ` Hari Bathini
2026-02-24 4:04 ` Sourabh Jain
0 siblings, 1 reply; 3+ messages in thread
From: Hari Bathini @ 2026-02-20 10:24 UTC (permalink / raw)
To: Sourabh Jain, linuxppc-dev
Cc: Madhavan Srinivasan, Mahesh Salgaonkar, Michael Ellerman,
Ritesh Harjani (IBM), Shivang Upadhyay
On 18/02/26 10:31 am, Sourabh Jain wrote:
> 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")
> Cc: Hari Bathini <hbathini@linux.ibm.com>
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> Cc: Shivang Upadhyay <shivangu@linux.ibm.com>
> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
> ---
> arch/powerpc/kexec/file_load_64.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
> index e7ef8b2a2554..ed76326f4b57 100644
> --- a/arch/powerpc/kexec/file_load_64.c
> +++ b/arch/powerpc/kexec/file_load_64.c
> @@ -460,7 +460,7 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf)
> }
>
> image->elf_load_addr = kbuf->mem;
> - image->elf_headers_sz = headers_sz;
> + image->elf_headers_sz = kbuf->memsz;
A comment here explaining why memsz is used instead of headers_sz and
also, another comment where memsz is set, as to why extra memory size
is accounted under it, improves readability...
Regardless..
Reviewed-by: Hari Bathini <hbathini@linux.ibm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/crash: adjust the elfcorehdr size
2026-02-20 10:24 ` Hari Bathini
@ 2026-02-24 4:04 ` Sourabh Jain
0 siblings, 0 replies; 3+ messages in thread
From: Sourabh Jain @ 2026-02-24 4:04 UTC (permalink / raw)
To: Hari Bathini, linuxppc-dev
Cc: Madhavan Srinivasan, Mahesh Salgaonkar, Michael Ellerman,
Ritesh Harjani (IBM), Shivang Upadhyay
On 20/02/26 15:54, Hari Bathini wrote:
>
>
> On 18/02/26 10:31 am, Sourabh Jain wrote:
>> 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")
>> Cc: Hari Bathini <hbathini@linux.ibm.com>
>> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
>> Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>> Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
>> Cc: Shivang Upadhyay <shivangu@linux.ibm.com>
>> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
>> ---
>> arch/powerpc/kexec/file_load_64.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/kexec/file_load_64.c
>> b/arch/powerpc/kexec/file_load_64.c
>> index e7ef8b2a2554..ed76326f4b57 100644
>> --- a/arch/powerpc/kexec/file_load_64.c
>> +++ b/arch/powerpc/kexec/file_load_64.c
>> @@ -460,7 +460,7 @@ static int load_elfcorehdr_segment(struct kimage
>> *image, struct kexec_buf *kbuf)
>> }
>> image->elf_load_addr = kbuf->mem;
>
>> - image->elf_headers_sz = headers_sz;
>> + image->elf_headers_sz = kbuf->memsz;
>
> A comment here explaining why memsz is used instead of headers_sz and
> also, another comment where memsz is set, as to why extra memory size
> is accounted under it, improves readability...
Sure I will update the commit message in the next version.
>
> Regardless..
>
> Reviewed-by: Hari Bathini <hbathini@linux.ibm.com>
Thanks for the review.
- Sourabh Jain
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-24 4:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-18 5:01 [PATCH] powerpc/crash: adjust the elfcorehdr size Sourabh Jain
2026-02-20 10:24 ` Hari Bathini
2026-02-24 4:04 ` Sourabh Jain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox