Skip to content

Commit 475f63a

Browse files
lian-boIngo Molnar
authored andcommitted
kexec_file: Correctly output debugging information for the PT_LOAD ELF header
Currently, when we enable the debugging switch to debug kexec_file, we always get the following incorrect results: kexec_file: Crash PT_LOAD elf header. phdr=00000000c988639b vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=51 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=000000003cca69a0 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=52 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000c584cb9f vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=53 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000cf85d57f vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=54 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000a4a8f847 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=55 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000272ec49f vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=56 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000ea0b65de vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=57 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=000000001f5e490c vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=58 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000dfe4109e vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=59 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000480ed2b6 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=60 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=0000000080b65151 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=61 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=0000000024e31c5e vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=62 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000332e0385 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=63 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=000000002754d5da vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=64 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000783320dd vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=65 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=0000000076fe5b64 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=66 p_offset=0x0 The reason is that kernel always prints the values of the next PT_LOAD instead of the current PT_LOAD. Change it to ensure that we can get the correct debugging information. [ mingo: Amended changelog, capitalized "ELF". ] Signed-off-by: Lianbo Jiang <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Dave Young <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a2e9a95 commit 475f63a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/kexec_file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,15 +1246,15 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map,
12461246
unsigned long long notes_addr;
12471247
unsigned long mstart, mend;
12481248

1249-
/* extra phdr for vmcoreinfo elf note */
1249+
/* extra phdr for vmcoreinfo ELF note */
12501250
nr_phdr = nr_cpus + 1;
12511251
nr_phdr += mem->nr_ranges;
12521252

12531253
/*
12541254
* kexec-tools creates an extra PT_LOAD phdr for kernel text mapping
12551255
* area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64).
12561256
* I think this is required by tools like gdb. So same physical
1257-
* memory will be mapped in two elf headers. One will contain kernel
1257+
* memory will be mapped in two ELF headers. One will contain kernel
12581258
* text virtual addresses and other will have __va(physical) addresses.
12591259
*/
12601260

@@ -1323,10 +1323,10 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map,
13231323
phdr->p_filesz = phdr->p_memsz = mend - mstart + 1;
13241324
phdr->p_align = 0;
13251325
ehdr->e_phnum++;
1326-
phdr++;
1327-
pr_debug("Crash PT_LOAD elf header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n",
1326+
pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n",
13281327
phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz,
13291328
ehdr->e_phnum, phdr->p_offset);
1329+
phdr++;
13301330
}
13311331

13321332
*addr = buf;

0 commit comments

Comments
 (0)