Lines Matching refs:rec
132 static unsigned long ftrace_get_ool_stub(struct dyn_ftrace *rec) in ftrace_get_ool_stub() argument
135 return rec->arch.ool_stub; in ftrace_get_ool_stub()
141 static int ftrace_get_call_inst(struct dyn_ftrace *rec, unsigned long addr, ppc_inst_t *call_inst) in ftrace_get_call_inst() argument
147 ip = ftrace_get_ool_stub(rec) + MCOUNT_INSN_SIZE; /* second instruction in stub */ in ftrace_get_call_inst()
149 ip = rec->ip; in ftrace_get_call_inst()
156 ip, rec->ip, addr); in ftrace_get_call_inst()
172 pr_err("0x%lx (0x%lx): No ftrace stubs reachable\n", ip, rec->ip); in ftrace_get_call_inst()
180 static int ftrace_init_ool_stub(struct module *mod, struct dyn_ftrace *rec) in ftrace_init_ool_stub() argument
199 WARN_ON(rec->arch.ool_stub); in ftrace_init_ool_stub()
201 if (is_kernel_inittext(rec->ip)) { in ftrace_init_ool_stub()
205 } else if (is_kernel_text(rec->ip)) { in ftrace_init_ool_stub()
212 !is_offset_in_branch_range((long)rec->ip - in ftrace_init_ool_stub()
237 if (!is_offset_in_branch_range((long)rec->ip - (long)&ool_stub->insn[0]) || in ftrace_init_ool_stub()
238 !is_offset_in_branch_range((long)(rec->ip + MCOUNT_INSN_SIZE) - in ftrace_init_ool_stub()
241 __func__, (void *)rec->ip, (void *)&ool_stub->insn[0]); in ftrace_init_ool_stub()
245 rec->arch.ool_stub = (unsigned long)&ool_stub->insn[0]; in ftrace_init_ool_stub()
249 ret = ftrace_get_call_inst(rec, (unsigned long)ftrace_caller, &inst); in ftrace_init_ool_stub()
259 inst = ftrace_create_branch_inst(ftrace_get_ool_stub(rec) + MCOUNT_INSN_SIZE, in ftrace_init_ool_stub()
265 if (!ret && create_branch(&inst, &ool_stub->insn[3], rec->ip + MCOUNT_INSN_SIZE, 0)) in ftrace_init_ool_stub()
280 static const struct ftrace_ops *powerpc_rec_get_ops(struct dyn_ftrace *rec) in powerpc_rec_get_ops() argument
284 if (rec->flags & FTRACE_FL_CALL_OPS_EN) { in powerpc_rec_get_ops()
285 ops = ftrace_find_unique_ops(rec); in powerpc_rec_get_ops()
295 static int ftrace_rec_set_ops(struct dyn_ftrace *rec, const struct ftrace_ops *ops) in ftrace_rec_set_ops() argument
298 return patch_ulong((void *)(ftrace_get_ool_stub(rec) - sizeof(unsigned long)), in ftrace_rec_set_ops()
301 return patch_ulong((void *)(rec->ip - MCOUNT_INSN_SIZE - sizeof(unsigned long)), in ftrace_rec_set_ops()
305 static int ftrace_rec_set_nop_ops(struct dyn_ftrace *rec) in ftrace_rec_set_nop_ops() argument
307 return ftrace_rec_set_ops(rec, &ftrace_nop_ops); in ftrace_rec_set_nop_ops()
310 static int ftrace_rec_update_ops(struct dyn_ftrace *rec) in ftrace_rec_update_ops() argument
312 return ftrace_rec_set_ops(rec, powerpc_rec_get_ops(rec)); in ftrace_rec_update_ops()
315 static int ftrace_rec_set_nop_ops(struct dyn_ftrace *rec) { return 0; } in ftrace_rec_set_nop_ops() argument
316 static int ftrace_rec_update_ops(struct dyn_ftrace *rec) { return 0; } in ftrace_rec_update_ops() argument
320 int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, unsigned long addr) in ftrace_modify_call() argument
328 int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) in ftrace_make_call() argument
331 unsigned long ip = rec->ip; in ftrace_make_call()
340 ip = ftrace_get_ool_stub(rec) + MCOUNT_INSN_SIZE; /* second instruction in stub */ in ftrace_make_call()
341 ret = ftrace_get_call_inst(rec, (unsigned long)ftrace_caller, &old); in ftrace_make_call()
344 ret |= ftrace_get_call_inst(rec, addr, &new); in ftrace_make_call()
349 ret = ftrace_rec_update_ops(rec); in ftrace_make_call()
354 ret = ftrace_modify_code(rec->ip, ppc_inst(PPC_RAW_NOP()), in ftrace_make_call()
355 ppc_inst(PPC_RAW_BRANCH((long)ftrace_get_ool_stub(rec) - (long)rec->ip))); in ftrace_make_call()
360 int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, unsigned long addr) in ftrace_make_nop() argument
376 struct dyn_ftrace *rec; in ftrace_replace_code() local
380 rec = ftrace_rec_iter_record(iter); in ftrace_replace_code()
381 ip = rec->ip; in ftrace_replace_code()
383 if (rec->flags & FTRACE_FL_DISABLED && !(rec->flags & FTRACE_FL_ENABLED)) in ftrace_replace_code()
386 addr = ftrace_get_addr_curr(rec); in ftrace_replace_code()
387 new_addr = ftrace_get_addr_new(rec); in ftrace_replace_code()
388 update = ftrace_update_record(rec, enable); in ftrace_replace_code()
391 ip = ftrace_get_ool_stub(rec) + MCOUNT_INSN_SIZE; in ftrace_replace_code()
392 ret = ftrace_get_call_inst(rec, (unsigned long)ftrace_caller, &nop_inst); in ftrace_replace_code()
402 ret = ftrace_get_call_inst(rec, new_addr, &new_call_inst); in ftrace_replace_code()
403 ret |= ftrace_get_call_inst(rec, addr, &call_inst); in ftrace_replace_code()
404 ret |= ftrace_rec_update_ops(rec); in ftrace_replace_code()
409 ret = ftrace_get_call_inst(rec, addr, &call_inst); in ftrace_replace_code()
410 ret |= ftrace_rec_set_nop_ops(rec); in ftrace_replace_code()
415 ret = ftrace_get_call_inst(rec, new_addr, &call_inst); in ftrace_replace_code()
416 ret |= ftrace_rec_update_ops(rec); in ftrace_replace_code()
428 call_inst = ppc_inst(PPC_RAW_BRANCH((long)ftrace_get_ool_stub(rec) - in ftrace_replace_code()
429 (long)rec->ip)); in ftrace_replace_code()
431 ip = rec->ip; in ftrace_replace_code()
448 ftrace_bug(ret, rec); in ftrace_replace_code()
452 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec) in ftrace_init_nop() argument
454 unsigned long addr, ip = rec->ip; in ftrace_init_nop()
492 ret = ftrace_init_ool_stub(mod, rec); in ftrace_init_nop()
527 ret = ftrace_rec_set_nop_ops(rec); in ftrace_init_nop()