On Tue, Jan 20, 2026 at 8:54 PM H. Peter Anvin <hpa@zytor.com> wrote:
>
> Every call to die() has a call to puts() in front of it, which adds
> unnecessary code bloat. Move the puts() into die() which, being a
> noreturn function, is terminal and allows the compiler to not generate
> unnecessary code around it.
>
> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Uros Bizjak <ubizjak@gmail.com>
> ---
> arch/x86/boot/boot.h | 2 +-
> arch/x86/boot/header.S | 5 +++--
> arch/x86/boot/main.c | 6 ++----
> arch/x86/boot/pm.c | 6 ++----
> 4 files changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
> index 1f2b7252e387..b4eb8405ba55 100644
> --- a/arch/x86/boot/boot.h
> +++ b/arch/x86/boot/boot.h
> @@ -280,7 +280,7 @@ void console_init(void);
> void query_edd(void);
>
> /* header.S */
> -void __noreturn die(void);
> +void __noreturn die(const char *msg);
>
> /* memory.c */
> void detect_memory(void);
> diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
> index 85a21d576f5b..5a54d33e51c2 100644
> --- a/arch/x86/boot/header.S
> +++ b/arch/x86/boot/header.S
> @@ -611,14 +611,15 @@ SETUP_SIGNATURE = 0x5a5aaa55
> # Setup corrupt somehow...
> setup_bad:
> movl $setup_corrupt, %eax
> - calll puts
> # Fall through...
>
> .globl die
> .type die, @function
> die:
> + calll puts
> +1:
> hlt
> - jmp die
> + jmp 1b
>
> .size die, .-die
>
> diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
> index da01ade4959e..ad8869aad6db 100644
> --- a/arch/x86/boot/main.c
> +++ b/arch/x86/boot/main.c
> @@ -143,10 +143,8 @@ void main(void)
> init_heap();
>
> /* Make sure we have all the proper CPU support */
> - if (validate_cpu()) {
> - puts("Unable to boot - please use a kernel appropriate for your CPU.\n");
> - die();
> - }
> + if (validate_cpu())
> + die("Unable to boot - please use a kernel appropriate for your CPU.\n");
>
> /* Tell the BIOS what CPU mode we intend to run in */
> set_bios_mode();
> diff --git a/arch/x86/boot/pm.c b/arch/x86/boot/pm.c
> index 5941f930f6c5..3be89ba4b1b3 100644
> --- a/arch/x86/boot/pm.c
> +++ b/arch/x86/boot/pm.c
> @@ -106,10 +106,8 @@ void go_to_protected_mode(void)
> realmode_switch_hook();
>
> /* Enable the A20 gate */
> - if (enable_a20()) {
> - puts("A20 gate not responding, unable to boot...\n");
> - die();
> - }
> + if (enable_a20())
> + die("A20 gate not responding, unable to boot...\n");
>
> /* Reset coprocessor (IGNNE#) */
> reset_coprocessor();
> --
> 2.52.0
>