From: Sourabh Jain <sourabhjain@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>,
Hari Bathini <hbathini@linux.ibm.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Mahesh Salgaonkar <mahesh@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
Shivang Upadhyay <shivangu@linux.ibm.com>,
Aditya Gupta <adityag@linux.ibm.com>
Subject: [PATCH v3 0/2] powerpc/crash: backup region offset update to eflcorehdr
Date: Thu, 12 Mar 2026 14:00:48 +0530 [thread overview]
Message-ID: <20260312083051.1935737-1-sourabhjain@linux.ibm.com> (raw)
On a kernel crash, purgatory copies the first 64 KB of the crashed
kernel memory to the backup memory region reserved within crashkernel
memory for the kdump kernel. This ensures that the capture kernel can
use the first 64 KB of memory to place the exception vectors and other
required data.
However, in the elfcorehdr prepared using the kexec_file_load syscall,
or the one recreated during a memory hotplug event, the offset of the
program header representing the first 64 KB of memory is set to 0,
whereas it should point to the backup region.
This has not caused issues so far because the first 64 KB is usually
identical in both the crashed and capture kernels. However, this is
only an assumption and is not guaranteed to always hold true.
Therefore, update the offset of the program header representing the
first 64 KB of the crashed kernel memory in the elfcorehdr prepared for
the kdump kernel.
Testing:
=======
Git Tree: https://github.com/sourabhjains/linux/commits/kdump-backup-region-offset/
The above tree contains an additional patch that introduces a new sysfs
interface to dump the kdump elfcorehdr to the dmesg/console.
$> cat /sys/kernel/kexec/crash_elfcorehdr_print
ELF Program Header Summary:
Total Program Headers: 13 (0xd)
PT_LOAD segments: 4 (0x4)
PT_NOTE segments: 9 (0x9)
Program Headers:
Index Type Offset VirtAddr PhysAddr FileSize MemSize Flags
================================================================================
0x0 PT_NOTE 0x3fd966400 0x0 0x3fd966400 0x218 0x218 ---
0x1 PT_NOTE 0x3fd996400 0x0 0x3fd996400 0x218 0x218 ---
0x2 PT_NOTE 0x3fd9c6400 0x0 0x3fd9c6400 0x218 0x218 ---
0x3 PT_NOTE 0x3fd9f6400 0x0 0x3fd9f6400 0x218 0x218 ---
0x4 PT_NOTE 0x3fda26400 0x0 0x3fda26400 0x218 0x218 ---
0x5 PT_NOTE 0x3fda56400 0x0 0x3fda56400 0x218 0x218 ---
0x6 PT_NOTE 0x3fda86400 0x0 0x3fda86400 0x218 0x218 ---
0x7 PT_NOTE 0x3fdab6400 0x0 0x3fdab6400 0x218 0x218 ---
0x8 PT_NOTE 0xa2c0000 0x0 0xa2c0000 0x10024 0x10024 ---
0x9 PT_LOAD 0x1af40000 0xc000000000000000 0x0 0x10000 0x10000 RWX
0xa PT_LOAD 0x10000 0xc000000000010000 0x10000 0x17ff0000 0x17ff0000 RWX
0xb PT_LOAD 0x2ec70000 0xc00000002ec70000 0x2ec70000 0x1390000 0x1390000 RWX
0xc PT_LOAD 0x58000000 0xc000000058000000 0x58000000 0x3a8000000 0x3a8000000 RWX
So, once kdump is successfully loaded using the kexec command,
for example:
$ kexec --initrd=/boot/initramfs-`uname -r`.img /boot/vmlinuz-`uname -r` --append="`cat /proc/cmdline`" -pds
Running cat /sys/kernel/kexec/crash_elfcorehdr_print prints the
elfcorehdr in the above format. The offset of the program header
representing the first 64 KB can be easily observed.
Changlog:
v1:
https://lore.kernel.org/all/20260303134722.2814049-1-sourabhjain@linux.ibm.com/
v2:
https://lore.kernel.org/all/20260307052102.944952-1-sourabhjain@linux.ibm.com/
- Fix build error: 'struct kimage' has no member named 'arch'
How?
Define ARCH_HAS_KIMAGE_ARCH and struct kimage_arch when
CONFIG_KEXEC_FILE or CONFIG_CRASH_DUMP is enabled so that
kimage->arch.backup_start is available with the kexec_load syscall.
v3:
- Fix a typo in a commit message 01/02
- Add a comment for a helper function in 02/02
- Add Reviewed-by tag
- No functional changes
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>
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>
Cc: Aditya Gupta <adityag@linux.ibm.com>
Sourabh Jain (2):
powerpc/crash: fix backup region offset update to elfcorehdr
powerpc/crash: Update backup region offset in elfcorehdr on memory
hotplug
arch/powerpc/include/asm/kexec.h | 14 +++++--
arch/powerpc/kexec/crash.c | 64 +++++++++++++++++++++++++++++++
arch/powerpc/kexec/file_load_64.c | 29 +-------------
3 files changed, 76 insertions(+), 31 deletions(-)
--
2.52.0
next reply other threads:[~2026-03-12 8:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 8:30 Sourabh Jain [this message]
2026-03-12 8:30 ` [PATCH v3 1/2] powerpc/crash: fix backup region offset update to elfcorehdr Sourabh Jain
2026-03-12 8:36 ` Hari Bathini
2026-03-12 10:44 ` Sourabh Jain
2026-03-12 8:30 ` [PATCH v3 2/2] powerpc/crash: Update backup region offset in elfcorehdr on memory hotplug Sourabh Jain
2026-04-08 4:29 ` [PATCH v3 0/2] powerpc/crash: backup region offset update to eflcorehdr Madhavan Srinivasan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260312083051.1935737-1-sourabhjain@linux.ibm.com \
--to=sourabhjain@linux.ibm.com \
--cc=adityag@linux.ibm.com \
--cc=hbathini@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mahesh@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=ritesh.list@gmail.com \
--cc=shivangu@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox