Skip to contentSkip to conversation

where/how 2nd kernel's elfcorehdr_addr comes from

DISCUSSION [email protected] 2 participants 3 messages Nov 4, 2022 – Nov 5, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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 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@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
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw
Quoted 10 lines · Zhijian/李 智坚

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.

Quoted 8 lines

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

Quoted 58 lines

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@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);

Quoted 7 lines

kernel/crash_dump.c:            elfcorehdr_size = elfcorehdr_addr;

kernel/crash_dump.c:            elfcorehdr_addr = memparse(end + 1, &end);

Thanks

Zhijian

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw
In reply to [email protected]
Quoted 14 lines · On 11/04/22 at 09:03am, [email protected] 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.

Quoted 7 lines

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 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.

Since you have studied this, so:
crash_prepare_elf64_headers() is the place where elf header of vmcore is contructed in 1st kernel. And in crash_load_segments() it's prepared to be passed out. I am talking about x86, and kexec_file load. You should be able to find the similar thing in user space code.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec