]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
s390/boot: Add support for boot messages loglevels
authorVasily Gorbik <gor@linux.ibm.com>
Wed, 20 Nov 2024 15:56:12 +0000 (16:56 +0100)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Sun, 26 Jan 2025 16:24:00 +0000 (17:24 +0100)
Add message severity levels for boot messages, similar to the main
kernel. Support command-line options that control console output
verbosity, including "loglevel," "ignore_loglevel," "debug," and "quiet".

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/boot/boot.h
arch/s390/boot/ipl_parm.c
arch/s390/boot/printk.c

index ce8422d8f9a8937763cc896374cabb468c73eeb1..80e86387bee55c2ee0723cceea2b7bc0093edd4b 100644 (file)
@@ -8,6 +8,7 @@
 
 #ifndef __ASSEMBLY__
 
+#include <linux/printk.h>
 #include <asm/physmem_info.h>
 
 struct machine_info {
@@ -76,7 +77,18 @@ void print_stacktrace(unsigned long sp);
 void error(char *m);
 int get_random(unsigned long limit, unsigned long *value);
 
+#define boot_emerg(fmt, ...)   boot_printk(KERN_EMERG fmt, ##__VA_ARGS__)
+#define boot_alert(fmt, ...)   boot_printk(KERN_ALERT fmt, ##__VA_ARGS__)
+#define boot_crit(fmt, ...)    boot_printk(KERN_CRIT fmt, ##__VA_ARGS__)
+#define boot_err(fmt, ...)     boot_printk(KERN_ERR fmt, ##__VA_ARGS__)
+#define boot_warn(fmt, ...)    boot_printk(KERN_WARNING fmt, ##__VA_ARGS__)
+#define boot_notice(fmt, ...)  boot_printk(KERN_NOTICE fmt, ##__VA_ARGS__)
+#define boot_info(fmt, ...)    boot_printk(KERN_INFO fmt, ##__VA_ARGS__)
+#define boot_debug(fmt, ...)   boot_printk(KERN_DEBUG fmt, ##__VA_ARGS__)
+
 extern struct machine_info machine;
+extern int boot_console_loglevel;
+extern bool boot_ignore_loglevel;
 
 /* Symbols defined by linker scripts */
 extern const char kernel_version[];
index 557462e62cd737625b9554e9b97a2c5f8bf028a7..b3fb0b6729688afdcefb003d7e31a8d552bdab9a 100644 (file)
@@ -313,5 +313,16 @@ void parse_boot_command_line(void)
 #endif
                if (!strcmp(param, "relocate_lowcore") && test_facility(193))
                        relocate_lowcore = 1;
+               if (!strcmp(param, "debug"))
+                       boot_console_loglevel = CONSOLE_LOGLEVEL_DEBUG;
+               if (!strcmp(param, "quiet"))
+                       boot_console_loglevel = CONSOLE_LOGLEVEL_QUIET;
+               if (!strcmp(param, "ignore_loglevel"))
+                       boot_ignore_loglevel = true;
+               if (!strcmp(param, "loglevel")) {
+                       boot_console_loglevel = simple_strtoull(val, NULL, 10);
+                       if (boot_console_loglevel < CONSOLE_LOGLEVEL_MIN)
+                               boot_console_loglevel = CONSOLE_LOGLEVEL_MIN;
+               }
        }
 }
index 41e576da1a4f3fc684622bd9d2f703e6cf5420e6..7eeb43821cd0c586fab628372c9fa99648d75ddb 100644 (file)
@@ -11,6 +11,9 @@
 #include <asm/uv.h>
 #include "boot.h"
 
+int boot_console_loglevel = CONFIG_CONSOLE_LOGLEVEL_DEFAULT;
+bool boot_ignore_loglevel;
+
 const char hex_asc[] = "0123456789abcdef";
 
 static char *as_hex(char *dst, unsigned long val, int pad)
@@ -131,6 +134,25 @@ static noinline char *strsym(char *buf, void *ip)
        return buf;
 }
 
+static inline int printk_loglevel(const char *buf)
+{
+       if (buf[0] == KERN_SOH_ASCII && buf[1]) {
+               switch (buf[1]) {
+               case '0' ... '7':
+                       return buf[1] - '0';
+               }
+       }
+       return MESSAGE_LOGLEVEL_DEFAULT;
+}
+
+static void boot_console_earlyprintk(const char *buf)
+{
+       int level = printk_loglevel(buf);
+
+       if (boot_ignore_loglevel || level < boot_console_loglevel)
+               sclp_early_printk(printk_skip_level(buf));
+}
+
 #define va_arg_len_type(args, lenmod, typemod)                         \
        ((lenmod == 'l') ? va_arg(args, typemod long) :                 \
         (lenmod == 'h') ? (typemod short)va_arg(args, typemod int) :   \
@@ -150,6 +172,11 @@ void boot_printk(const char *fmt, ...)
        ssize_t len;
        int pad;
 
+       if (!printk_get_level(fmt)) {
+               *p++ = KERN_SOH_ASCII;
+               *p++ = '0' + MESSAGE_LOGLEVEL_DEFAULT;
+       }
+
        va_start(args, fmt);
        for (; p < end && *fmt; fmt++) {
                if (*fmt != '%') {
@@ -202,5 +229,5 @@ void boot_printk(const char *fmt, ...)
        }
 out:
        va_end(args);
-       sclp_early_printk(buf);
+       boot_console_earlyprintk(buf);
 }