From: Vasily Gorbik Date: Wed, 20 Nov 2024 19:30:10 +0000 (+0100) Subject: s390/boot: Dump message ring buffer on crash with bootdebug X-Git-Tag: v6.14-rc1~36^2~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b2a992a55fb60395d1ab9a4d4b2ea3783e3b7ad9;p=thirdparty%2Fkernel%2Flinux.git s390/boot: Dump message ring buffer on crash with bootdebug Dump the boot message ring buffer when a crash occurs during boot, but only if bootdebug is enabled. This helps assist in analyzing boot-time issues by providing additional debugging information. Signed-off-by: Vasily Gorbik Acked-by: Heiko Carstens Signed-off-by: Alexander Gordeev --- diff --git a/arch/s390/boot/boot.h b/arch/s390/boot/boot.h index 688fa75f86516..0cfa84a42ec17 100644 --- a/arch/s390/boot/boot.h +++ b/arch/s390/boot/boot.h @@ -76,6 +76,7 @@ int __printf(1, 2) boot_printk(const char *fmt, ...); void print_stacktrace(unsigned long sp); void error(char *m); int get_random(unsigned long limit, unsigned long *value); +void boot_rb_dump(void); #ifndef boot_fmt #define boot_fmt(fmt) fmt diff --git a/arch/s390/boot/pgm_check_info.c b/arch/s390/boot/pgm_check_info.c index e8a728c3db052..633f11600aab3 100644 --- a/arch/s390/boot/pgm_check_info.c +++ b/arch/s390/boot/pgm_check_info.c @@ -37,6 +37,8 @@ void print_pgm_check_info(void) unsigned long *gpregs = (unsigned long *)get_lowcore()->gpregs_save_area; struct psw_bits *psw = &psw_bits(get_lowcore()->psw_save_area); + if (bootdebug) + boot_rb_dump(); boot_emerg("Linux version %s\n", kernel_version); if (!is_prot_virt_guest() && early_command_line[0]) boot_emerg("Kernel command line: %s\n", early_command_line); diff --git a/arch/s390/boot/printk.c b/arch/s390/boot/printk.c index 092114e469376..abfa05cf95624 100644 --- a/arch/s390/boot/printk.c +++ b/arch/s390/boot/printk.c @@ -32,6 +32,24 @@ static void boot_rb_add(const char *str, size_t len) boot_rb_off += len + 1; } +static void print_rb_entry(const char *str) +{ + sclp_early_printk(printk_skip_level(str)); +} + +static bool debug_messages_printed(void) +{ + return boot_earlyprintk && (boot_ignore_loglevel || boot_console_loglevel > LOGLEVEL_DEBUG); +} + +void boot_rb_dump(void) +{ + if (debug_messages_printed()) + return; + sclp_early_printk("Boot messages ring buffer:\n"); + boot_rb_foreach(print_rb_entry); +} + const char hex_asc[] = "0123456789abcdef"; static char *as_hex(char *dst, unsigned long val, int pad)