x86/asm: Create stack frames in rwsem functions
authorJosh Poimboeuf <[email protected]>
Thu, 21 Jan 2016 22:49:22 +0000 (16:49 -0600)
committerIngo Molnar <[email protected]>
Wed, 24 Feb 2016 07:35:43 +0000 (08:35 +0100)
rwsem.S has several callable non-leaf functions which don't honor
CONFIG_FRAME_POINTER, which can result in bad stack traces.

Create stack frames for them when CONFIG_FRAME_POINTER is enabled.

Signed-off-by: Josh Poimboeuf <[email protected]>
Reviewed-by: Borislav Petkov <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Bernd Petrovitsch <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Chris J Arges <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Jiri Slaby <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Michal Marek <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Pedro Alves <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/ad0932bbead975b15f9578e4f2cf2ee5961eb840.1453405861.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/lib/rwsem.S

index 40027db991405ba123a508a7d9523afe04fd744b..be110efa0096687c1ea35ada3fc439a9cb3f6180 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <linux/linkage.h>
 #include <asm/alternative-asm.h>
+#include <asm/frame.h>
 
 #define __ASM_HALF_REG(reg)    __ASM_SEL(reg, e##reg)
 #define __ASM_HALF_SIZE(inst)  __ASM_SEL(inst##w, inst##l)
 
 /* Fix up special calling conventions */
 ENTRY(call_rwsem_down_read_failed)
+       FRAME_BEGIN
        save_common_regs
        __ASM_SIZE(push,) %__ASM_REG(dx)
        movq %rax,%rdi
        call rwsem_down_read_failed
        __ASM_SIZE(pop,) %__ASM_REG(dx)
        restore_common_regs
+       FRAME_END
        ret
 ENDPROC(call_rwsem_down_read_failed)
 
 ENTRY(call_rwsem_down_write_failed)
+       FRAME_BEGIN
        save_common_regs
        movq %rax,%rdi
        call rwsem_down_write_failed
        restore_common_regs
+       FRAME_END
        ret
 ENDPROC(call_rwsem_down_write_failed)
 
 ENTRY(call_rwsem_wake)
+       FRAME_BEGIN
        /* do nothing if still outstanding active readers */
        __ASM_HALF_SIZE(dec) %__ASM_HALF_REG(dx)
        jnz 1f
@@ -109,15 +115,18 @@ ENTRY(call_rwsem_wake)
        movq %rax,%rdi
        call rwsem_wake
        restore_common_regs
-1:     ret
+1:     FRAME_END
+       ret
 ENDPROC(call_rwsem_wake)
 
 ENTRY(call_rwsem_downgrade_wake)
+       FRAME_BEGIN
        save_common_regs
        __ASM_SIZE(push,) %__ASM_REG(dx)
        movq %rax,%rdi
        call rwsem_downgrade_wake
        __ASM_SIZE(pop,) %__ASM_REG(dx)
        restore_common_regs
+       FRAME_END
        ret
 ENDPROC(call_rwsem_downgrade_wake)