diff options
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r-- | arch/powerpc/kernel/entry_32.S | 4 | ||||
-rw-r--r-- | arch/powerpc/kernel/entry_64.S | 5 | ||||
-rw-r--r-- | arch/powerpc/kernel/ftrace.c | 21 |
3 files changed, 15 insertions, 15 deletions
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 3b1dd29d9f91..7231a708af0d 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <asm/ppc_asm.h> | 30 | #include <asm/ppc_asm.h> |
31 | #include <asm/asm-offsets.h> | 31 | #include <asm/asm-offsets.h> |
32 | #include <asm/unistd.h> | 32 | #include <asm/unistd.h> |
33 | #include <asm/ftrace.h> | ||
33 | 34 | ||
34 | #undef SHOW_SYSCALLS | 35 | #undef SHOW_SYSCALLS |
35 | #undef SHOW_SYSCALLS_TASK | 36 | #undef SHOW_SYSCALLS_TASK |
@@ -1053,6 +1054,7 @@ _GLOBAL(_mcount) | |||
1053 | stw r10,40(r1) | 1054 | stw r10,40(r1) |
1054 | stw r3, 44(r1) | 1055 | stw r3, 44(r1) |
1055 | stw r5, 8(r1) | 1056 | stw r5, 8(r1) |
1057 | subi r3, r3, MCOUNT_INSN_SIZE | ||
1056 | .globl mcount_call | 1058 | .globl mcount_call |
1057 | mcount_call: | 1059 | mcount_call: |
1058 | bl ftrace_stub | 1060 | bl ftrace_stub |
@@ -1090,6 +1092,7 @@ _GLOBAL(ftrace_caller) | |||
1090 | stw r10,40(r1) | 1092 | stw r10,40(r1) |
1091 | stw r3, 44(r1) | 1093 | stw r3, 44(r1) |
1092 | stw r5, 8(r1) | 1094 | stw r5, 8(r1) |
1095 | subi r3, r3, MCOUNT_INSN_SIZE | ||
1093 | .globl ftrace_call | 1096 | .globl ftrace_call |
1094 | ftrace_call: | 1097 | ftrace_call: |
1095 | bl ftrace_stub | 1098 | bl ftrace_stub |
@@ -1128,6 +1131,7 @@ _GLOBAL(_mcount) | |||
1128 | stw r3, 44(r1) | 1131 | stw r3, 44(r1) |
1129 | stw r5, 8(r1) | 1132 | stw r5, 8(r1) |
1130 | 1133 | ||
1134 | subi r3, r3, MCOUNT_INSN_SIZE | ||
1131 | LOAD_REG_ADDR(r5, ftrace_trace_function) | 1135 | LOAD_REG_ADDR(r5, ftrace_trace_function) |
1132 | lwz r5,0(r5) | 1136 | lwz r5,0(r5) |
1133 | 1137 | ||
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 2c4d9e056ead..2f511a969d2c 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <asm/bug.h> | 31 | #include <asm/bug.h> |
32 | #include <asm/ptrace.h> | 32 | #include <asm/ptrace.h> |
33 | #include <asm/irqflags.h> | 33 | #include <asm/irqflags.h> |
34 | #include <asm/ftrace.h> | ||
34 | 35 | ||
35 | /* | 36 | /* |
36 | * System calls. | 37 | * System calls. |
@@ -879,6 +880,7 @@ _GLOBAL(_mcount) | |||
879 | mflr r3 | 880 | mflr r3 |
880 | stdu r1, -112(r1) | 881 | stdu r1, -112(r1) |
881 | std r3, 128(r1) | 882 | std r3, 128(r1) |
883 | subi r3, r3, MCOUNT_INSN_SIZE | ||
882 | .globl mcount_call | 884 | .globl mcount_call |
883 | mcount_call: | 885 | mcount_call: |
884 | bl ftrace_stub | 886 | bl ftrace_stub |
@@ -895,6 +897,7 @@ _GLOBAL(ftrace_caller) | |||
895 | stdu r1, -112(r1) | 897 | stdu r1, -112(r1) |
896 | std r3, 128(r1) | 898 | std r3, 128(r1) |
897 | ld r4, 16(r11) | 899 | ld r4, 16(r11) |
900 | subi r3, r3, MCOUNT_INSN_SIZE | ||
898 | .globl ftrace_call | 901 | .globl ftrace_call |
899 | ftrace_call: | 902 | ftrace_call: |
900 | bl ftrace_stub | 903 | bl ftrace_stub |
@@ -916,7 +919,7 @@ _GLOBAL(_mcount) | |||
916 | std r3, 128(r1) | 919 | std r3, 128(r1) |
917 | ld r4, 16(r11) | 920 | ld r4, 16(r11) |
918 | 921 | ||
919 | 922 | subi r3, r3, MCOUNT_INSN_SIZE | |
920 | LOAD_REG_ADDR(r5,ftrace_trace_function) | 923 | LOAD_REG_ADDR(r5,ftrace_trace_function) |
921 | ld r5,0(r5) | 924 | ld r5,0(r5) |
922 | ld r5,0(r5) | 925 | ld r5,0(r5) |
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c index e12c593ab9ca..3855ceb937b0 100644 --- a/arch/powerpc/kernel/ftrace.c +++ b/arch/powerpc/kernel/ftrace.c | |||
@@ -15,8 +15,8 @@ | |||
15 | #include <linux/list.h> | 15 | #include <linux/list.h> |
16 | 16 | ||
17 | #include <asm/cacheflush.h> | 17 | #include <asm/cacheflush.h> |
18 | #include <asm/ftrace.h> | ||
18 | 19 | ||
19 | #define CALL_BACK 4 | ||
20 | 20 | ||
21 | static unsigned int ftrace_nop = 0x60000000; | 21 | static unsigned int ftrace_nop = 0x60000000; |
22 | 22 | ||
@@ -27,9 +27,10 @@ static unsigned int ftrace_nop = 0x60000000; | |||
27 | # define GET_ADDR(addr) *(unsigned long *)addr | 27 | # define GET_ADDR(addr) *(unsigned long *)addr |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | |||
30 | static unsigned int notrace ftrace_calc_offset(long ip, long addr) | 31 | static unsigned int notrace ftrace_calc_offset(long ip, long addr) |
31 | { | 32 | { |
32 | return (int)((addr + CALL_BACK) - ip); | 33 | return (int)(addr - ip); |
33 | } | 34 | } |
34 | 35 | ||
35 | notrace unsigned char *ftrace_nop_replace(void) | 36 | notrace unsigned char *ftrace_nop_replace(void) |
@@ -76,9 +77,6 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code, | |||
76 | unsigned new = *(unsigned *)new_code; | 77 | unsigned new = *(unsigned *)new_code; |
77 | int faulted = 0; | 78 | int faulted = 0; |
78 | 79 | ||
79 | /* move the IP back to the start of the call */ | ||
80 | ip -= CALL_BACK; | ||
81 | |||
82 | /* | 80 | /* |
83 | * Note: Due to modules and __init, code can | 81 | * Note: Due to modules and __init, code can |
84 | * disappear and change, we need to protect against faulting | 82 | * disappear and change, we need to protect against faulting |
@@ -118,12 +116,10 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code, | |||
118 | notrace int ftrace_update_ftrace_func(ftrace_func_t func) | 116 | notrace int ftrace_update_ftrace_func(ftrace_func_t func) |
119 | { | 117 | { |
120 | unsigned long ip = (unsigned long)(&ftrace_call); | 118 | unsigned long ip = (unsigned long)(&ftrace_call); |
121 | unsigned char old[4], *new; | 119 | unsigned char old[MCOUNT_INSN_SIZE], *new; |
122 | int ret; | 120 | int ret; |
123 | 121 | ||
124 | ip += CALL_BACK; | 122 | memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE); |
125 | |||
126 | memcpy(old, &ftrace_call, 4); | ||
127 | new = ftrace_call_replace(ip, (unsigned long)func); | 123 | new = ftrace_call_replace(ip, (unsigned long)func); |
128 | ret = ftrace_modify_code(ip, old, new); | 124 | ret = ftrace_modify_code(ip, old, new); |
129 | 125 | ||
@@ -134,16 +130,13 @@ notrace int ftrace_mcount_set(unsigned long *data) | |||
134 | { | 130 | { |
135 | unsigned long ip = (long)(&mcount_call); | 131 | unsigned long ip = (long)(&mcount_call); |
136 | unsigned long *addr = data; | 132 | unsigned long *addr = data; |
137 | unsigned char old[4], *new; | 133 | unsigned char old[MCOUNT_INSN_SIZE], *new; |
138 | |||
139 | /* ip is at the location, but modify code will subtact this */ | ||
140 | ip += CALL_BACK; | ||
141 | 134 | ||
142 | /* | 135 | /* |
143 | * Replace the mcount stub with a pointer to the | 136 | * Replace the mcount stub with a pointer to the |
144 | * ip recorder function. | 137 | * ip recorder function. |
145 | */ | 138 | */ |
146 | memcpy(old, &mcount_call, 4); | 139 | memcpy(old, &mcount_call, MCOUNT_INSN_SIZE); |
147 | new = ftrace_call_replace(ip, *addr); | 140 | new = ftrace_call_replace(ip, *addr); |
148 | *addr = ftrace_modify_code(ip, old, new); | 141 | *addr = ftrace_modify_code(ip, old, new); |
149 | 142 | ||