where/how 2nd kernel's elfcorehdr_addr comes from

lizhijian at fujitsu.com lizhijian at fujitsu.com
Fri Nov 4 18:38:56 PDT 2022


On 04/11/2022 17:03, Li, Zhijian/李 智坚 wrote:
> Hi folks,
>
> I'm trying to add pmem's metadata(located at pmem device) to
> /proc/vmcore. To accomplish this, I think
>
> something i need to know is where the contents of /proc/vmcore come
> from, and then append
>
> something into it.
>
> I have read
> https://opensource.com/article/17/6/kdump-usage-and-internals, and knew
> /proc/vmcore is a elf file.
>
> It mentioned that "Creates /proc/vmcore as per elfcorehdr information
> received", but i don't get how it
>
> elfcorehdr(maybe elfcorehdr_addr) be assigned in 2nd kernel.

I got it, elfcorehdr comes from 1st kernel's kexec-tools which passes 
elfcorehdr=xxx to 2nd kernel

Thanks


>
> I tried to grep it in the kernel source, but still no answer.  So i deep
> hope you guys can give me some hints or answer.
>
> and thank you in advance :)
>
> [root at iaas-rpma linux]# git grep elfcorehdr_addr | grep -v -w -e ia64 -e
> loongarch -e mips -e powerpc  -e riscv
>
> arch/s390/kernel/setup.c:       elfcorehdr_addr = ELFCORE_ADDR_MAX;
>
> drivers/of/fdt.c:       if (memblock_is_region_reserved(elfcorehdr_addr,
> elfcorehdr_size)) {
>
> drivers/of/fdt.c:       memblock_reserve(elfcorehdr_addr, elfcorehdr_size);
>
> drivers/of/fdt.c:               elfcorehdr_size >> 10, elfcorehdr_addr);
>
> drivers/of/fdt.c:       elfcorehdr_addr =
> dt_mem_next_cell(dt_root_addr_cells, &prop);
>
> drivers/of/fdt.c:                elfcorehdr_addr, elfcorehdr_size);
>
> fs/proc/vmcore.c:       addr = elfcorehdr_addr;
>
> fs/proc/vmcore.c:       addr = elfcorehdr_addr;
>
> fs/proc/vmcore.c:       addr = elfcorehdr_addr;
>
> fs/proc/vmcore.c:       addr = elfcorehdr_addr;
>
> fs/proc/vmcore.c:       addr = elfcorehdr_addr;
>
> fs/proc/vmcore.c:       rc = elfcorehdr_alloc(&elfcorehdr_addr,
> &elfcorehdr_size);
>
> fs/proc/vmcore.c:       elfcorehdr_free(elfcorehdr_addr);
>
> fs/proc/vmcore.c:       elfcorehdr_addr = ELFCORE_ADDR_ERR;
>
> include/linux/crash_dump.h:extern unsigned long long elfcorehdr_addr;
>
> include/linux/crash_dump.h:     return elfcorehdr_addr != ELFCORE_ADDR_MAX;
>
> include/linux/crash_dump.h:     return is_kdump_kernel() &&
> elfcorehdr_addr != ELFCORE_ADDR_ERR ? 1 : 0;
>
> include/linux/crash_dump.h:             elfcorehdr_addr = ELFCORE_ADDR_ERR;
>
> kernel/crash_dump.c: * Note: elfcorehdr_addr is not just limited to
> vmcore. It is also used by
>
> kernel/crash_dump.c:unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
>
> kernel/crash_dump.c:EXPORT_SYMBOL_GPL(elfcorehdr_addr);
>
> kernel/crash_dump.c:    elfcorehdr_addr = memparse(arg, &end);
>
> kernel/crash_dump.c:            elfcorehdr_size = elfcorehdr_addr;
>
> kernel/crash_dump.c:            elfcorehdr_addr = memparse(end + 1, &end);
>
> Thanks
>
> Zhijian


More information about the kexec mailing list