Skip to contentSkip to conversation

x86/smpboot: Mark native_play_dead() as __noreturn

PATCH Applied Thorsten Blum 3 participants 5 messages Oct 27, 2025 – Oct 31, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/smpboot: Mark native_play_dead() as __noreturn

native_play_dead() ends by calling the non-returning function hlt_play_dead() and therefore also never returns.

The !CONFIG_HOTPLUG_CPU stub version of native_play_dead() unconditionally calls BUG() and does not return either.

Add the __noreturn attribute to both function definitions and their declaration to document this behavior and to potentially improve compiler optimizations.

Remove the obsolete comment, and add native_play_dead() to the objtool's list of __noreturn functions.

---
 arch/x86/include/asm/smp.h | 2 +-
 arch/x86/kernel/smpboot.c  | 8 ++------
 tools/objtool/noreturns.h  | 1 +
 3 files changed, 4 insertions(+), 7 deletions(-)
arch/x86/include/asm/smp.h +1 -1
index 22bfebe6776d..84951572ab81 100644
@@ -109,7 +109,7 @@ int common_cpu_up(unsigned int cpunum, struct task_struct *tidle);
 int native_kick_ap(unsigned int cpu, struct task_struct *tidle);
 int native_cpu_disable(void);
 void __noreturn hlt_play_dead(void);
-void native_play_dead(void);
+void __noreturn native_play_dead(void);
 void play_dead_common(void);
 void wbinvd_on_cpu(int cpu);
 void wbinvd_on_all_cpus(void);
arch/x86/kernel/smpboot.c +2 -6
index eb289abece23..a4ba735842a8 100644
@@ -1328,11 +1328,7 @@ void __noreturn hlt_play_dead(void)
 		native_halt();
 }
 
-/*
- * native_play_dead() is essentially a __noreturn function, but it can't
- * be marked as such as the compiler may complain about it.
- */
-void native_play_dead(void)
+void __noreturn native_play_dead(void)
 {
 	if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS))
 		__update_spec_ctrl(0);
@@ -1351,7 +1347,7 @@ int native_cpu_disable(void)
 	return -ENOSYS;
 }
 
-void native_play_dead(void)
+void __noreturn native_play_dead(void)
 {
 	BUG();
 }
tools/objtool/noreturns.h +1 -0
index 802895fae3ca..14f8ab653449 100644
@@ -36,6 +36,7 @@ NORETURN(machine_real_restart)
 NORETURN(make_task_dead)
 NORETURN(mpt_halt_firmware)
 NORETURN(mwait_play_dead)
+NORETURN(native_play_dead)
 NORETURN(nmi_panic_self_stop)
 NORETURN(panic)
 NORETURN(vpanic)
Signature · 1 line
2.51.0
maintainer
#1 lore raw
Quoted 6 lines · Thorsten Blum

native_play_dead() ends by calling the non-returning function hlt_play_dead() and therefore also never returns.

The !CONFIG_HOTPLUG_CPU stub version of native_play_dead() unconditionally calls BUG() and does not return either.

Quoted 8 lines

Add the __noreturn attribute to both function definitions and their declaration to document this behavior and to potentially improve compiler optimizations.

Remove the obsolete comment, and add native_play_dead() to the objtool's list of __noreturn functions.

Is there an objtool warning that this fixes? If so, it would be helpful to put it in the description above.

And same for the other patch.

Otherwise it LGTM. Thanks!

Signature · 1 line
Josh
#2 lore raw
Quoted 11 lines · Josh Poimboeuf
Quoted 10 lines · Thorsten Blum

native_play_dead() ends by calling the non-returning function hlt_play_dead() and therefore also never returns.

The !CONFIG_HOTPLUG_CPU stub version of native_play_dead() unconditionally calls BUG() and does not return either.

Add the __noreturn attribute to both function definitions and their declaration to document this behavior and to potentially improve compiler optimizations.

Quoted 7 lines
Quoted 4 lines

Remove the obsolete comment, and add native_play_dead() to the objtool's list of __noreturn functions.

