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


Groups > linux.kernel > #1202925

[PATCH v9 08/20] x86/paravirt: Create a stack frame in PV_CALLEE_SAVE_REGS_THUNK

From Josh Poimboeuf <jpoimboe@redhat.com>
Newsgroups linux.kernel
Subject [PATCH v9 08/20] x86/paravirt: Create a stack frame in PV_CALLEE_SAVE_REGS_THUNK
Date 2015-08-07 19:00 +0200
Message-ID <pUT9W-5pP-35@gated-at.bofh.it> (permalink)
References <pUT9U-5pP-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


A function created with the PV_CALLEE_SAVE_REGS_THUNK macro doesn't set
up a new stack frame before the call instruction, which breaks frame
pointer convention if CONFIG_FRAME_POINTER is enabled and can result in
a bad stack trace.  Also, the thunk functions aren't annotated as ELF
callable functions.

Create a stack frame when CONFIG_FRAME_POINTER is enabled and add the
ELF function type.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Alok Kataria <akataria@vmware.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
---
 arch/x86/include/asm/paravirt.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index c2be037..0d28801 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -13,6 +13,7 @@
 #include <linux/bug.h>
 #include <linux/types.h>
 #include <linux/cpumask.h>
+#include <asm/frame.h>
 
 static inline int paravirt_enabled(void)
 {
@@ -772,15 +773,19 @@ static __always_inline void __ticket_unlock_kick(struct arch_spinlock *lock,
  * call. The return value in rax/eax will not be saved, even for void
  * functions.
  */
+#define PV_THUNK_NAME(func) "__raw_callee_save_" #func
 #define PV_CALLEE_SAVE_REGS_THUNK(func)					\
 	extern typeof(func) __raw_callee_save_##func;			\
 									\
 	asm(".pushsection .text;"					\
-	    ".globl __raw_callee_save_" #func " ; "			\
-	    "__raw_callee_save_" #func ": "				\
+	    ".globl " PV_THUNK_NAME(func) ";"				\
+	    ".type " PV_THUNK_NAME(func) ", @function;"			\
+	    PV_THUNK_NAME(func) ":"					\
+	    FRAME_BEGIN							\
 	    PV_SAVE_ALL_CALLER_REGS					\
 	    "call " #func ";"						\
 	    PV_RESTORE_ALL_CALLER_REGS					\
+	    FRAME_END							\
 	    "ret;"							\
 	    ".popsection")
 
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


Thread

[PATCH v9 00/20] Compile-time stack validation Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 05/20] x86/stackvalidate: Add ignore macros Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 03/20] x86/stackvalidate: Compile-time stack validation Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 18/20] x86/asm: Create stack frames in rwsem functions Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 16/20] x86/asm/entry: Create stack frames in thunk functions Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 13/20] x86/asm/crypto: Move .Lbswap_mask data to .rodata section Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 01/20] x86/asm: Frame pointer macro cleanup Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 08/20] x86/paravirt: Create a stack frame in PV_CALLEE_SAVE_REGS_THUNK Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 11/20] x86/xen: Add xen_cpuid() and xen_setup_gdt() to stackvalidate whitelists Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 09/20] x86/amd: Set ELF function type for vide() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 14/20] x86/asm/crypto: Move jump_table to .rodata section Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 15/20] x86/asm/crypto: Create stack frames in clmul_ghash_mul/update() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 20/20] x86/asm/power: Create stack frames in hibernate_asm_64.S Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
    Re: [PATCH v9 20/20] x86/asm/power: Create stack frames in  hibernate_asm_64.S Pavel Machek <pavel@ucw.cz> - 2015-08-09 21:20 +0200
  [PATCH v9 10/20] x86/reboot: Add ljmp instructions to stackvalidate whitelist Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200
  [PATCH v9 04/20] x86/stackvalidate: Add file and directory ignores Josh Poimboeuf <jpoimboe@redhat.com> - 2015-08-07 19:00 +0200

csiph-web