{
        unsigned char replaced[MCOUNT_INSN_SIZE];
 
+       ftrace_expected = old_code;
+
        /*
         * Note: Due to modules and __init, code can
         *  disappear and change, we need to protect against faulting
        if (addr == MCOUNT_ADDR)
                return ftrace_modify_code_direct(rec->ip, old, new);
 
+       ftrace_expected = NULL;
+
        /* Normal cases use add_brk_on_nop */
        WARN_ONCE(1, "invalid use of ftrace_make_nop");
        return -EINVAL;
                                 unsigned long addr)
 {
        WARN_ON(1);
+       ftrace_expected = NULL;
        return -EINVAL;
 }
 
        if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
                return -EFAULT;
 
+       ftrace_expected = old;
+
        /* Make sure it is what we expect it to be */
        if (memcmp(replaced, old, MCOUNT_INSN_SIZE) != 0)
                return -EINVAL;
                ftrace_addr = ftrace_get_addr_curr(rec);
                nop = ftrace_call_replace(ip, ftrace_addr);
 
+               ftrace_expected = nop;
+
                if (memcmp(&ins[1], &nop[1], MCOUNT_INSN_SIZE - 1) != 0)
                        return -EINVAL;
        }
 
 };
 extern enum ftrace_bug_type ftrace_bug_type;
 
+/*
+ * Archs can set this to point to a variable that holds the value that was
+ * expected at the call site before calling ftrace_bug().
+ */
+extern const void *ftrace_expected;
+
 void ftrace_bug(int err, struct dyn_ftrace *rec);
 
 struct seq_file;
 
        return __ftrace_hash_update_ipmodify(ops, old_hash, new_hash);
 }
 
-static void print_ip_ins(const char *fmt, unsigned char *p)
+static void print_ip_ins(const char *fmt, const unsigned char *p)
 {
        int i;
 
 ftrace_find_tramp_ops_any(struct dyn_ftrace *rec);
 
 enum ftrace_bug_type ftrace_bug_type;
+const void *ftrace_expected;
 
 static void print_bug_type(void)
 {
                FTRACE_WARN_ON_ONCE(1);
                pr_info("ftrace failed to modify ");
                print_ip_sym(ip);
-               print_ip_ins(" actual: ", (unsigned char *)ip);
+               print_ip_ins(" actual:   ", (unsigned char *)ip);
                pr_cont("\n");
+               if (ftrace_expected) {
+                       print_ip_ins(" expected: ", ftrace_expected);
+                       pr_cont("\n");
+               }
                break;
        case -EPERM:
                FTRACE_WARN_ON_ONCE(1);