From patchwork Fri Apr 24 02:44:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 47481 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 366AA2121F for ; Fri, 24 Apr 2015 02:45:18 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf8300193lbc.1 for ; Thu, 23 Apr 2015 19:45:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=9puCs+J+tDDyxHbtmaHiUu3oWiqffqHbFJWfmmppD14=; b=RfUEAn1+mPUNS02v/hpTBYME+T0dX8XOJGbENFFS56sjd4yDsd7afEVOSVFuVwuJZC yLYhC8ePGkhoK9JcxtFGl6p5QYK3eY3UoUzBBbnz7aSL6kFaRH2wG4RY6Iw4osdexB1W 28UH9pZqgKL+UPs2VadPqMGrjB5xZbf7lRFRpKPXT4NSr/HOaxHK5I7RpqzMHni1dTG7 R7fDhgBmYgrQqvJ+hFXrbDk+jFFkSMk8nzoJKJbZyUB2M4UyO2S5jKwz7jcT8nwo5yqs qhcy8kVxKjzzVC8AoIV929TTVm2DQp6cw/YBsHi+dNVBpe60VjRxywRwm4y9alhNYbxi edqw== X-Gm-Message-State: ALoCoQkQL/ZezyAXOwKSDQVhPQMIqw5FaI1enPXOiquhoxwLuAtXzBT6DAldSXZfm1LehL92E1ww X-Received: by 10.112.171.41 with SMTP id ar9mr2899434lbc.24.1429843517177; Thu, 23 Apr 2015 19:45:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.224.165 with SMTP id rd5ls428221lac.77.gmail; Thu, 23 Apr 2015 19:45:17 -0700 (PDT) X-Received: by 10.152.6.105 with SMTP id z9mr3900425laz.98.1429843517005; Thu, 23 Apr 2015 19:45:17 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id du6si7241371lbc.117.2015.04.23.19.45.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 19:45:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by laat2 with SMTP id t2so25787645laa.1 for ; Thu, 23 Apr 2015 19:45:16 -0700 (PDT) X-Received: by 10.112.125.138 with SMTP id mq10mr5117994lbb.35.1429843516893; Thu, 23 Apr 2015 19:45:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp922782lbt; Thu, 23 Apr 2015 19:45:16 -0700 (PDT) X-Received: by 10.69.12.227 with SMTP id et3mr10641766pbd.11.1429843515073; Thu, 23 Apr 2015 19:45:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ka1si15214893pbc.194.2015.04.23.19.45.13; Thu, 23 Apr 2015 19:45:15 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753986AbbDXCpB (ORCPT + 27 others); Thu, 23 Apr 2015 22:45:01 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:34221 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753955AbbDXCoz (ORCPT ); Thu, 23 Apr 2015 22:44:55 -0400 Received: by pacyx8 with SMTP id yx8so35089586pac.1 for ; Thu, 23 Apr 2015 19:44:54 -0700 (PDT) X-Received: by 10.68.209.193 with SMTP id mo1mr10535841pbc.142.1429843494846; Thu, 23 Apr 2015 19:44:54 -0700 (PDT) Received: from localhost.localdomain (61-205-1-167m5.grp1.mineo.jp. [61.205.1.167]) by mx.google.com with ESMTPSA id do16sm9488624pac.15.2015.04.23.19.44.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Apr 2015 19:44:53 -0700 (PDT) From: AKASHI Takahiro To: rostedt@goodmis.org, mingo@kernel.org, jpoimboe@redhat.com, sjenning@redhat.com, jkosina@suse.cz, vojtech@suse.cz, catalin.marinas@arm.com, will.deacon@arm.com Cc: broonie@kernel.org, masami.hiramatsu.pt@hitachi.com, live-patching@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [RFC 1/4] ftrace: add a helper function for livepatch Date: Fri, 24 Apr 2015 11:44:06 +0900 Message-Id: <1429843449-7388-2-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429843449-7388-1-git-send-email-takahiro.akashi@linaro.org> References: <1429843449-7388-1-git-send-email-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: takahiro.akashi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , ftrace_lookup_mcount() will return an address of mcount call in a function. Signed-off-by: AKASHI Takahiro --- include/linux/ftrace.h | 2 ++ kernel/trace/ftrace.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 1da6029..1d0271f 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -699,6 +699,8 @@ static inline void __ftrace_enabled_restore(int enabled) # define trace_preempt_off(a0, a1) do { } while (0) #endif +extern unsigned long ftrace_lookup_mcount(unsigned long addr); + #ifdef CONFIG_FTRACE_MCOUNT_RECORD extern void ftrace_init(void); #else diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 4f22802..fcfb04f 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -4857,6 +4857,32 @@ static int ftrace_process_locs(struct module *mod, return ret; } +unsigned long ftrace_lookup_mcount(unsigned long addr) +{ + struct ftrace_page *pg; + struct dyn_ftrace *rec; + char str[KSYM_SYMBOL_LEN]; + char *modname; + const char *name; + unsigned long mcount = 0; + unsigned long offset; + + mutex_lock(&ftrace_lock); + + do_for_each_ftrace_rec(pg, rec) { + name = kallsyms_lookup(rec->ip, NULL, &offset, &modname, str); + if (name && rec->ip == (addr + offset)) { + mcount = rec->ip; + goto out_unlock; + } + } while_for_each_ftrace_rec(); + + out_unlock: + mutex_unlock(&ftrace_lock); + + return mcount; +} + #ifdef CONFIG_MODULES #define next_to_ftrace_page(p) container_of(p, struct ftrace_page, next)