Skip to content

Commit

Permalink
powerpc/ftrace: Fix math to calculate offset in TOC
Browse files Browse the repository at this point in the history
Impact: fix dynamic ftrace with large modules in PPC64

The math to calculate the offset into the TOC that is taken from reading
the trampoline is incorrect. The bottom half of the offset is a signed
extended short. The current code was using an OR to create the offset
when it should have been using an addition.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Acked-by: Geoff Levand <geoffrey.levand@am.sony.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Steven Rostedt authored and Benjamin Herrenschmidt committed Feb 10, 2009
1 parent eef3361 commit f25f907
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/powerpc/kernel/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ __ftrace_make_nop(struct module *mod,
return -EINVAL;
}

offset = (unsigned)((unsigned short)jmp[0]) << 16 |
(unsigned)((unsigned short)jmp[1]);
/* The bottom half is signed extended */
offset = ((unsigned)((unsigned short)jmp[0]) << 16) +
(int)((short)jmp[1]);

DEBUGP(" %x ", offset);

Expand Down

0 comments on commit f25f907

Please sign in to comment.