Skip to content

Commit b79015a

Browse files
Vasily GorbikAlexander Gordeev
authored andcommitted
s390/boot: Add prefix filtering to bootdebug messages
Enhance boot debugging by allowing the "bootdebug" kernel parameter to accept an optional comma-separated list of prefixes. Only debug messages starting with these prefixes will be printed during boot. For example: bootdebug=startup,vmem Not specifying a filter for the "bootdebug" parameter prints all debug messages. The `boot_fmt` macro can be defined to set a common prefix: #define boot_fmt(fmt) "startup: " fmt Signed-off-by: Vasily Gorbik <[email protected]> Acked-by: Heiko Carstens <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent d20d8e5 commit b79015a

File tree

5 files changed

+50
-14
lines changed

5 files changed

+50
-14
lines changed

arch/s390/boot/boot.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,18 @@ void print_stacktrace(unsigned long sp);
7777
void error(char *m);
7878
int get_random(unsigned long limit, unsigned long *value);
7979

80-
#define boot_emerg(fmt, ...) boot_printk(KERN_EMERG fmt, ##__VA_ARGS__)
81-
#define boot_alert(fmt, ...) boot_printk(KERN_ALERT fmt, ##__VA_ARGS__)
82-
#define boot_crit(fmt, ...) boot_printk(KERN_CRIT fmt, ##__VA_ARGS__)
83-
#define boot_err(fmt, ...) boot_printk(KERN_ERR fmt, ##__VA_ARGS__)
84-
#define boot_warn(fmt, ...) boot_printk(KERN_WARNING fmt, ##__VA_ARGS__)
85-
#define boot_notice(fmt, ...) boot_printk(KERN_NOTICE fmt, ##__VA_ARGS__)
86-
#define boot_info(fmt, ...) boot_printk(KERN_INFO fmt, ##__VA_ARGS__)
87-
#define boot_debug(fmt, ...) boot_printk(KERN_DEBUG fmt, ##__VA_ARGS__)
80+
#ifndef boot_fmt
81+
#define boot_fmt(fmt) fmt
82+
#endif
83+
84+
#define boot_emerg(fmt, ...) boot_printk(KERN_EMERG boot_fmt(fmt), ##__VA_ARGS__)
85+
#define boot_alert(fmt, ...) boot_printk(KERN_ALERT boot_fmt(fmt), ##__VA_ARGS__)
86+
#define boot_crit(fmt, ...) boot_printk(KERN_CRIT boot_fmt(fmt), ##__VA_ARGS__)
87+
#define boot_err(fmt, ...) boot_printk(KERN_ERR boot_fmt(fmt), ##__VA_ARGS__)
88+
#define boot_warn(fmt, ...) boot_printk(KERN_WARNING boot_fmt(fmt), ##__VA_ARGS__)
89+
#define boot_notice(fmt, ...) boot_printk(KERN_NOTICE boot_fmt(fmt), ##__VA_ARGS__)
90+
#define boot_info(fmt, ...) boot_printk(KERN_INFO boot_fmt(fmt), ##__VA_ARGS__)
91+
#define boot_debug(fmt, ...) boot_printk(KERN_DEBUG boot_fmt(fmt), ##__VA_ARGS__)
8892

8993
extern struct machine_info machine;
9094
extern int boot_console_loglevel;

arch/s390/boot/ipl_parm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,11 @@ void parse_boot_command_line(void)
317317
boot_earlyprintk = true;
318318
if (!strcmp(param, "debug"))
319319
boot_console_loglevel = CONSOLE_LOGLEVEL_DEBUG;
320-
if (!strcmp(param, "bootdebug"))
320+
if (!strcmp(param, "bootdebug")) {
321321
bootdebug = true;
322+
if (val)
323+
strncpy(bootdebug_filter, val, sizeof(bootdebug_filter) - 1);
324+
}
322325
if (!strcmp(param, "quiet"))
323326
boot_console_loglevel = CONSOLE_LOGLEVEL_QUIET;
324327
if (!strcmp(param, "ignore_loglevel"))

