lkml.org 
[lkml]   [2022]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: objtool warning for next-20221118
    On Tue, Nov 22, 2022 at 04:22:58PM -0800, Paul E. McKenney wrote:
    > On Tue, Nov 22, 2022 at 09:35:17AM +0100, Peter Zijlstra wrote:
    > > On Mon, Nov 21, 2022 at 09:16:05PM -0800, Josh Poimboeuf wrote:
    > >
    > > > It's complaining about an unreachable instruction after a call to
    > > > arch_cpu_idle_dead(). In this case objtool detects the fact
    > > > arch_cpu_idle_dead() doesn't return due to its call to the
    > > > non-CONFIG_SMP version of play_dead(). But GCC has no way of detecting
    > > > that because the caller is in another translation unit.
    > > >
    > > > As far as I can tell, that function should never return. Though it
    > > > seems to have some dubious semantics (see xen_pv_play_dead() for
    > > > example, which *does* seem to return?). I'm thinking it would be an
    > > > improvement to enforce that noreturn behavior across all arches and
    > > > platforms, sprinkling __noreturn and BUG() on arch_cpu_idle_dead() and
    > > > maybe some of it callees, where needed.
    > > >
    > > > Peter, what do you think? I could attempt a patch.
    > >
    > > I'm thinking the Xen case makes all this really rather difficult :/
    > >
    > > While normally a CPU is brought up through a trampoline, Xen seems to
    > > have implemented it by simply returning from play_dead(), and afaict
    > > that is actually a valid way to go about doing it.
    > >
    > > Perhaps the best way would be to stick a REACHABLE annotation in
    > > arch_cpu_idle_dead() or something?
    >
    > When I apply this on -next, I still get the objtool complaint.
    > Is there something else I should also be doing?

    Silly GCC is folding the inline asm. This works (but still doesn't seem
    like the right approach):

    diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
    index 26e8f57c75ad..128e7d78fedf 100644
    --- a/arch/x86/kernel/process.c
    +++ b/arch/x86/kernel/process.c
    @@ -702,7 +702,7 @@ static void (*x86_idle)(void);
    #ifndef CONFIG_SMP
    static inline void play_dead(void)
    {
    - BUG();
    + _BUG_FLAGS(ASM_UD2, 0, ASM_REACHABLE);
    }
    #endif

    \
     
     \ /
      Last update: 2022-11-23 02:49    [W:4.522 / U:0.068 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site