Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965903AbeAJQck (ORCPT + 1 other); Wed, 10 Jan 2018 11:32:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:42496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933851AbeAJQch (ORCPT ); Wed, 10 Jan 2018 11:32:37 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C403121723 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Wed, 10 Jan 2018 11:32:34 -0500 From: Steven Rostedt To: Alan Kao Cc: Palmer Dabbelt , Albert Ou , Ingo Molnar , Masahiro Yamada , Kamil Rytarowski , Andrew Morton , patches@groups.riscv.org, linux-kernel@vger.kernel.org, Alan Kao , Greentime Hu Subject: Re: [PATCH 2/6] riscv/ftrace: Add dynamic function tracer support Message-ID: <20180110113234.2fa92920@vmware.local.home> In-Reply-To: <20180110073814.32338-3-alankao@andestech.com> References: <20180110073814.32338-1-alankao@andestech.com> <20180110073814.32338-3-alankao@andestech.com> X-Mailer: Claws Mail 3.15.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Wed, 10 Jan 2018 15:38:10 +0800 Alan Kao 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; > +}