mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-01 10:42:11 +00:00
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 <lijiang@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Dave Young <dyoung@redhat.com> Link: https://lore.kernel.org/r/20200804044933.1973-4-lijiang@redhat.com
This commit is contained in:
parent
a2e9a95d21
commit
475f63ae63
@ -1246,7 +1246,7 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map,
|
|||||||
unsigned long long notes_addr;
|
unsigned long long notes_addr;
|
||||||
unsigned long mstart, mend;
|
unsigned long mstart, mend;
|
||||||
|
|
||||||
/* extra phdr for vmcoreinfo elf note */
|
/* extra phdr for vmcoreinfo ELF note */
|
||||||
nr_phdr = nr_cpus + 1;
|
nr_phdr = nr_cpus + 1;
|
||||||
nr_phdr += mem->nr_ranges;
|
nr_phdr += mem->nr_ranges;
|
||||||
|
|
||||||
@ -1254,7 +1254,7 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map,
|
|||||||
* kexec-tools creates an extra PT_LOAD phdr for kernel text mapping
|
* kexec-tools creates an extra PT_LOAD phdr for kernel text mapping
|
||||||
* area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64).
|
* area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64).
|
||||||
* I think this is required by tools like gdb. So same physical
|
* I think this is required by tools like gdb. So same physical
|
||||||
* memory will be mapped in two elf headers. One will contain kernel
|
* memory will be mapped in two ELF headers. One will contain kernel
|
||||||
* text virtual addresses and other will have __va(physical) addresses.
|
* text virtual addresses and other will have __va(physical) addresses.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1323,10 +1323,10 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map,
|
|||||||
phdr->p_filesz = phdr->p_memsz = mend - mstart + 1;
|
phdr->p_filesz = phdr->p_memsz = mend - mstart + 1;
|
||||||
phdr->p_align = 0;
|
phdr->p_align = 0;
|
||||||
ehdr->e_phnum++;
|
ehdr->e_phnum++;
|
||||||
phdr++;
|
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",
|
||||||
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",
|
|
||||||
phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz,
|
phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz,
|
||||||
ehdr->e_phnum, phdr->p_offset);
|
ehdr->e_phnum, phdr->p_offset);
|
||||||
|
phdr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*addr = buf;
|
*addr = buf;
|
||||||
|
Loading…
Reference in New Issue
Block a user