From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
David Miller <davem@davemloft.net>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Pekka Paalanen <pq@iki.fi>,
linuxppc-dev@ozlabs.org, Rusty Russell <rusty@rustcorp.com.au>,
Paul Mackerras <paulus@samba.org>,
Paul Mundt <lethal@linux-sh.org>,
Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 2/4] ftrace,ppc: fix test of 24bit jump
Date: Mon, 17 Nov 2008 14:09:50 -0500 [thread overview]
Message-ID: <20081117191059.408002035@goodmis.org> (raw)
In-Reply-To: 20081117190948.619751203@goodmis.org
[-- Attachment #1: 0002-ftrace-ppc-fix-test-of-24bit-jump.patch --]
[-- Type: text/plain, Size: 1385 bytes --]
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 <paulus@samba.org>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
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
--
next prev parent reply other threads:[~2008-11-17 19:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-17 19:09 [PATCH 0/4] ftrace: PPC port of dynamic ftrace fixes Steven Rostedt
2008-11-17 19:09 ` [PATCH 1/4] ftrace,ppc: consolidate dyn ftrace ppc code between 32 and 64 bit Steven Rostedt
2008-11-17 19:09 ` Steven Rostedt [this message]
2008-11-17 19:09 ` [PATCH 3/4] ftrace,ppc: fix module check in dynamic ftrace code Steven Rostedt
2008-11-17 19:09 ` [PATCH 4/4] ftrace,ppc: fix test of branch link Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081117191059.408002035@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=fweisbec@gmail.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=pq@iki.fi \
--cc=rusty@rustcorp.com.au \
--cc=srostedt@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox