ftrace/x86: Add dynamic allocated trampoline for ftrace_ops
[deliverable/linux.git] / arch / x86 / kernel / mcount_64.S
index c73aecf10d34a6b8f12bac3eff1bf64110ae664f..42f0cdd20bafcfaf62f1d071ea8c60c2f319a494 100644 (file)
@@ -28,9 +28,11 @@ ENTRY(function_hook)
 END(function_hook)
 
 /* skip is set if stack has been adjusted */
-.macro ftrace_caller_setup skip=0
+.macro ftrace_caller_setup trace_label skip=0
        MCOUNT_SAVE_FRAME \skip
 
+       /* Save this location */
+GLOBAL(\trace_label)
        /* Load the ftrace_ops into the 3rd parameter */
        movq function_trace_op(%rip), %rdx
 
@@ -46,7 +48,7 @@ END(function_hook)
 .endm
 
 ENTRY(ftrace_caller)
-       ftrace_caller_setup
+       ftrace_caller_setup ftrace_caller_op_ptr
        /* regs go into 4th parameter (but make it NULL) */
        movq $0, %rcx
 
@@ -54,7 +56,14 @@ GLOBAL(ftrace_call)
        call ftrace_stub
 
        MCOUNT_RESTORE_FRAME
-ftrace_return:
+
+       /*
+        * The copied trampoline must call ftrace_return as it
+        * still may need to call the function graph tracer.
+        */
+GLOBAL(ftrace_caller_end)
+
+GLOBAL(ftrace_return)
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 GLOBAL(ftrace_graph_call)
@@ -70,7 +79,7 @@ ENTRY(ftrace_regs_caller)
        pushfq
 
        /* skip=8 to skip flags saved in SS */
-       ftrace_caller_setup 8
+       ftrace_caller_setup ftrace_regs_caller_op_ptr 8
 
        /* Save the rest of pt_regs */
        movq %r15, R15(%rsp)
@@ -122,6 +131,14 @@ GLOBAL(ftrace_regs_call)
        /* Restore flags */
        popfq
 
+       /*
+        * As this jmp to ftrace_return can be a short jump
+        * it must not be copied into the trampoline.
+        * The trampoline will add the code to jump
+        * to the return.
+        */
+GLOBAL(ftrace_regs_caller_end)
+
        jmp ftrace_return
 
        popfq
This page took 0.027012 seconds and 5 git commands to generate.