lkml.org 
[lkml]   [2018]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/6] riscv/ftrace: Add dynamic function tracer support
On Wed, 10 Jan 2018 15:38:10 +0800
Alan Kao <nonerkao@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;
> +}

\
 
 \ /
  Last update: 2018-01-14 23:21    [W:0.091 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site