Commit graph

16 commits

Author SHA1 Message Date
Heiko Carstens
7e7f94d106 s390/boot: Use strspcy() instead of strcpy()
Convert all strcpy() usages to strscpy(). strcpy() is deprecated since
it performs no bounds checking on the destination buffer.

Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2025-04-30 11:41:28 +02:00
Vasily Gorbik
1468d6b1d3 s390/boot: Replace strncpy() with strscpy()
Replace the last 2 usages of strncpy() in s390 code with strscpy().

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2025-04-14 11:23:22 +02:00
Heiko Carstens
f931f67cfc s390/time: Convert MACHINE_HAS_SCC to machine_has_scc()
Use static branch(es) to implement and use machine_has_scc() instead
of a runtime check via MACHINE_HAS_SCC.

This comes with a cleanup of early time initialization: the initial
tod_clock_base value is now passed via the bootdata mechanism, instead
of using absolute lowcore as transport vehicle from the decompressor
to the kernel.

Also the early tod clock initialization is moved to the decompressor
which allows to use a static branch with machine_has_scc() within the
kernel.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2025-03-04 17:18:06 +01:00
Vasily Gorbik
70309dc776 s390/boot: Add timestamps to early boot messages
When CONFIG_PRINTK_TIME is enabled, add timestamps to boot messages in
the same format as regular printk. Timestamps appear only with earlyprintk
and are stored in the boot messages ring buffer, but are not propagated
to main kernel messages (if earlyprintk is not enabled). This prevents
double timestamps in the output.

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>
2025-01-26 17:24:02 +01:00
Vasily Gorbik
b2a992a55f 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 <gor@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
2025-01-26 17:24:01 +01:00
Vasily Gorbik
b79015ae63 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 <gor@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
2025-01-26 17:24:01 +01:00
Vasily Gorbik
d20d8e5133 s390/boot: Add bootdebug option to control debug messages
Suppress decompressor debug messages by default, similar to regular
kernel debug messages that require 'DEBUG' or 'dyndbg' to be enabled
(depending on CONFIG_DYNAMIC_DEBUG). Introduce a 'bootdebug' option to
enable printing these messages when needed.

All messages are still stored in the boot ring buffer regardless.

To enable boot debug messages:

  bootdebug debug

Or combine with 'earlyprintk' to print them without delay:

  bootdebug debug earlyprintk

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>
2025-01-26 17:24:01 +01:00
Vasily Gorbik
c09f8d0ad6 s390/boot: Defer boot messages when earlyprintk is not enabled
When earlyprintk is not specified, boot messages are only stored in a
ring buffer to be printed later by printk when console driver is
registered.

Critical messages from boot_emerg() are always printed immediately,
even without earlyprintk.

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>
2025-01-26 17:24:01 +01:00
Vasily Gorbik
847e5a4c71 s390/boot: Make boot_printk() return int
Modify boot_printk() to return int, aligning it with printk().

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>
2025-01-26 17:24:01 +01:00
Vasily Gorbik
816b5feaed 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 <gor@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
2025-01-26 17:24:00 +01:00
Vasily Gorbik
d538fdc49a 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 <gor@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
2025-01-26 17:24:00 +01:00
Vasily Gorbik
92b712fa7d s390/boot: Add decimal conversion specifiers to boot_printk()
Enable the boot_printk() function to print decimal values. Add the 'd',
'i', and 'u' conversion specifiers support.

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>
2025-01-26 17:23:59 +01:00
Vasily Gorbik
3d846daafb s390/boot: Add field width and padding handling to boot_printk()
Enhance boot_printk() to support field width and padding across all
argument types for better formatting.

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>
2025-01-26 17:23:59 +01:00
Vasily Gorbik
9291d572fe s390/boot: Add length modifiers to boot_printk()
Add support for the 'l', 'h', 'hh', and 'z' length modifiers.

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>
2025-01-26 17:23:59 +01:00
Vasily Gorbik
dccac2b22b s390/boot: Add %% support to boot_printk()
Add "%%" support for the boot_printk() format string.

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>
2025-01-26 17:23:59 +01:00
Heiko Carstens
5c9a274202 s390/boot: Move boot_printk() code to own file
Keep the printk code separate from the program check code and move
boot_printk() and helper functions to own printk.c file.

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2024-09-07 17:12:43 +02:00