On Wed, 10 Jan 2018 15:38:10 +0800 Alan Kao <noner...@gmail.com> wrote:
> +static int ftrace_check_current_call(unsigned long hook_pos, > + unsigned int *expected) > +{ > + unsigned int replaced[2]; > + unsigned int nops[2] = {NOP4, NOP4}; > + > + /* we expect nops at the hook position */ > + if (!expected) > + expected = nops; > + > + /* read the text we want to modify */ > + if (probe_kernel_read(replaced, (void *)hook_pos, MCOUNT_INSN_SIZE)) > + return -EFAULT; > + > + /* Make sure it is what we expect it to be */ > + if (replaced[0] != expected[0] || replaced[1] != expected[1]) { I wonder if we can have a slight enhancement by doing: if (memcmp(replaced, expected, sizeof(replaced)) != 0) { -- Steve > + pr_err("%p: expected (%08x %08x) but get (%08x %08x)", > + (void *)hook_pos, expected[0], expected[1], replaced[0], > + replaced[1]); > + return -EINVAL; > + } > + > + return 0; > +}