aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/crash.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/crash.c')
-rw-r--r--arch/x86/kernel/crash.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index 8175c0c205e6..229b8ecf8428 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -337,7 +337,7 @@ static int prepare_elf64_headers(struct crash_mem *cmem, bool kernel_map,
337 Elf64_Ehdr *ehdr; 337 Elf64_Ehdr *ehdr;
338 Elf64_Phdr *phdr; 338 Elf64_Phdr *phdr;
339 unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; 339 unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz;
340 unsigned char *buf, *bufp; 340 unsigned char *buf;
341 unsigned int cpu, i; 341 unsigned int cpu, i;
342 unsigned long long notes_addr; 342 unsigned long long notes_addr;
343 unsigned long mstart, mend; 343 unsigned long mstart, mend;
@@ -362,9 +362,8 @@ static int prepare_elf64_headers(struct crash_mem *cmem, bool kernel_map,
362 if (!buf) 362 if (!buf)
363 return -ENOMEM; 363 return -ENOMEM;
364 364
365 bufp = buf; 365 ehdr = (Elf64_Ehdr *)buf;
366 ehdr = (Elf64_Ehdr *)bufp; 366 phdr = (Elf64_Phdr *)(ehdr + 1);
367 bufp += sizeof(Elf64_Ehdr);
368 memcpy(ehdr->e_ident, ELFMAG, SELFMAG); 367 memcpy(ehdr->e_ident, ELFMAG, SELFMAG);
369 ehdr->e_ident[EI_CLASS] = ELFCLASS64; 368 ehdr->e_ident[EI_CLASS] = ELFCLASS64;
370 ehdr->e_ident[EI_DATA] = ELFDATA2LSB; 369 ehdr->e_ident[EI_DATA] = ELFDATA2LSB;
@@ -380,33 +379,30 @@ static int prepare_elf64_headers(struct crash_mem *cmem, bool kernel_map,
380 379
381 /* Prepare one phdr of type PT_NOTE for each present cpu */ 380 /* Prepare one phdr of type PT_NOTE for each present cpu */
382 for_each_present_cpu(cpu) { 381 for_each_present_cpu(cpu) {
383 phdr = (Elf64_Phdr *)bufp;
384 bufp += sizeof(Elf64_Phdr);
385 phdr->p_type = PT_NOTE; 382 phdr->p_type = PT_NOTE;
386 notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); 383 notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu));
387 phdr->p_offset = phdr->p_paddr = notes_addr; 384 phdr->p_offset = phdr->p_paddr = notes_addr;
388 phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); 385 phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t);
389 (ehdr->e_phnum)++; 386 (ehdr->e_phnum)++;
387 phdr++;
390 } 388 }
391 389
392 /* Prepare one PT_NOTE header for vmcoreinfo */ 390 /* Prepare one PT_NOTE header for vmcoreinfo */
393 phdr = (Elf64_Phdr *)bufp;
394 bufp += sizeof(Elf64_Phdr);
395 phdr->p_type = PT_NOTE; 391 phdr->p_type = PT_NOTE;
396 phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); 392 phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note();
397 phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; 393 phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE;
398 (ehdr->e_phnum)++; 394 (ehdr->e_phnum)++;
395 phdr++;
399 396
400 /* Prepare PT_LOAD type program header for kernel text region */ 397 /* Prepare PT_LOAD type program header for kernel text region */
401 if (kernel_map) { 398 if (kernel_map) {
402 phdr = (Elf64_Phdr *)bufp;
403 bufp += sizeof(Elf64_Phdr);
404 phdr->p_type = PT_LOAD; 399 phdr->p_type = PT_LOAD;
405 phdr->p_flags = PF_R|PF_W|PF_X; 400 phdr->p_flags = PF_R|PF_W|PF_X;
406 phdr->p_vaddr = (Elf64_Addr)_text; 401 phdr->p_vaddr = (Elf64_Addr)_text;
407 phdr->p_filesz = phdr->p_memsz = _end - _text; 402 phdr->p_filesz = phdr->p_memsz = _end - _text;
408 phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); 403 phdr->p_offset = phdr->p_paddr = __pa_symbol(_text);
409 (ehdr->e_phnum)++; 404 ehdr->e_phnum++;
405 phdr++;
410 } 406 }
411 407
412 /* Go through all the ranges in cmem->ranges[] and prepare phdr */ 408 /* Go through all the ranges in cmem->ranges[] and prepare phdr */