Streamlining the Final Leap: Unifying U-Boot’s Pre-OS Cleanup

What happens in the final moments before U-Boot hands control over to the operating system? Until recently, the answer was, “it’s complicated.” Each architecture like ARM, x86, and RISC-V had its own way of handling the final pre-boot cleanup, leading to a maze of slightly different functions and duplicated code. It was difficult to know what was really happening just before the kernel started.
Thanks to a recent series of commits in Concept, this critical part of the boot process has been significantly cleaned up and unified.
A Simpler, Centralized Approach
The core of this effort is the introduction of a new generic function: bootm_final()
. This function’s purpose is to consolidate all the common steps that must happen right before booting an OS. By moving to this centralized model, we’ve replaced various architecture-specific functions, like bootm_announce_and_cleanup()
, with a single, unified call.
This new approach has been adopted across the x86, RISC-V, and ARM architectures, as well as for the EFI loader.
Key Improvements in This Series
- Unified Cleanup: Common tasks like disabling interrupts, quiescing board devices, and calling
cleanup_before_linux()
are now handled in one place, reducing code duplication and increasing consistency. - Better Bootstage Reporting: The EFI boot path now benefits from bootstage processing. If enabled, U-Boot will produce a bootstage report, offering better insights into boot-time performance when launching an EFI application. This report is emitted when exit-boot-services is called, thus allowing timing of GRUB and the kernel EFI stuff, if present.
- Code Simplification: With the new generic function in place, redundant architecture-specific functions have been removed. We also took the opportunity to drop an outdated workaround for an old version of GRUB (
EFI_GRUB_ARM32_WORKAROUND
).
This cleanup makes the boot process more robust, easier to understand, and simpler to maintain. While there is still future work to be done in this area, this is a major step forward in standardizing the final hand-off from U-Boot to the OS.