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

s390/kdump: Provide is_kdump_kernel() implementation

s390 sets "elfcorehdr_addr = ELFCORE_ADDR_MAX;" early during
setup_arch() to deactivate the "elfcorehdr= kernel" parameter,
resulting in is_kdump_kernel() returning "false".

During vmcore_init()->elfcorehdr_alloc(), if on a dump kernel and
allocation succeeded, elfcorehdr_addr will be set to a valid address
and is_kdump_kernel() will consequently return "true".

is_kdump_kernel() should return a consistent result during all boot
stages, and properly return "true" if in a kdump environment - just
like it is done on powerpc where "false" is indicated in fadump
environments, as added in commit b098f1c32365 ("powerpc/fadump: make
is_kdump_kernel() return false when fadump is active").

Similarly provide a custom is_kdump_kernel() implementation that will only
return "true" in kdump environments, and will do so consistently during
boot.

Update the documentation of dump_available().

Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Link: https://lore.kernel.org/r/20241023090651.1115507-1-david@redhat.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>

authored by

David Hildenbrand and committed by
Heiko Carstens
82a0fcb1 2835f8bf

+22 -8
+3
arch/s390/include/asm/kexec.h
··· 94 94 95 95 void arch_kexec_unprotect_crashkres(void); 96 96 #define arch_kexec_unprotect_crashkres arch_kexec_unprotect_crashkres 97 + 98 + bool is_kdump_kernel(void); 99 + #define is_kdump_kernel is_kdump_kernel 97 100 #endif 98 101 99 102 #ifdef CONFIG_KEXEC_FILE
+11
arch/s390/kernel/crash_dump.c
··· 237 237 prot); 238 238 } 239 239 240 + /* 241 + * Return true only when in a kdump or stand-alone kdump environment. 242 + * Note that /proc/vmcore might also be available in "standard zfcp/nvme dump" 243 + * environments, where this function returns false; see dump_available(). 244 + */ 245 + bool is_kdump_kernel(void) 246 + { 247 + return oldmem_data.start; 248 + } 249 + EXPORT_SYMBOL_GPL(is_kdump_kernel); 250 + 240 251 static const char *nt_name(Elf64_Word type) 241 252 { 242 253 const char *name = "LINUX";
+8 -8
arch/s390/kernel/smp.c
··· 574 574 575 575 /* 576 576 * Collect CPU state of the previous, crashed system. 577 - * There are four cases: 577 + * There are three cases: 578 578 * 1) standard zfcp/nvme dump 579 579 * condition: OLDMEM_BASE == NULL && is_ipl_type_dump() == true 580 580 * The state for all CPUs except the boot CPU needs to be collected ··· 587 587 * with sigp stop-and-store-status. The firmware or the boot-loader 588 588 * stored the registers of the boot CPU in the absolute lowcore in the 589 589 * memory of the old system. 590 - * 3) kdump and the old kernel did not store the CPU state, 591 - * or stand-alone kdump for DASD 592 - * condition: OLDMEM_BASE != NULL && !is_kdump_kernel() 590 + * 3) kdump or stand-alone kdump for DASD 591 + * condition: OLDMEM_BASE != NULL && is_ipl_type_dump() == false 593 592 * The state for all CPUs except the boot CPU needs to be collected 594 593 * with sigp stop-and-store-status. The kexec code or the boot-loader 595 594 * stored the registers of the boot CPU in the memory of the old system. 596 - * 4) kdump and the old kernel stored the CPU state 597 - * condition: OLDMEM_BASE != NULL && is_kdump_kernel() 598 - * This case does not exist for s390 anymore, setup_arch explicitly 599 - * deactivates the elfcorehdr= kernel parameter 595 + * 596 + * Note that the legacy kdump mode where the old kernel stored the CPU states 597 + * does no longer exist: setup_arch() explicitly deactivates the elfcorehdr= 598 + * kernel parameter. The is_kdump_kernel() implementation on s390 is independent 599 + * of the elfcorehdr= parameter. 600 600 */ 601 601 static bool dump_available(void) 602 602 {