From: Vasily Gorbik Date: Wed, 20 Nov 2024 15:56:12 +0000 (+0100) Subject: s390/boot: Add support for boot messages loglevels X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d538fdc49a7d7dd068fc29bcc6093e8dd45abbd9;p=users%2Fjedix%2Flinux-maple.git s390/boot: Add support for boot messages loglevels 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 Acked-by: Heiko Carstens Signed-off-by: Alexander Gordeev --- diff --git a/arch/s390/boot/boot.h b/arch/s390/boot/boot.h index ce8422d8f9a89..80e86387bee55 100644 --- a/arch/s390/boot/boot.h +++ b/arch/s390/boot/boot.h @@ -8,6 +8,7 @@ #ifndef __ASSEMBLY__ +#include #include 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[]; diff --git a/arch/s390/boot/ipl_parm.c b/arch/s390/boot/ipl_parm.c index 557462e62cd73..b3fb0b6729688 100644 --- a/arch/s390/boot/ipl_parm.c +++ b/arch/s390/boot/ipl_parm.c @@ -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; + } } } diff --git a/arch/s390/boot/printk.c b/arch/s390/boot/printk.c index 41e576da1a4f3..7eeb43821cd0c 100644 --- a/arch/s390/boot/printk.c +++ b/arch/s390/boot/printk.c @@ -11,6 +11,9 @@ #include #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); }