@@ -114,7 +114,6 @@ static unsigned long find_bl_target(unsigned long ip, ppc_inst_t op)
114
114
}
115
115
116
116
#ifdef CONFIG_MODULES
117
- #ifdef CONFIG_PPC64
118
117
static int
119
118
__ftrace_make_nop (struct module * mod ,
120
119
struct dyn_ftrace * rec , unsigned long addr )
@@ -154,10 +153,11 @@ __ftrace_make_nop(struct module *mod,
154
153
return - EINVAL ;
155
154
}
156
155
157
- #ifdef CONFIG_MPROFILE_KERNEL
158
- /* When using -mkernel_profile there is no load to jump over */
156
+ /* When using -mprofile-kernel or PPC32 there is no load to jump over */
159
157
pop = ppc_inst (PPC_RAW_NOP ());
160
158
159
+ #ifdef CONFIG_PPC64
160
+ #ifdef CONFIG_MPROFILE_KERNEL
161
161
if (copy_inst_from_kernel_nofault (& op , (void * )(ip - 4 ))) {
162
162
pr_err ("Fetching instruction at %lx failed.\n" , ip - 4 );
163
163
return - EFAULT ;
@@ -201,6 +201,7 @@ __ftrace_make_nop(struct module *mod,
201
201
return - EINVAL ;
202
202
}
203
203
#endif /* CONFIG_MPROFILE_KERNEL */
204
+ #endif /* PPC64 */
204
205
205
206
if (patch_instruction ((u32 * )ip , pop )) {
206
207
pr_err ("Patching NOP failed.\n" );
@@ -209,48 +210,6 @@ __ftrace_make_nop(struct module *mod,
209
210
210
211
return 0 ;
211
212
}
212
-
213
- #else /* !PPC64 */
214
- static int
215
- __ftrace_make_nop (struct module * mod ,
216
- struct dyn_ftrace * rec , unsigned long addr )
217
- {
218
- ppc_inst_t op ;
219
- unsigned long ip = rec -> ip ;
220
- unsigned long tramp , ptr ;
221
-
222
- if (copy_from_kernel_nofault (& op , (void * )ip , MCOUNT_INSN_SIZE ))
223
- return - EFAULT ;
224
-
225
- /* Make sure that that this is still a 24bit jump */
226
- if (!is_bl_op (op )) {
227
- pr_err ("Not expected bl: opcode is %s\n" , ppc_inst_as_str (op ));
228
- return - EINVAL ;
229
- }
230
-
231
- /* lets find where the pointer goes */
232
- tramp = find_bl_target (ip , op );
233
-
234
- /* Find where the trampoline jumps to */
235
- if (module_trampoline_target (mod , tramp , & ptr )) {
236
- pr_err ("Failed to get trampoline target\n" );
237
- return - EFAULT ;
238
- }
239
-
240
- if (ptr != addr ) {
241
- pr_err ("Trampoline location %08lx does not match addr\n" ,
242
- tramp );
243
- return - EINVAL ;
244
- }
245
-
246
- op = ppc_inst (PPC_RAW_NOP ());
247
-
248
- if (patch_instruction ((u32 * )ip , op ))
249
- return - EPERM ;
250
-
251
- return 0 ;
252
- }
253
- #endif /* PPC64 */
254
213
#endif /* CONFIG_MODULES */
255
214
256
215
static unsigned long find_ftrace_tramp (unsigned long ip )
@@ -437,13 +396,12 @@ int ftrace_make_nop(struct module *mod,
437
396
}
438
397
439
398
#ifdef CONFIG_MODULES
440
- #ifdef CONFIG_PPC64
441
399
/*
442
400
* Examine the existing instructions for __ftrace_make_call.
443
401
* They should effectively be a NOP, and follow formal constraints,
444
402
* depending on the ABI. Return false if they don't.
445
403
*/
446
- #ifndef CONFIG_MPROFILE_KERNEL
404
+ #ifdef CONFIG_PPC64_ELF_ABI_V1
447
405
static int
448
406
expected_nop_sequence (void * ip , ppc_inst_t op0 , ppc_inst_t op1 )
449
407
{
@@ -465,7 +423,7 @@ expected_nop_sequence(void *ip, ppc_inst_t op0, ppc_inst_t op1)
465
423
static int
466
424
expected_nop_sequence (void * ip , ppc_inst_t op0 , ppc_inst_t op1 )
467
425
{
468
- /* look for patched "NOP" on ppc64 with -mprofile-kernel */
426
+ /* look for patched "NOP" on ppc64 with -mprofile-kernel or ppc32 */
469
427
if (!ppc_inst_equal (op0 , ppc_inst (PPC_RAW_NOP ())))
470
428
return 0 ;
471
429
return 1 ;
@@ -484,8 +442,10 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
484
442
if (copy_inst_from_kernel_nofault (op , ip ))
485
443
return - EFAULT ;
486
444
445
+ #ifdef CONFIG_PPC64_ELF_ABI_V1
487
446
if (copy_inst_from_kernel_nofault (op + 1 , ip + 4 ))
488
447
return - EFAULT ;
448
+ #endif
489
449
490
450
if (!expected_nop_sequence (ip , op [0 ], op [1 ])) {
491
451
pr_err ("Unexpected call sequence at %p: %s %s\n" ,
@@ -531,58 +491,6 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
531
491
532
492
return 0 ;
533
493
}
534
-
535
- #else /* !CONFIG_PPC64: */
536
- static int
537
- __ftrace_make_call (struct dyn_ftrace * rec , unsigned long addr )
538
- {
539
- int err ;
540
- ppc_inst_t op ;
541
- u32 * ip = (u32 * )rec -> ip ;
542
- struct module * mod = rec -> arch .mod ;
543
- unsigned long tramp ;
544
-
545
- /* read where this goes */
546
- if (copy_inst_from_kernel_nofault (& op , ip ))
547
- return - EFAULT ;
548
-
549
- /* It should be pointing to a nop */
550
- if (!ppc_inst_equal (op , ppc_inst (PPC_RAW_NOP ()))) {
551
- pr_err ("Expected NOP but have %s\n" , ppc_inst_as_str (op ));
552
- return - EINVAL ;
553
- }
554
-
555
- /* If we never set up a trampoline to ftrace_caller, then bail */
556
- #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
557
- if (!mod -> arch .tramp || !mod -> arch .tramp_regs ) {
558
- #else
559
- if (!mod -> arch .tramp ) {
560
- #endif
561
- pr_err ("No ftrace trampoline\n" );
562
- return - EINVAL ;
563
- }
564
-
565
- #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
566
- if (rec -> flags & FTRACE_FL_REGS )
567
- tramp = mod -> arch .tramp_regs ;
568
- else
569
- #endif
570
- tramp = mod -> arch .tramp ;
571
- /* create the branch to the trampoline */
572
- err = create_branch (& op , ip , tramp , BRANCH_SET_LINK );
573
- if (err ) {
574
- pr_err ("REL24 out of range!\n" );
575
- return - EINVAL ;
576
- }
577
-
578
- pr_devel ("write to %lx\n" , rec -> ip );
579
-
580
- if (patch_instruction (ip , op ))
581
- return - EPERM ;
582
-
583
- return 0 ;
584
- }
585
- #endif /* CONFIG_PPC64 */
586
494
#endif /* CONFIG_MODULES */
587
495
588
496
static int __ftrace_make_call_kernel (struct dyn_ftrace * rec , unsigned long addr )
0 commit comments