arch/s390/boot/printk.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ bool boot_ignore_loglevel;
1717
char __bootdata(boot_rb)[PAGE_SIZE * 2];
1818
bool __bootdata(boot_earlyprintk);
1919
size_t __bootdata(boot_rb_off);
20+
char __bootdata(bootdebug_filter)[128];
2021
bool __bootdata(bootdebug);
2122

2223
static void boot_rb_add(const char *str, size_t len)
@@ -169,11 +170,12 @@ static void boot_console_earlyprintk(const char *buf)
169170
/* always print emergency messages */
170171
if (level > LOGLEVEL_EMERG && !boot_earlyprintk)
171172
return;
173+
buf = printk_skip_level(buf);
172174
/* print debug messages only when bootdebug is enabled */
173-
if (level == LOGLEVEL_DEBUG && !bootdebug)
175+
if (level == LOGLEVEL_DEBUG && (!bootdebug || !bootdebug_filter_match(buf)))
174176
return;
175177
if (boot_ignore_loglevel || level < boot_console_loglevel)
176-
sclp_early_printk(printk_skip_level(buf));
178+
sclp_early_printk(buf);
177179
}
178180

179181
#define va_arg_len_type(args, lenmod, typemod) \

arch/s390/include/asm/boot_data.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
#ifndef _ASM_S390_BOOT_DATA_H
33

4+
#include <linux/string.h>
45
#include <asm/setup.h>
56
#include <asm/ipl.h>
67

@@ -18,6 +19,7 @@ extern unsigned long early_ipl_comp_list_size;
1819
extern char boot_rb[PAGE_SIZE * 2];
1920
extern bool boot_earlyprintk;
2021
extern size_t boot_rb_off;
22+
extern char bootdebug_filter[128];
2123
extern bool bootdebug;
2224

2325
#define boot_rb_foreach(cb) \
@@ -30,4 +32,27 @@ extern bool bootdebug;
3032
cb(boot_rb + off); \
3133
} while (0)
3234

35+
/*
36+
* bootdebug_filter is a comma separated list of strings,
37+
* where each string can be a prefix of the message.
38+
*/
39+
static inline bool bootdebug_filter_match(const char *buf)
40+
{
41+
char *p = bootdebug_filter, *s;
42+
char *end;
43+
44+
if (!*p)
45+
return true;
46+
47+
end = p + strlen(p);
48+
while (p < end) {
49+
p = skip_spaces(p);
50+
s = memscan(p, ',', end - p);
51+
if (!strncmp(p, buf, s - p))
52+
return true;
53+
p = s + 1;
54+
}
55+
return false;
56+
}
57+
3358
#endif /* _ASM_S390_BOOT_DATA_H */

arch/s390/kernel/setup.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ struct oldmem_data __bootdata_preserved(oldmem_data);
160160
char __bootdata(boot_rb)[PAGE_SIZE * 2];
161161
bool __bootdata(boot_earlyprintk);
162162
size_t __bootdata(boot_rb_off);
163+
char __bootdata(bootdebug_filter)[128];
163164
bool __bootdata(bootdebug);
164165

165166
unsigned long __bootdata_preserved(VMALLOC_START);
@@ -886,16 +887,17 @@ static void __init log_component_list(void)
886887
* Print avoiding interpretation of % in buf and taking bootdebug option
887888
* into consideration.
888889
*/
889-
static void __init print_rb_entry(char *buf)
890+
static void __init print_rb_entry(const char *buf)
890891
{
891892
char fmt[] = KERN_SOH "0boot: %s";
892893
int level = printk_get_level(buf);
893894

894-
if (level == KERN_DEBUG[1] && !bootdebug)
895+
buf = printk_skip_level(buf);
896+
if (level == KERN_DEBUG[1] && (!bootdebug || !bootdebug_filter_match(buf)))
895897
return;
896898

897899
fmt[1] = level;
898-
printk(fmt, printk_skip_level(buf));
900+
printk(fmt, buf);
899901
}
900902

901903
/*

0 commit comments

Comments
 (0)