Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/kdump: remove code to create ELF notes in the crashed system

The s390 architecture can store the CPU registers of the crashed system
after the kdump kernel has been started and this is the preferred way.
Remove the remaining code fragments that deal with storing CPU registers
while the crashed system is still active.

Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

+28 -63
-2
arch/s390/include/asm/elf.h
··· 229 229 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 230 230 int arch_setup_additional_pages(struct linux_binprm *, int); 231 231 232 - void *fill_cpu_elf_notes(void *ptr, struct save_area *sa, __vector128 *vxrs); 233 - 234 232 #endif
+3 -21
arch/s390/kernel/crash_dump.c
··· 73 73 } 74 74 75 75 /* 76 - * Pointer to ELF header in new kernel 77 - */ 78 - static void *elfcorehdr_newmem; 79 - 80 - /* 81 76 * Copy one page from zfcpdump "oldmem" 82 77 * 83 78 * For pages below HSA size memory from the HSA is copied. Otherwise ··· 385 390 /* 386 391 * Fill ELF notes for one CPU with save area registers 387 392 */ 388 - void *fill_cpu_elf_notes(void *ptr, struct save_area *sa, __vector128 *vx_regs) 393 + static void *fill_cpu_elf_notes(void *ptr, struct save_area *sa, 394 + __vector128 *vx_regs) 389 395 { 390 396 ptr = nt_prstatus(ptr, sa); 391 397 ptr = nt_fpregset(ptr, sa); ··· 569 573 /* If we are not in kdump or zfcpdump mode return */ 570 574 if (!OLDMEM_BASE && ipl_info.type != IPL_TYPE_FCP_DUMP) 571 575 return 0; 572 - /* If elfcorehdr= has been passed via cmdline, we use that one */ 573 - if (elfcorehdr_addr != ELFCORE_ADDR_MAX) 574 - return 0; 575 576 /* If we cannot get HSA size for zfcpdump return error */ 576 577 if (ipl_info.type == IPL_TYPE_FCP_DUMP && !sclp.hsa_size) 577 578 return -ENODEV; ··· 599 606 hdr_off = PTR_DIFF(ptr, hdr); 600 607 loads_init(phdr_loads, hdr_off); 601 608 *addr = (unsigned long long) hdr; 602 - elfcorehdr_newmem = hdr; 603 609 *size = (unsigned long long) hdr_off; 604 610 BUG_ON(elfcorehdr_size > alloc_size); 605 611 return 0; ··· 609 617 */ 610 618 void elfcorehdr_free(unsigned long long addr) 611 619 { 612 - if (!elfcorehdr_newmem) 613 - return; 614 620 kfree((void *)(unsigned long)addr); 615 621 } 616 622 ··· 619 629 { 620 630 void *src = (void *)(unsigned long)*ppos; 621 631 622 - src = elfcorehdr_newmem ? src : src - OLDMEM_BASE; 623 632 memcpy(buf, src, count); 624 633 *ppos += count; 625 634 return count; ··· 630 641 ssize_t elfcorehdr_read_notes(char *buf, size_t count, u64 *ppos) 631 642 { 632 643 void *src = (void *)(unsigned long)*ppos; 633 - int rc; 634 644 635 - if (elfcorehdr_newmem) { 636 - memcpy(buf, src, count); 637 - } else { 638 - rc = copy_from_oldmem(buf, src, count); 639 - if (rc) 640 - return rc; 641 - } 645 + memcpy(buf, src, count); 642 646 *ppos += count; 643 647 return count; 644 648 }
+18 -24
arch/s390/kernel/machine_kexec.c
··· 35 35 #ifdef CONFIG_CRASH_DUMP 36 36 37 37 /* 38 - * Create ELF notes for one CPU 39 - */ 40 - static void add_elf_notes(int cpu) 41 - { 42 - struct save_area *sa = (void *) 4608 + store_prefix(); 43 - void *ptr; 44 - 45 - memcpy((void *) (4608UL + sa->pref_reg), sa, sizeof(*sa)); 46 - ptr = (u64 *) per_cpu_ptr(crash_notes, cpu); 47 - ptr = fill_cpu_elf_notes(ptr, sa, NULL); 48 - memset(ptr, 0, sizeof(struct elf_note)); 49 - } 50 - 51 - /* 52 38 * Initialize CPU ELF notes 53 39 */ 54 40 static void setup_regs(void) 55 41 { 56 - unsigned long sa = S390_lowcore.prefixreg_save_area + SAVE_AREA_BASE; 57 - struct _lowcore *lc; 42 + struct save_area *sa, *sa_0; 43 + unsigned long prefix; 58 44 int cpu, this_cpu; 59 45 60 - /* Get lowcore pointer from store status of this CPU (absolute zero) */ 61 - lc = (struct _lowcore *)(unsigned long)S390_lowcore.prefixreg_save_area; 46 + /* setup_regs is called with the prefix register = 0 */ 47 + sa_0 = (struct save_area *) SAVE_AREA_BASE; 48 + 49 + /* Get status of this CPU out of absolute zero */ 50 + prefix = (unsigned long) S390_lowcore.prefixreg_save_area; 51 + sa = (struct save_area *)(prefix + SAVE_AREA_BASE); 52 + memcpy(sa, sa_0, sizeof(struct save_area)); 53 + if (MACHINE_HAS_VX) { 54 + struct _lowcore *lc = (struct _lowcore *) prefix; 55 + save_vx_regs_safe((void *) lc->vector_save_area_addr); 56 + } 57 + 58 + /* Get status of the other CPUs */ 62 59 this_cpu = smp_find_processor_id(stap()); 63 - add_elf_notes(this_cpu); 64 60 for_each_online_cpu(cpu) { 65 61 if (cpu == this_cpu) 66 62 continue; 67 63 if (smp_store_status(cpu)) 68 64 continue; 69 - add_elf_notes(cpu); 65 + prefix = (unsigned long) S390_lowcore.prefixreg_save_area; 66 + sa = (struct save_area *)(prefix + SAVE_AREA_BASE); 67 + memcpy(sa, sa_0, sizeof(struct save_area)); 70 68 } 71 - if (MACHINE_HAS_VX) 72 - save_vx_regs_safe((void *) lc->vector_save_area_addr); 73 - /* Copy dump CPU store status info to absolute zero */ 74 - memcpy((void *) SAVE_AREA_BASE, (void *) sa, sizeof(struct save_area)); 75 69 } 76 70 77 71 /*
+5 -10
arch/s390/kernel/setup.c
··· 661 661 #endif 662 662 } 663 663 664 - static void __init reserve_elfcorehdr(void) 665 - { 666 - #ifdef CONFIG_CRASH_DUMP 667 - if (is_kdump_kernel()) 668 - memblock_reserve(elfcorehdr_addr - OLDMEM_BASE, 669 - PAGE_ALIGN(elfcorehdr_size)); 670 - #endif 671 - } 672 - 673 664 static void __init setup_memory(void) 674 665 { 675 666 struct memblock_region *reg; ··· 832 841 init_mm.brk = (unsigned long) &_end; 833 842 834 843 parse_early_param(); 844 + #ifdef CONFIG_CRASH_DUMP 845 + /* Deactivate elfcorehdr= kernel parameter */ 846 + elfcorehdr_addr = ELFCORE_ADDR_MAX; 847 + #endif 848 + 835 849 os_info_init(); 836 850 setup_ipl(); 837 851 ··· 845 849 reserve_oldmem(); 846 850 reserve_kernel(); 847 851 reserve_initrd(); 848 - reserve_elfcorehdr(); 849 852 memblock_allow_resize(); 850 853 851 854 /* Get information about *all* installed memory */
+2 -6
arch/s390/kernel/smp.c
··· 608 608 * stored the registers of the boot CPU in the memory of the old system. 609 609 * 4) kdump and the old kernel stored the CPU state 610 610 * condition: OLDMEM_BASE != NULL && is_kdump_kernel() 611 - * The state of all CPUs is stored in ELF sections in the memory of the 612 - * old system. The ELF sections are picked up by the crash_dump code 613 - * via elfcorehdr_addr. 611 + * This case does not exist for s390 anymore, setup_arch explicitly 612 + * deactivates the elfcorehdr= kernel parameter 614 613 */ 615 614 void __init smp_save_dump_cpus(void) 616 615 { ··· 618 619 struct save_area_ext *sa_ext; 619 620 bool is_boot_cpu; 620 621 621 - if (is_kdump_kernel()) 622 - /* Previous system stored the CPU states. Nothing to do. */ 623 - return; 624 622 if (!(OLDMEM_BASE || ipl_info.type == IPL_TYPE_FCP_DUMP)) 625 623 /* No previous system present, normal boot. */ 626 624 return;