]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
s390/boot: Add common boot_panic() code
authorHeiko Carstens <hca@linux.ibm.com>
Tue, 12 Aug 2025 14:58:43 +0000 (16:58 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Thu, 28 Aug 2025 14:52:54 +0000 (16:52 +0200)
Introduce a common boot_panic() helper macro, and use it to
get rid of three more or less identical implementations.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/boot/boot.h
arch/s390/boot/decompressor.c
arch/s390/boot/physmem_info.c
arch/s390/boot/startup.c

index c0152db285f0b9d785eb1cf90a94d539d3803c61..37d5b097ede5f55256cd234cc4d50c4fdcc816b1 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/printk.h>
 #include <asm/physmem_info.h>
+#include <asm/stacktrace.h>
 
 struct vmlinux_info {
        unsigned long entry;
@@ -89,6 +90,13 @@ void __noreturn jump_to_kernel(psw_t *psw);
 #define boot_info(fmt, ...)    boot_printk(KERN_INFO boot_fmt(fmt), ##__VA_ARGS__)
 #define boot_debug(fmt, ...)   boot_printk(KERN_DEBUG boot_fmt(fmt), ##__VA_ARGS__)
 
+#define boot_panic(...) do {                           \
+       boot_emerg(__VA_ARGS__);                        \
+       print_stacktrace(current_frame_address());      \
+       boot_emerg(" -- System halted\n");              \
+       disabled_wait();                                \
+} while (0)
+
 extern struct machine_info machine;
 extern int boot_console_loglevel;
 extern bool boot_ignore_loglevel;
index 03500b9d9fb9aded28c63e3a7623e19367b90fa1..8d1bc25a6bf4ed9b954d066777c3d0ae2915d837 100644 (file)
@@ -68,9 +68,7 @@ static void decompress_error(char *m)
 {
        if (bootdebug)
                boot_rb_dump();
-       boot_emerg("Decompression error: %s\n", m);
-       boot_emerg(" -- System halted\n");
-       disabled_wait();
+       boot_panic("Decompression error: %s\n", m);
 }
 
 unsigned long mem_safe_offset(void)
index 45e3d057cfaa31624fde8da04af7256084552eb7..1f2ca5435838e8994f41602a4862b05912c96869 100644 (file)
@@ -228,9 +228,7 @@ static void die_oom(unsigned long size, unsigned long align, unsigned long min,
        boot_emerg("Usable online memory total: %lu Reserved: %lu Free: %lu\n",
                   total_mem, total_reserved_mem,
                   total_mem > total_reserved_mem ? total_mem - total_reserved_mem : 0);
-       print_stacktrace(current_frame_address());
-       boot_emerg(" -- System halted\n");
-       disabled_wait();
+       boot_panic("Oom\n");
 }
 
 static void _physmem_reserve(enum reserved_range_type type, unsigned long addr, unsigned long size)
index 93684a7757161c2b5ee2aec64218a3b4d66e6e94..3fbd25b9498f35224e4586ee3dcc955138689d04 100644 (file)
@@ -44,13 +44,6 @@ u64 __bootdata_preserved(clock_comparator_max) = -1UL;
 u64 __bootdata_preserved(stfle_fac_list[16]);
 struct oldmem_data __bootdata_preserved(oldmem_data);
 
-void error(char *x)
-{
-       boot_emerg("%s\n", x);
-       boot_emerg(" -- System halted\n");
-       disabled_wait();
-}
-
 static char sysinfo_page[PAGE_SIZE] __aligned(PAGE_SIZE);
 
 static void detect_machine_type(void)
@@ -220,10 +213,10 @@ static void rescue_initrd(unsigned long min, unsigned long max)
 static void copy_bootdata(void)
 {
        if (__boot_data_end - __boot_data_start != vmlinux.bootdata_size)
-               error(".boot.data section size mismatch");
+               boot_panic(".boot.data section size mismatch\n");
        memcpy((void *)vmlinux.bootdata_off, __boot_data_start, vmlinux.bootdata_size);
        if (__boot_data_preserved_end - __boot_data_preserved_start != vmlinux.bootdata_preserved_size)
-               error(".boot.preserved.data section size mismatch");
+               boot_panic(".boot.preserved.data section size mismatch\n");
        memcpy((void *)vmlinux.bootdata_preserved_off, __boot_data_preserved_start, vmlinux.bootdata_preserved_size);
 }
 
@@ -237,7 +230,7 @@ static void kaslr_adjust_relocs(unsigned long min_addr, unsigned long max_addr,
        for (reloc = (int *)__vmlinux_relocs_64_start; reloc < (int *)__vmlinux_relocs_64_end; reloc++) {
                loc = (long)*reloc + phys_offset;
                if (loc < min_addr || loc > max_addr)
-                       error("64-bit relocation outside of kernel!\n");
+                       boot_panic("64-bit relocation outside of kernel!\n");
                *(u64 *)loc += offset;
        }
 }