From patchwork Fri Feb 13 15:00:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 23124 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 14CC1DDFBE for ; Sat, 14 Feb 2009 02:44:43 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from hrndva-omtalb.mail.rr.com (hrndva-omtalb.mail.rr.com [71.74.56.125]) by ozlabs.org (Postfix) with ESMTP id 2DD7BDDFC2 for ; Sat, 14 Feb 2009 02:01:48 +1100 (EST) Received: from gandalf.stny.rr.com ([74.67.89.75]) by hrndva-omta03.mail.rr.com with ESMTP id <20090213150147.MOOM16900.hrndva-omta03.mail.rr.com@gandalf.stny.rr.com>; Fri, 13 Feb 2009 15:01:47 +0000 Received: from rostedt by gandalf.stny.rr.com with local (Exim 4.69) (envelope-from ) id 1LXzY3-0007Ag-A7; Fri, 13 Feb 2009 10:01:47 -0500 Message-Id: <20090213150147.180922180@goodmis.org> References: <20090213150055.947823726@goodmis.org> User-Agent: quilt/0.46-1 Date: Fri, 13 Feb 2009 10:00:57 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org Subject: [PATCH 2/2] powerpc, ftrace: use create_branch lib function Content-Disposition: inline; filename=0002-powerpc-ftrace-use-create_branch-lib-function.patch Cc: Steven Rostedt , Paul Mackerras , Frederic Weisbecker , Ingo Molnar , Andrew Morton X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org From: Steven Rostedt Impact: clean up, remove duplicate code When ftrace was first ported to PowerPC, there existed a create_function_call that would create the instruction to make a call to a given address. Unfortunately, this call expected to write to the address it was given, and since it used the address to calculate the offset, it could not be faked. ftrace needed a way to create the instruction without actually writing that instruction to the text section. So ftrace had to implement its own code. Now we have create_branch in the code patching library, which does exactly what ftrace needs. This patch replaces ftrace's implementation with the library function. Signed-off-by: Steven Rostedt --- arch/powerpc/kernel/ftrace.c | 14 +------------- 1 files changed, 1 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c index 610c852..4c75a1c 100644 --- a/arch/powerpc/kernel/ftrace.c +++ b/arch/powerpc/kernel/ftrace.c @@ -31,11 +31,6 @@ #endif #ifdef CONFIG_DYNAMIC_FTRACE -static unsigned int ftrace_calc_offset(long ip, long addr) -{ - return (int)(addr - ip); -} - static unsigned int ftrace_nop_replace(void) { return PPC_NOP_INSTR; @@ -46,17 +41,10 @@ ftrace_call_replace(unsigned long ip, unsigned long addr, int link) { unsigned int op; - /* - * It would be nice to just use create_function_call, but that will - * update the code itself. Here we need to just return the - * instruction that is going to be modified, without modifying the - * code. - */ addr = GET_ADDR(addr); /* if (link) set op to 'bl' else 'b' */ - op = 0x48000000 | (link ? 1 : 0); - op |= (ftrace_calc_offset(ip, addr) & 0x03fffffc); + op = create_branch((unsigned int *)ip, addr, link ? 1 : 0); return op; }