From patchwork Fri Feb 13 05:40:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 5823241 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B5233BF440 for ; Fri, 13 Feb 2015 05:52:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4EFD72034B for ; Fri, 13 Feb 2015 05:52:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A051F20328 for ; Fri, 13 Feb 2015 05:52:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YM98c-0006fx-KH; Fri, 13 Feb 2015 05:50:02 +0000 Received: from szxga02-in.huawei.com ([119.145.14.65]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YM97e-000677-E6; Fri, 13 Feb 2015 05:49:03 +0000 Received: from 172.24.2.119 (EHLO lggeml423-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CHG07679; Fri, 13 Feb 2015 13:47:24 +0800 (CST) Received: from kernel-host.huawei (10.107.197.247) by lggeml423-hub.china.huawei.com (10.72.61.33) with Microsoft SMTP Server id 14.3.158.1; Fri, 13 Feb 2015 13:47:16 +0800 From: Wang Nan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH v3 08/26] ftrace: enable make ftrace nop before ftrace_init(). Date: Fri, 13 Feb 2015 13:40:36 +0800 Message-ID: <1423806036-61825-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1423805941-61407-1-git-send-email-wangnan0@huawei.com> References: <1423805941-61407-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.197.247] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150212_214902_862303_8FE5A58E X-CRM114-Status: UNSURE ( 9.07 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) Cc: lizefan@huawei.com, x86@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch is for early kprobes. Ftrace converts ftrace entries to nop when init, which will conflict with early kprobes if it probe on an ftrace entry before such conversion. For x86, ftrace entries is 'call' instruction which is happends unboostable. This patch provides ftrace_process_loc_early() to allow early kprobes to convert target instruction before ftrace_init() is called. Only allows ftrace_process_loc_early() called before ftrace_init(). However, for x86 only this patch is not enough. Due to ideal_nop() is updated during setup_arch(), we are unable to ensure ftrace_process_loc_early() choose similar nop as normal ftrace. I'll use another mechanism to solve this problem. Signed-off-by: Wang Nan --- include/linux/ftrace.h | 5 +++++ kernel/trace/ftrace.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 8db315a..d37ccd8a 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -702,9 +702,14 @@ static inline void __ftrace_enabled_restore(int enabled) #ifdef CONFIG_FTRACE_MCOUNT_RECORD extern void ftrace_init(void); extern void ftrace_init_early(void); +extern int ftrace_process_loc_early(unsigned long ip); #else static inline void ftrace_init(void) { } static inline void ftrace_init_early(void) { } +static inline int ftrace_process_loc_early(unsigned long __unused) +{ + return 0; +} #endif /* diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index fc0c1aa..e39e72a 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5037,6 +5037,24 @@ void __init ftrace_init_early(void) ftrace_sort_mcount_area(__start_mcount_loc, __stop_mcount_loc); } +int __init ftrace_process_loc_early(unsigned long addr) +{ + unsigned long ip; + struct dyn_ftrace fake_rec; + int ret; + + BUG_ON(ftrace_pages_start); + + ip = ftrace_location(addr); + if (ip != addr) + return -EINVAL; + + memset(&fake_rec, '\0', sizeof(fake_rec)); + fake_rec.ip = ip; + ret = ftrace_make_nop(NULL, &fake_rec, MCOUNT_ADDR); + return ret; +} + /* Do nothing if arch does not support this */ void __weak arch_ftrace_update_trampoline(struct ftrace_ops *ops) {