• Florent Revest's avatar
    arm64: ftrace: Add direct call support · 2aa6ac03
    Florent Revest authored
    This builds up on the CALL_OPS work which extends the ftrace patchsite
    on arm64 with an ops pointer usable by the ftrace trampoline.
    
    This ops pointer is valid at all time. Indeed, it is either pointing to
    ftrace_list_ops or to the single ops which should be called from that
    patchsite.
    
    There are a few cases to distinguish:
    - If a direct call ops is the only one tracing a function:
      - If the direct called trampoline is within the reach of a BL
        instruction
         -> the ftrace patchsite jumps to the trampoline
      - Else
         -> the ftrace patchsite jumps to the ftrace_caller trampoline which
            reads the ops pointer in the patchsite and jumps to the direct
            call address stored in the ops
    - Else
      -> the ftrace patchsite jumps to the ftrace_caller trampoline and its
         ops literal points to ftrace_list_ops so it iterates over all
         registered ftrace ops, including the direct call ops and calls its
         call_direct_funcs handler which stores the direct called
         trampoline's address in the ftrace_regs and the ftrace_caller
         trampoline will return to that address instead of returning to the
         traced function
    Signed-off-by: default avatarFlorent Revest <revest@chromium.org>
    Co-developed-by: default avatarMark Rutland <mark.rutland@arm.com>
    Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
    Link: https://lore.kernel.org/r/20230405180250.2046566-2-revest@chromium.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
    2aa6ac03
Kconfig 79.1 KB