Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1338132

Re: [PATCH] sched/x86: Add stack frame dependency to __preempt_schedule[_notrace]

From Jiri Slaby <jslaby@suse.cz>
Newsgroups linux.kernel
Subject Re: [PATCH] sched/x86: Add stack frame dependency to __preempt_schedule[_notrace]
Date 2016-02-19 13:10 +0100
Message-ID <r3S2K-4Vi-25@gated-at.bofh.it> (permalink)
References (5 earlier) <r1sm5-3kI-5@gated-at.bofh.it> <r2ulR-3v3-27@gated-at.bofh.it> <r2xD5-5Wh-21@gated-at.bofh.it> <r2xD5-5Wh-23@gated-at.bofh.it> <r3ASf-CA-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 02/18/2016, 06:41 PM, Josh Poimboeuf wrote:
> If __preempt_schedule() or __preempt_schedule_notrace() is referenced at
> the beginning of a function, gcc can insert the asm inline "call
> ___preempt_schedule[_notrace]" instruction before setting up a stack
> frame, which breaks frame pointer convention if CONFIG_FRAME_POINTER is
> enabled and can result in bad stack traces.
> 
> Force a stack frame to be created if CONFIG_FRAME_POINTER is enabled by
> listing the stack pointer as an output operand for the inline asm
> statements.
> 
> Specifically this fixes the following stacktool warnings:
> 
>   stacktool: drivers/scsi/hpsa.o: hpsa_scsi_do_simple_cmd.constprop.106()+0x79: call without frame pointer save/setup
...
> Reported-by: Jiri Slaby <jslaby@suse.cz>

This patch and adding lbug_with_loc to global_noreturns makes all
stacktool warnings go away here.

> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> ---
>  arch/x86/include/asm/preempt.h | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h
> index 01bcde8..d397deb 100644
> --- a/arch/x86/include/asm/preempt.h
> +++ b/arch/x86/include/asm/preempt.h
> @@ -94,10 +94,19 @@ static __always_inline bool should_resched(int preempt_offset)
>  
>  #ifdef CONFIG_PREEMPT
>    extern asmlinkage void ___preempt_schedule(void);
> -# define __preempt_schedule() asm ("call ___preempt_schedule")
> +# define __preempt_schedule()					\
> +({								\
> +	register void *__sp asm(_ASM_SP);			\
> +	asm volatile ("call ___preempt_schedule" : "+r"(__sp));	\
> +})
> +
>    extern asmlinkage void preempt_schedule(void);
>    extern asmlinkage void ___preempt_schedule_notrace(void);
> -# define __preempt_schedule_notrace() asm ("call ___preempt_schedule_notrace")
> +# define __preempt_schedule_notrace()					\
> +({									\
> +	register void *__sp asm(_ASM_SP);				\
> +	asm volatile ("call ___preempt_schedule_notrace" : "+r"(__sp));	\
> +})
>    extern asmlinkage void preempt_schedule_notrace(void);
>  #endif
>  
> 

thanks,
-- 
js
suse labs

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH 00/33] Compile-time stack metadata validation Jiri Slaby <jslaby@suse.cz> - 2016-02-12 11:40 +0100
  Re: [PATCH 00/33] Compile-time stack metadata validation Jiri Slaby <jslaby@suse.cz> - 2016-02-12 11:50 +0100
  Re: [PATCH 00/33] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-12 15:50 +0100
    Re: [PATCH 00/33] Compile-time stack metadata validation Peter Zijlstra <peterz@infradead.org> - 2016-02-12 18:20 +0100
      Re: [PATCH 00/33] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-12 19:40 +0100
      Re: [PATCH 00/33] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-12 19:40 +0100
        Re: [PATCH 00/33] Compile-time stack metadata validation Peter Zijlstra <peterz@infradead.org> - 2016-02-12 21:20 +0100
          Re: [PATCH 00/33] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-15 17:40 +0100
            Re: [PATCH 00/33] Compile-time stack metadata validation Peter Zijlstra <peterz@infradead.org> - 2016-02-15 18:00 +0100
            Re: [PATCH 00/33] Compile-time stack metadata validation Andi Kleen <andi@firstfloor.org> - 2016-02-15 21:10 +0100
            Re: [PATCH 00/33] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-15 21:10 +0100
              [PATCH] sched/x86: Add stack frame dependency to  __preempt_schedule[_notrace] Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-18 18:50 +0100
                Re: [PATCH] sched/x86: Add stack frame dependency to  __preempt_schedule[_notrace] Jiri Slaby <jslaby@suse.cz> - 2016-02-19 13:10 +0100

csiph-web