lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <25592ab5-5d8a-46ed-86a2-a0c58eed9f60@paulmck-laptop>
Date: Fri, 28 Feb 2025 16:33:23 -0800
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Josh Poimboeuf <jpoimboe@...nel.org>
Cc: patryk.wlazlyn@...ux.intel.com, artem.bityutskiy@...ux.intel.com,
	dave.hansen@...ux.intel.com, gautham.shenoy@....com,
	rafael.j.wysocki@...el.com, linux-kernel@...r.kernel.org,
	sfr@...b.auug.org.au, peterz@...radead.org
Subject: Re: [BUG objtool,x86] Missing __noreturn annotation in
 acpi_processor_ffh_play_dead()

On Fri, Feb 28, 2025 at 02:00:39PM -0800, Josh Poimboeuf wrote:
> On Fri, Feb 28, 2025 at 11:51:26AM -0800, Paul E. McKenney wrote:
> > On Fri, Feb 28, 2025 at 11:12:13AM -0800, Josh Poimboeuf wrote:
> > > On Fri, Feb 28, 2025 at 11:00:07AM -0800, Paul E. McKenney wrote:
> > > > Hello!
> > > > 
> > > > My recent -next testing hits this objtool complaint:
> > > > 
> > > > vmlinux.o: warning: objtool: acpi_idle_play_dead+0x3c: acpi_processor_ffh_play_dead() is missing a __noreturn annotation
> > > > 
> > > > My attempts to silence this by adding the suggested __noreturn annotations
> > > > didn't help, and often got me compiler warnings about __noreturn functions
> > > > actually returning.  So I bisected, which converges on this innocent-looking
> > > > commit:
> > > > 
> > > > a7dd183f0b38 ("x86/smp: Allow calling mwait_play_dead with an arbitrary hint")
> > > > 
> > > > Several runs verified that this really is the commit that objtool is
> > > > complaining about.  Unfortunately, this commit does not revert cleanly.
> > > > 
> > > > This is from builds using clang version 19.1.5 (CentOS 19.1.5-2.el9).
> > > > 
> > > > Help?
> > > 
> > > I can take a look.  Is it LLVM defconfig?  Otherwise can you send the
> > > .config?
> > 
> > Thank you!  And rcutorture modifies whatever defconfig it gets. so please
> > see below for the full .config.
> 
> With your config I actually get a different warning:
> 
>         vmlinux.o: warning: objtool: acpi_processor_ffh_play_dead+0x67: mwait_play_dead() is missing a __noreturn annotation
> 
> The below patch should fix both, can you confirm it fixes yours?
> 
> From: Josh Poimboeuf <jpoimboe@...nel.org>
> Subject: [PATCH] x86/smp: Fix __noreturn annotations for mwait_play_dead() and
>  acpi_processor_ffh_play_dead()
> 
> mwait_play_dead() doesn't return, but only has a partial __noreturn
> annotation.
> 
> acpi_processor_ffh_play_dead() also doesn't return due to its
> unconditional calling of mwait_play_dead().
> 
> Fix the annotations for both functions.
> 
> This fixes the following 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
> 
> Reported-by: "Paul E. McKenney" <paulmck@...nel.org>
> Fixes: a7dd183f0b38 ("x86/smp: Allow calling mwait_play_dead with an arbitrary hint")
> Fixes: 541ddf31e300 ("ACPI/processor_idle: Add FFH state handling")
> Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>

Aha!  The tools/objtool/noreturns.h is either new to me or was forgotten
by me.  ;-)

This does indeed handle the objtool warnings for CONFIG_SMP=y builds,
so thank you!

But for CONFIG_SMP=n builds, I get the following:

arch/x86/kernel/acpi/cstate.c: In function ‘acpi_processor_ffh_play_dead’:
arch/x86/kernel/acpi/cstate.c:216:1: error: ‘noreturn’ function does return [-Werror

And in this build configuration, it does look like mwait_play_dead is an
empty static inline function.  I could imagine making that __noreturn be
a CPP macro, but I could also imagine making mwait_play_dead() refrain
from returning.

Thoughts?

							Thanx, Paul

> ---
>  arch/x86/include/asm/smp.h    | 2 +-
>  arch/x86/kernel/acpi/cstate.c | 2 +-
>  include/acpi/processor.h      | 2 +-
>  tools/objtool/noreturns.h     | 2 ++
>  4 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
> index 80f8bfd83fc7..9c7ae0a214dc 100644
> --- a/arch/x86/include/asm/smp.h
> +++ b/arch/x86/include/asm/smp.h
> @@ -114,7 +114,7 @@ void wbinvd_on_cpu(int cpu);
>  int wbinvd_on_all_cpus(void);
>  
>  void smp_kick_mwait_play_dead(void);
> -void mwait_play_dead(unsigned int eax_hint);
> +void __noreturn mwait_play_dead(unsigned int eax_hint);
>  
>  void native_smp_send_reschedule(int cpu);
>  void native_send_call_func_ipi(const struct cpumask *mask);
> diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
> index 86c87c01d23d..d25584255ab8 100644
> --- a/arch/x86/kernel/acpi/cstate.c
> +++ b/arch/x86/kernel/acpi/cstate.c
> @@ -206,7 +206,7 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
>  }
>  EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe);
>  
> -void acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx)
> +void __noreturn acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx)
>  {
>  	unsigned int cpu = smp_processor_id();
>  	struct cstate_entry *percpu_entry;
> diff --git a/include/acpi/processor.h b/include/acpi/processor.h
> index 63a37e72b721..86b6b17b0f70 100644
> --- a/include/acpi/processor.h
> +++ b/include/acpi/processor.h
> @@ -280,7 +280,7 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
>  				    struct acpi_processor_cx *cx,
>  				    struct acpi_power_register *reg);
>  void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
> -void acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx);
> +void __noreturn acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx);
>  #else
>  static inline void acpi_processor_power_init_bm_check(struct
>  						      acpi_processor_flags
> diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h
> index b2174894f9f7..5a4aec4c4639 100644
> --- a/tools/objtool/noreturns.h
> +++ b/tools/objtool/noreturns.h
> @@ -16,6 +16,7 @@ NORETURN(__tdx_hypercall_failed)
>  NORETURN(__ubsan_handle_builtin_unreachable)
>  NORETURN(__x64_sys_exit)
>  NORETURN(__x64_sys_exit_group)
> +NORETURN(acpi_processor_ffh_play_dead)
>  NORETURN(arch_cpu_idle_dead)
>  NORETURN(bch2_trans_in_restart_error)
>  NORETURN(bch2_trans_restart_error)
> @@ -34,6 +35,7 @@ NORETURN(kunit_try_catch_throw)
>  NORETURN(machine_real_restart)
>  NORETURN(make_task_dead)
>  NORETURN(mpt_halt_firmware)
> +NORETURN(mwait_play_dead)
>  NORETURN(nmi_panic_self_stop)
>  NORETURN(panic)
>  NORETURN(panic_smp_self_stop)
> -- 
> 2.48.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