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

x86/smp: Fix mwait_play_dead() and acpi_processor_ffh_play_dead() noreturn behavior

Fix some related issues (done in a single patch to avoid introducing
intermediate bisect warnings):

1) The SMP version of mwait_play_dead() doesn't return, but its
!SMP counterpart does. Make its calling behavior consistent by
resolving the !SMP version to a BUG(). It should never be called
anyway, this just enforces that at runtime and enables its callers
to be marked as __noreturn.

2) While the SMP definition of mwait_play_dead() is annotated as
__noreturn, the declaration isn't. Nor is it listed in
tools/objtool/noreturns.h. Fix that.

3) Similar to #1, the SMP version of acpi_processor_ffh_play_dead()
doesn't return but its !SMP counterpart does. Make the !SMP
version a BUG(). It should never be called.

4) acpi_processor_ffh_play_dead() doesn't return, but is lacking any
__noreturn annotations. Fix that.

This fixes the following objtool warnings:

vmlinux.o: warning: objtool: acpi_processor_ffh_play_dead+0x67: mwait_play_dead() is missing a __noreturn annotation
vmlinux.o: warning: objtool: acpi_idle_play_dead+0x3c: acpi_processor_ffh_play_dead() is missing a __noreturn annotation

Fixes: a7dd183f0b38 ("x86/smp: Allow calling mwait_play_dead with an arbitrary hint")
Fixes: 541ddf31e300 ("ACPI/processor_idle: Add FFH state handling")
Reported-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Link: https://lore.kernel.org/r/e885c6fa9e96a61471b33e48c2162d28b15b14c5.1740962711.git.jpoimboe@kernel.org

authored by

Josh Poimboeuf and committed by
Ingo Molnar
4e32645c 091b7686

+8 -6
+2 -2
arch/x86/include/asm/smp.h
··· 114 114 int wbinvd_on_all_cpus(void); 115 115 116 116 void smp_kick_mwait_play_dead(void); 117 - void mwait_play_dead(unsigned int eax_hint); 117 + void __noreturn mwait_play_dead(unsigned int eax_hint); 118 118 119 119 void native_smp_send_reschedule(int cpu); 120 120 void native_send_call_func_ipi(const struct cpumask *mask); ··· 166 166 return (struct cpumask *)cpumask_of(0); 167 167 } 168 168 169 - static inline void mwait_play_dead(unsigned int eax_hint) { } 169 + static inline void __noreturn mwait_play_dead(unsigned int eax_hint) { BUG(); } 170 170 #endif /* CONFIG_SMP */ 171 171 172 172 #ifdef CONFIG_DEBUG_NMI_SELFTEST
+1 -1
arch/x86/kernel/acpi/cstate.c
··· 206 206 } 207 207 EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe); 208 208 209 - void acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx) 209 + void __noreturn acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx) 210 210 { 211 211 unsigned int cpu = smp_processor_id(); 212 212 struct cstate_entry *percpu_entry;
+3 -3
include/acpi/processor.h
··· 280 280 struct acpi_processor_cx *cx, 281 281 struct acpi_power_register *reg); 282 282 void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate); 283 - void acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx); 283 + void __noreturn acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx); 284 284 #else 285 285 static inline void acpi_processor_power_init_bm_check(struct 286 286 acpi_processor_flags ··· 301 301 { 302 302 return; 303 303 } 304 - static inline void acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx) 304 + static inline void __noreturn acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx) 305 305 { 306 - return; 306 + BUG(); 307 307 } 308 308 #endif 309 309
+2
tools/objtool/noreturns.h
··· 16 16 NORETURN(__ubsan_handle_builtin_unreachable) 17 17 NORETURN(__x64_sys_exit) 18 18 NORETURN(__x64_sys_exit_group) 19 + NORETURN(acpi_processor_ffh_play_dead) 19 20 NORETURN(arch_cpu_idle_dead) 20 21 NORETURN(bch2_trans_in_restart_error) 21 22 NORETURN(bch2_trans_restart_error) ··· 35 34 NORETURN(machine_real_restart) 36 35 NORETURN(make_task_dead) 37 36 NORETURN(mpt_halt_firmware) 37 + NORETURN(mwait_play_dead) 38 38 NORETURN(nmi_panic_self_stop) 39 39 NORETURN(panic) 40 40 NORETURN(panic_smp_self_stop)