Linux kernel developers are working to make it easier to debug early boot issues such as Kexec failures as currently dealing with such situations can be a frustrating and time consuming headache for figuring out the problems prior to the kernel being fully brought online.
Sent out on Tuesday was the x86/boot pull request that contains initial work in this direction to enhance the early boot debugging experience. The x86/boot summary explains:
“A large and involved preparatory series to pave the way to add exception handling for relocate_kernel – which will be a debugging facility that has aided in the field to debug an exceptionally hard to debug early boot bug. Plus assorted cleanups and fixes that were discovered along the way, by David Woodhouse.”
David Woodhouse of Amazon/AWS further elaborated in that initial patch series working on exception handling for relocate_kernel:
“Debugging kexec failures is painful, as anything going wrong in execution of the critical relocate_kernel() function tends to just lead to a triple fault. Thus leading to *weeks* of my life that I won’t get back. Having hacked something up for my own use, I figured I should share it…
Add a CONFIG_KEXEC_DEBUG option which sets up a trivial exception handler in that environment, and outputs to the early_printk serial console if configured. Currently only I/O-based 8250 serial ports are supported, but that could be extended.
While we’re here, clean the code up a little and fix some other problems. Most notably, load a suitable GDT on the way back into the kernel after a KEXEC_PRESERVE_CONTEXT invocation instead of trusting the called code to do so. And (new in v4) fix the interaction of PTI and the identmap code so that it doesn’t scribble over the end of the 4KiB region allocated for the PGD expecting there to be a userspace PGD there.”
Thus for those having to deal with debugging early boot kernel issues, moving forward there are enhancements being worked on for making it a little less painful. These initial patches are merged for the in-development Linux 6.14 kernel.