On Thu, Feb 06, 2025 at 12:12:42PM +0900, Masami Hiramatsu (Google) wrote:

> +#ifdef CONFIG_HAVE_FENTRY
> +/* Convert fentry address to the symbol address. */
> +unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)
> +{
> +#ifdef CONFIG_X86_KERNEL_IBT
> +     u32 instr;
> +
> +     /* We want to be extra safe in case entry ip is on the page edge,
> +      * but otherwise we need to avoid get_kernel_nofault()'s overhead.
> +      */
> +     if ((fentry_ip & ~PAGE_MASK) < ENDBR_INSN_SIZE) {
> +             if (get_kernel_nofault(instr, (u32 *)(fentry_ip - 
> ENDBR_INSN_SIZE)))
> +                     return fentry_ip;
> +     } else {
> +             instr = *(u32 *)(fentry_ip - ENDBR_INSN_SIZE);
> +     }
> +     if (is_endbr(instr))
> +             fentry_ip -= ENDBR_INSN_SIZE;
> +#endif
> +     return fentry_ip;
> +}
> +#endif

Urgh, that reminds, me. I have a pile of patches cleaning up this mess.
Let me go find them.

Reply via email to