x86/kprobes: Get rid of kretprobe_trampoline_holder()
authorJosh Poimboeuf <jpoimboe@redhat.com>
Thu, 21 Jan 2016 22:49:28 +0000 (16:49 -0600)
committerIngo Molnar <mingo@kernel.org>
Wed, 24 Feb 2016 07:35:44 +0000 (08:35 +0100)
The kretprobe_trampoline_holder() wrapper around kretprobe_trampoline()
isn't used anywhere and adds some unnecessary frame pointer instructions
which never execute.  Instead, just make kretprobe_trampoline() a proper
ELF function.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
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: David S. Miller <davem@davemloft.net>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
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: Thomas Gleixner <tglx@linutronix.de>
Cc: live-patching@vger.kernel.org
Link: http://lkml.kernel.org/r/92d921b102fb865a7c254cfde9e4a0a72b9a781e.1453405861.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/kprobes/core.c

index 1deffe6cc87367631fe23b4c5d4b6be697ff4b0e..5b187dfbfc8b9e48136872750eac9e2a89d8ccf4 100644 (file)
@@ -671,38 +671,37 @@ NOKPROBE_SYMBOL(kprobe_int3_handler);
  * When a retprobed function returns, this code saves registers and
  * calls trampoline_handler() runs, which calls the kretprobe's handler.
  */
-static void __used kretprobe_trampoline_holder(void)
-{
-       asm volatile (
-                       ".global kretprobe_trampoline\n"
-                       "kretprobe_trampoline: \n"
+asm(
+       ".global kretprobe_trampoline\n"
+       ".type kretprobe_trampoline, @function\n"
+       "kretprobe_trampoline:\n"
 #ifdef CONFIG_X86_64
-                       /* We don't bother saving the ss register */
-                       "       pushq %rsp\n"
-                       "       pushfq\n"
-                       SAVE_REGS_STRING
-                       "       movq %rsp, %rdi\n"
-                       "       call trampoline_handler\n"
-                       /* Replace saved sp with true return address. */
-                       "       movq %rax, 152(%rsp)\n"
-                       RESTORE_REGS_STRING
-                       "       popfq\n"
+       /* We don't bother saving the ss register */
+       "       pushq %rsp\n"
+       "       pushfq\n"
+       SAVE_REGS_STRING
+       "       movq %rsp, %rdi\n"
+       "       call trampoline_handler\n"
+       /* Replace saved sp with true return address. */
+       "       movq %rax, 152(%rsp)\n"
+       RESTORE_REGS_STRING
+       "       popfq\n"
 #else
-                       "       pushf\n"
-                       SAVE_REGS_STRING
-                       "       movl %esp, %eax\n"
-                       "       call trampoline_handler\n"
-                       /* Move flags to cs */
-                       "       movl 56(%esp), %edx\n"
-                       "       movl %edx, 52(%esp)\n"
-                       /* Replace saved flags with true return address. */
-                       "       movl %eax, 56(%esp)\n"
-                       RESTORE_REGS_STRING
-                       "       popf\n"
+       "       pushf\n"
+       SAVE_REGS_STRING
+       "       movl %esp, %eax\n"
+       "       call trampoline_handler\n"
+       /* Move flags to cs */
+       "       movl 56(%esp), %edx\n"
+       "       movl %edx, 52(%esp)\n"
+       /* Replace saved flags with true return address. */
+       "       movl %eax, 56(%esp)\n"
+       RESTORE_REGS_STRING
+       "       popf\n"
 #endif
-                       "       ret\n");
-}
-NOKPROBE_SYMBOL(kretprobe_trampoline_holder);
+       "       ret\n"
+       ".size kretprobe_trampoline, .-kretprobe_trampoline\n"
+);
 NOKPROBE_SYMBOL(kretprobe_trampoline);
 
 /*