Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20251027155107.183136-1-thorsten.blum@linux.dev
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

authored by

Thorsten Blum and committed by
Josh Poimboeuf
0ccf30fc f6af8690

+4 -7
+1 -1
arch/x86/include/asm/smp.h
··· 109 109 int native_kick_ap(unsigned int cpu, struct task_struct *tidle); 110 110 int native_cpu_disable(void); 111 111 void __noreturn hlt_play_dead(void); 112 - void native_play_dead(void); 112 + void __noreturn native_play_dead(void); 113 113 void play_dead_common(void); 114 114 void wbinvd_on_cpu(int cpu); 115 115 void wbinvd_on_all_cpus(void);
+2 -6
arch/x86/kernel/smpboot.c
··· 1328 1328 native_halt(); 1329 1329 } 1330 1330 1331 - /* 1332 - * native_play_dead() is essentially a __noreturn function, but it can't 1333 - * be marked as such as the compiler may complain about it. 1334 - */ 1335 - void native_play_dead(void) 1331 + void __noreturn native_play_dead(void) 1336 1332 { 1337 1333 if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS)) 1338 1334 __update_spec_ctrl(0); ··· 1347 1351 return -ENOSYS; 1348 1352 } 1349 1353 1350 - void native_play_dead(void) 1354 + void __noreturn native_play_dead(void) 1351 1355 { 1352 1356 BUG(); 1353 1357 }
+1
tools/objtool/noreturns.h
··· 36 36 NORETURN(make_task_dead) 37 37 NORETURN(mpt_halt_firmware) 38 38 NORETURN(mwait_play_dead) 39 + NORETURN(native_play_dead) 39 40 NORETURN(nmi_panic_self_stop) 40 41 NORETURN(panic) 41 42 NORETURN(vpanic)