On Sun, 4 Jan 2026 22:34:15 +0900
Masami Hiramatsu (Google) <[email protected]> wrote:
> > This looks a bit grotty to me and presumably other architectures would
> > need similar treatement. Wouldn't it be cleaner to reuse the existing
> > API instead? For example, by calling ftrace_regs_set_instruction_pointer()
> > and ftrace_regs_set_return_value() to update the relevant registers from
> > the core code?
>
> I agreed with using the generic APIs. Also, ftrace_partial_regs_fix() is
> not self-explained. Maybe ftrace_regs_set_by_regs()?
Or perhaps: ftrace_partial_regs_update() where you call it if you need to
update the regs.
/*
* ftrace_partial_regs_update - update the original ftrace_regs from regs
* @fregs: The ftrace_regs to update from @regs
* @regs: The partial regs from ftrace_partial_regs() that was updated
*
* Some architectures have the partial regs living in the ftrace_regs
* structure, whereas other architectures need to make a different copy
* of the @regs. If a partial @regs is retrieved by ftrace_partial_regs() and
* if the code using @regs updates a field (like the instruction pointer or
* stack pointer) it may need to propagate that change to the original @fregs
* it retrieved the partial @regs from. Use this function to guarantee that
* update happens.
*/
static __always_inline void
ftrace_partial_regs_update(const struct ftrace_regs *fregs, struct pt_regs
*regs) {
struct __arch_ftrace_regs *afregs = arch_ftrace_regs(fregs);
if (afregs->pc != regs->pc) {
afregs->pc = regs->pc;
afregs->regs[0] = regs->regs[0];
}
}
-- Steve