Merge tag 'x86_mm_for_6.2_v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
[linux-2.6-microblaze.git] / arch / x86 / kernel / ftrace.c
index 0357946..5e7ead5 100644 (file)
@@ -69,6 +69,10 @@ static const char *ftrace_nop_replace(void)
 
 static const char *ftrace_call_replace(unsigned long ip, unsigned long addr)
 {
+       /*
+        * No need to translate into a callthunk. The trampoline does
+        * the depth accounting itself.
+        */
        return text_gen_insn(CALL_INSN_OPCODE, (void *)ip, (void *)addr);
 }
 
@@ -217,7 +221,9 @@ void ftrace_replace_code(int enable)
 
                ret = ftrace_verify_code(rec->ip, old);
                if (ret) {
+                       ftrace_expected = old;
                        ftrace_bug(ret, rec);
+                       ftrace_expected = NULL;
                        return;
                }
        }
@@ -317,7 +323,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
        unsigned long size;
        unsigned long *ptr;
        void *trampoline;
-       void *ip;
+       void *ip, *dest;
        /* 48 8b 15 <offset> is movq <offset>(%rip), %rdx */
        unsigned const char op_ref[] = { 0x48, 0x8b, 0x15 };
        unsigned const char retq[] = { RET_INSN_OPCODE, INT3_INSN_OPCODE };
@@ -359,7 +365,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
 
        ip = trampoline + size;
        if (cpu_feature_enabled(X86_FEATURE_RETHUNK))
-               __text_gen_insn(ip, JMP32_INSN_OPCODE, ip, &__x86_return_thunk, JMP32_INSN_SIZE);
+               __text_gen_insn(ip, JMP32_INSN_OPCODE, ip, x86_return_thunk, JMP32_INSN_SIZE);
        else
                memcpy(ip, retq, sizeof(retq));
 
@@ -404,17 +410,19 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
        /* put in the call to the function */
        mutex_lock(&text_mutex);
        call_offset -= start_offset;
+       /*
+        * No need to translate into a callthunk. The trampoline does
+        * the depth accounting before the call already.
+        */
+       dest = ftrace_ops_get_func(ops);
        memcpy(trampoline + call_offset,
-              text_gen_insn(CALL_INSN_OPCODE,
-                            trampoline + call_offset,
-                            ftrace_ops_get_func(ops)), CALL_INSN_SIZE);
+              text_gen_insn(CALL_INSN_OPCODE, trampoline + call_offset, dest),
+              CALL_INSN_SIZE);
        mutex_unlock(&text_mutex);
 
        /* ALLOC_TRAMP flags lets us know we created it */
        ops->flags |= FTRACE_OPS_FL_ALLOC_TRAMP;
 
-       set_vm_flush_reset_perms(trampoline);
-
        set_memory_rox((unsigned long)trampoline, npages);
        return (unsigned long)trampoline;
 fail: