Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/paravirt: Create a stack frame in PV_CALLEE_SAVE_REGS_THUNK

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>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Alok Kataria <akataria@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Chris J Arges <chris.j.arges@canonical.com>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Pedro Alves <palves@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: live-patching@vger.kernel.org
Link: http://lkml.kernel.org/r/a2cad74e87c4aba7fd0f54a1af312e66a824a575.1453405861.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Josh Poimboeuf and committed by
Ingo Molnar
87b240cb bb93eb4c

+7 -2
+7 -2
arch/x86/include/asm/paravirt.h
··· 13 13 #include <linux/bug.h> 14 14 #include <linux/types.h> 15 15 #include <linux/cpumask.h> 16 + #include <asm/frame.h> 16 17 17 18 static inline int paravirt_enabled(void) 18 19 { ··· 757 756 * call. The return value in rax/eax will not be saved, even for void 758 757 * functions. 759 758 */ 759 + #define PV_THUNK_NAME(func) "__raw_callee_save_" #func 760 760 #define PV_CALLEE_SAVE_REGS_THUNK(func) \ 761 761 extern typeof(func) __raw_callee_save_##func; \ 762 762 \ 763 763 asm(".pushsection .text;" \ 764 - ".globl __raw_callee_save_" #func " ; " \ 765 - "__raw_callee_save_" #func ": " \ 764 + ".globl " PV_THUNK_NAME(func) ";" \ 765 + ".type " PV_THUNK_NAME(func) ", @function;" \ 766 + PV_THUNK_NAME(func) ":" \ 767 + FRAME_BEGIN \ 766 768 PV_SAVE_ALL_CALLER_REGS \ 767 769 "call " #func ";" \ 768 770 PV_RESTORE_ALL_CALLER_REGS \ 771 + FRAME_END \ 769 772 "ret;" \ 770 773 ".popsection") 771 774