[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260120195407.1163051-6-hpa@zytor.com>
Date: Tue, 20 Jan 2026 11:53:57 -0800
From: "H. Peter Anvin" <hpa@...or.com>
To: Thomas Gleixner <tglx@...nel.org>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Uros Bizjak <ubizjak@...il.com>, Petr Mladek <pmladek@...e.com>,
Andrew Morton <akpm@...ux-foundation.org>, Kees Cook <kees@...nel.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Nathan Chancellor <nathan@...nel.org>,
Kiryl Shutsemau <kas@...nel.org>,
Rick Edgecombe <rick.p.edgecombe@...el.com>
Cc: "H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org,
linux-coco@...ts.linux.dev, x86@...nel.org
Subject: [PATCH v1 05/14] x86/boot: call puts() from within die()
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@...or.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
Powered by blists - more mailing lists