Merge tag 'trace-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux...
[linux-2.6-microblaze.git] / arch / x86 / kernel / ftrace_64.S
index 6e8961c..369e61f 100644 (file)
@@ -85,6 +85,7 @@
        movq %rdi, RDI(%rsp)
        movq %r8, R8(%rsp)
        movq %r9, R9(%rsp)
+       movq $0, ORIG_RAX(%rsp)
        /*
         * Save the original RBP. Even though the mcount ABI does not
         * require this, it helps out callers.
        subq $MCOUNT_INSN_SIZE, %rdi
        .endm
 
-.macro restore_mcount_regs
+.macro restore_mcount_regs save=0
+
+       /* ftrace_regs_caller or frame pointers require this */
+       movq RBP(%rsp), %rbp
+
        movq R9(%rsp), %r9
        movq R8(%rsp), %r8
        movq RDI(%rsp), %rdi
        movq RCX(%rsp), %rcx
        movq RAX(%rsp), %rax
 
-       /* ftrace_regs_caller can modify %rbp */
-       movq RBP(%rsp), %rbp
-
-       addq $MCOUNT_REG_SIZE, %rsp
+       addq $MCOUNT_REG_SIZE-\save, %rsp
 
        .endm
 
@@ -174,6 +176,8 @@ SYM_FUNC_START(ftrace_regs_caller)
        /* Save the current flags before any operations that can change them */
        pushfq
 
+       UNWIND_HINT_SAVE
+
        /* added 8 bytes to save flags */
        save_mcount_regs 8
        /* save_mcount_regs fills in first two parameters */
@@ -226,7 +230,33 @@ SYM_INNER_LABEL(ftrace_regs_call, SYM_L_GLOBAL)
        movq R10(%rsp), %r10
        movq RBX(%rsp), %rbx
 
-       restore_mcount_regs
+       movq ORIG_RAX(%rsp), %rax
+       movq %rax, MCOUNT_REG_SIZE-8(%rsp)
+
+       /* If ORIG_RAX is anything but zero, make this a call to that */
+       movq ORIG_RAX(%rsp), %rax
+       cmpq    $0, %rax
+       je      1f
+
+       /* Swap the flags with orig_rax */
+       movq MCOUNT_REG_SIZE(%rsp), %rdi
+       movq %rdi, MCOUNT_REG_SIZE-8(%rsp)
+       movq %rax, MCOUNT_REG_SIZE(%rsp)
+
+       restore_mcount_regs 8
+
+       jmp     2f
+
+1:     restore_mcount_regs
+
+
+2:
+       /*
+        * The stack layout is nondetermistic here, depending on which path was
+        * taken.  This confuses objtool and ORC, rightfully so.  For now,
+        * pretend the stack always looks like the non-direct case.
+        */
+       UNWIND_HINT_RESTORE
 
        /* Restore flags */
        popfq