s390/boot: Add common boot_panic() code

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>
This commit is contained in:
Heiko Carstens
2025-08-12 16:58:43 +02:00
committed by Alexander Gordeev
parent 669bc57e70
commit b3597eb51a
4 changed files with 13 additions and 16 deletions

View 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;

View 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)

View 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)

View 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;
}
}