Return-Path: Received: from hrndva-omtalb.mail.rr.com (hrndva-omtalb.mail.rr.com [71.74.56.124]) by ozlabs.org (Postfix) with ESMTP id 9652ADDDEA for ; Tue, 18 Nov 2008 06:11:02 +1100 (EST) Message-Id: <20081117191059.408002035@goodmis.org> References: <20081117190948.619751203@goodmis.org> Date: Mon, 17 Nov 2008 14:09:50 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Subject: [PATCH 2/4] ftrace,ppc: fix test of 24bit jump Cc: Andrew Morton , Peter Zijlstra , Rusty Russell , Pekka Paalanen , David Miller , linuxppc-dev@ozlabs.org, Steven Rostedt , Paul Mundt , Paul Mackerras , Frederic Weisbecker , Ingo Molnar , Thomas Gleixner List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Impact: fix of test if an address is 26 bits away or not Paul Mackerras pointed out that the test of the 24bit offset jump was incorrect. For one thing, it is a 26 bit distance since we multiply by 4 to account for the alignment. Another is that it may produce an incorrect result on a negative jump of exactly the offset size. Reported-by: Paul Mackerras Signed-off-by: Steven Rostedt --- arch/powerpc/kernel/ftrace.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c index 9360fd1..918a5d2 100644 --- a/arch/powerpc/kernel/ftrace.c +++ b/arch/powerpc/kernel/ftrace.c @@ -114,12 +114,19 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code, */ static int test_24bit_addr(unsigned long ip, unsigned long addr) { - unsigned long diff; + long diff; - /* can we get to addr from ip in 24 bits? */ - diff = ip > addr ? ip - addr : addr - ip; + /* + * Can we get to addr from ip in 24 bits? + * (26 really, since we mulitply by 4 for 4 byte alignment) + */ + diff = addr - ip; - return !(diff & ((unsigned long)-1 << 24)); + /* + * Return true if diff is less than 1 << 25 + * and greater than -1 << 26. + */ + return (diff < (1 << 25)) && (diff > (-1 << 26)); } static int is_bl_op(unsigned int op) -- 1.5.6.5 --