Skip to content

Commit 816b5fe

Browse files
Vasily GorbikAlexander Gordeev
authored andcommitted
s390/boot: Introduce ring buffer for boot messages
Collect all boot messages into a ring buffer independent of the current log level. This allows to retain all boot-time messages, which is particularly useful for analyzing early crashes. Signed-off-by: Vasily Gorbik <[email protected]> Acked-by: Heiko Carstens <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent bbbaf06 commit 816b5fe

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

arch/s390/boot/printk.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@
1313

1414
int boot_console_loglevel = CONFIG_CONSOLE_LOGLEVEL_DEFAULT;
1515
bool boot_ignore_loglevel;
16+
char boot_rb[PAGE_SIZE * 2];
17+
size_t boot_rb_off;
18+
19+
static void boot_rb_add(const char *str, size_t len)
20+
{
21+
/* leave double '\0' in the end */
22+
size_t avail = sizeof(boot_rb) - boot_rb_off - 1;
23+
24+
/* store strings separated by '\0' */
25+
if (len + 1 > avail)
26+
boot_rb_off = 0;
27+
strcpy(boot_rb + boot_rb_off, str);
28+
boot_rb_off += len + 1;
29+
}
1630

1731
const char hex_asc[] = "0123456789abcdef";
1832

@@ -229,5 +243,9 @@ void boot_printk(const char *fmt, ...)
229243
}
230244
out:
231245
va_end(args);
232-
boot_console_earlyprintk(buf);
246+
len = strlen(buf);
247+
if (len) {
248+
boot_rb_add(buf, len);
249+
boot_console_earlyprintk(buf);
250+
}
233251
}

arch/s390/include/asm/boot_data.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,17 @@ extern unsigned long ipl_cert_list_size;
1515
extern unsigned long early_ipl_comp_list_addr;
1616
extern unsigned long early_ipl_comp_list_size;
1717

18+
extern char boot_rb[PAGE_SIZE * 2];
19+
extern size_t boot_rb_off;
20+
21+
#define boot_rb_foreach(cb) \
22+
do { \
23+
size_t off = boot_rb_off + strlen(boot_rb + boot_rb_off) + 1; \
24+
size_t len; \
25+
for (; off < sizeof(boot_rb) && (len = strlen(boot_rb + off)); off += len + 1) \
26+
cb(boot_rb + off); \
27+
for (off = 0; off < boot_rb_off && (len = strlen(boot_rb + off)); off += len + 1) \
28+
cb(boot_rb + off); \
29+
} while (0)
30+
1831
#endif /* _ASM_S390_BOOT_DATA_H */

0 commit comments

Comments
 (0)