Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754110AbeAKIDF (ORCPT + 1 other); Thu, 11 Jan 2018 03:03:05 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:45956 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753686AbeAKIDD (ORCPT ); Thu, 11 Jan 2018 03:03:03 -0500 X-Google-Smtp-Source: ACJfBoulz9EGOuYFi0nHQBAbnGIk90hygOBXxE+O8G22U92GdFjqaohGz4xo8fR7WaKuyKP6fRrHZQ== Date: Thu, 11 Jan 2018 16:02:57 +0800 From: Alan Kao To: Steven Rostedt 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: <20180111080255.GA2848@93d8b218059b> References: <20180110073814.32338-1-alankao@andestech.com> <20180110073814.32338-3-alankao@andestech.com> <20180110113643.7622a7d3@vmware.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180110113643.7622a7d3@vmware.local.home> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Wed, Jan 10, 2018 at 11:36:43AM -0500, Steven Rostedt wrote: > On Wed, 10 Jan 2018 15:38:10 +0800 > Alan Kao wrote: > > > +static int __ftrace_modify_call(unsigned long hook_pos, unsigned long target, > > + bool enable) > > +{ > > + unsigned int offset = (unsigned int)(target - hook_pos); > > + unsigned int auipc_call = to_auipc_insn(offset); > > + unsigned int jalr_call = to_jalr_insn(offset); > > + unsigned int calls[2] = {auipc_call, jalr_call}; > > + unsigned int nops[2] = {NOP4, NOP4}; > > + int ret = 0; > > + > > + /* when ftrace_make_nop is called */ > > + if (!enable) > > + ret = ftrace_check_current_call(hook_pos, calls); > > + > > + if (ret) > > + goto out; > > + > > + /* replace the auipc-jalr pair at once */ > > + ret = probe_kernel_write((void *)hook_pos, enable ? calls : nops, > > + MCOUNT_INSN_SIZE); > > + if (ret) > > You don't want to return the return of probe_kernel_write() here. For > ftrace bug to work properly, if a fail to write occurs, you need to > return -EPERM. > > -- Steve > Thanks for the correction and the style fix in the previous mail. These problems will be fixed in the next version patch. Alan