Is there an objtool warning that this fixes? If so, it would be helpful to put it in the description above.

Not that I'm aware of.

maintainer Acked-by
#3 lore raw
Quoted 15 lines · Thorsten Blum
Quoted 14 lines · Josh Poimboeuf
Quoted 13 lines · Thorsten Blum

native_play_dead() ends by calling the non-returning function hlt_play_dead() and therefore also never returns.

The !CONFIG_HOTPLUG_CPU stub version of native_play_dead() unconditionally calls BUG() and does not return either.

Add the __noreturn attribute to both function definitions and their declaration to document this behavior and to potentially improve compiler optimizations.

Remove the obsolete comment, and add native_play_dead() to the objtool's list of __noreturn functions.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Is there an objtool warning that this fixes? If so, it would be helpful to put it in the description above.

Not that I'm aware of.

Ok.

Signature · 1 line
Josh
merge bot Applied
#4 lore raw
In reply to Thorsten Blum
The following commit has been merged into the objtool/core branch of tip:

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     0ccf30fc64acca8e43a54a4f54fb3a4f155d4692
Gitweb:        https://git.kernel.org/tip/0ccf30fc64acca8e43a54a4f54fb3a4f155d4692
Author:        Thorsten Blum <[email protected]>
AuthorDate:    Mon, 27 Oct 2025 16:51:02 +01:00
Committer:     Josh Poimboeuf <[email protected]>
CommitterDate: Thu, 30 Oct 2025 08:29:41 -07:00

x86/smpboot: Mark native_play_dead() as __noreturn

native_play_dead() ends by calling the non-returning function hlt_play_dead() and therefore also never returns.

The !CONFIG_HOTPLUG_CPU stub version of native_play_dead() unconditionally calls BUG() and does not return either.

Add the __noreturn attribute to both function definitions and their declaration to document this behavior and to potentially improve compiler optimizations.

Remove the obsolete comment, and add native_play_dead() to the objtool's list of __noreturn functions.

---
 arch/x86/include/asm/smp.h | 2 +-
 arch/x86/kernel/smpboot.c  | 8 ++------
 tools/objtool/noreturns.h  | 1 +
 3 files changed, 4 insertions(+), 7 deletions(-)
arch/x86/include/asm/smp.h +1 -1
index 22bfebe..8495157 100644
@@ -109,7 +109,7 @@ int common_cpu_up(unsigned int cpunum, struct task_struct *tidle);
 int native_kick_ap(unsigned int cpu, struct task_struct *tidle);
 int native_cpu_disable(void);
 void __noreturn hlt_play_dead(void);
-void native_play_dead(void);
+void __noreturn native_play_dead(void);
 void play_dead_common(void);
 void wbinvd_on_cpu(int cpu);
 void wbinvd_on_all_cpus(void);
arch/x86/kernel/smpboot.c +2 -6
index eb289ab..a4ba735 100644
@@ -1328,11 +1328,7 @@ void __noreturn hlt_play_dead(void)
 		native_halt();
 }
 
-/*
- * native_play_dead() is essentially a __noreturn function, but it can't
- * be marked as such as the compiler may complain about it.
- */
-void native_play_dead(void)
+void __noreturn native_play_dead(void)
 {
 	if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS))
 		__update_spec_ctrl(0);
@@ -1351,7 +1347,7 @@ int native_cpu_disable(void)
 	return -ENOSYS;
 }
 
-void native_play_dead(void)
+void __noreturn native_play_dead(void)
 {
 	BUG();
 }
tools/objtool/noreturns.h +1 -0
index 802895f..14f8ab6 100644
@@ -36,6 +36,7 @@ NORETURN(machine_real_restart)
 NORETURN(make_task_dead)
 NORETURN(mpt_halt_firmware)
 NORETURN(mwait_play_dead)
+NORETURN(native_play_dead)
 NORETURN(nmi_panic_self_stop)
 NORETURN(panic)
 NORETURN(vpanic)