@@ -222,9 +222,8 @@ __ftrace_make_nop(struct module *mod,
222
222
struct dyn_ftrace * rec , unsigned long addr )
223
223
{
224
224
struct ppc_inst op ;
225
- unsigned int jmp [4 ];
226
225
unsigned long ip = rec -> ip ;
227
- unsigned long tramp ;
226
+ unsigned long tramp , ptr ;
228
227
229
228
if (copy_from_kernel_nofault (& op , (void * )ip , MCOUNT_INSN_SIZE ))
230
229
return - EFAULT ;
@@ -238,41 +237,13 @@ __ftrace_make_nop(struct module *mod,
238
237
/* lets find where the pointer goes */
239
238
tramp = find_bl_target (ip , op );
240
239
241
- /*
242
- * On PPC32 the trampoline looks like:
243
- * 0x3d, 0x80, 0x00, 0x00 lis r12,sym@ha
244
- * 0x39, 0x8c, 0x00, 0x00 addi r12,r12,sym@l
245
- * 0x7d, 0x89, 0x03, 0xa6 mtctr r12
246
- * 0x4e, 0x80, 0x04, 0x20 bctr
247
- */
248
-
249
- pr_devel ("ip:%lx jumps to %lx" , ip , tramp );
250
-
251
240
/* Find where the trampoline jumps to */
252
- if (copy_from_kernel_nofault ( jmp , ( void * ) tramp , sizeof ( jmp ) )) {
253
- pr_err ("Failed to read %lx \n" , tramp );
241
+ if (module_trampoline_target ( mod , tramp , & ptr )) {
242
+ pr_err ("Failed to get trampoline target \n" );
254
243
return - EFAULT ;
255
244
}
256
245
257
- pr_devel (" %08x %08x " , jmp [0 ], jmp [1 ]);
258
-
259
- /* verify that this is what we expect it to be */
260
- if (((jmp [0 ] & 0xffff0000 ) != 0x3d800000 ) ||
261
- ((jmp [1 ] & 0xffff0000 ) != 0x398c0000 ) ||
262
- (jmp [2 ] != 0x7d8903a6 ) ||
263
- (jmp [3 ] != 0x4e800420 )) {
264
- pr_err ("Not a trampoline\n" );
265
- return - EINVAL ;
266
- }
267
-
268
- tramp = (jmp [1 ] & 0xffff ) |
269
- ((jmp [0 ] & 0xffff ) << 16 );
270
- if (tramp & 0x8000 )
271
- tramp -= 0x10000 ;
272
-
273
- pr_devel (" %lx " , tramp );
274
-
275
- if (tramp != addr ) {
246
+ if (ptr != addr ) {
276
247
pr_err ("Trampoline location %08lx does not match addr\n" ,
277
248
tramp );
278
249
return - EINVAL ;
0 commit comments