Re: [patch 36/38] x86/ftrace: Make it call depth tracking aware

From: Steven Rostedt
Date: Mon Jul 18 2022 - 17:01:33 EST


On Sun, 17 Jul 2022 01:18:08 +0200 (CEST)
Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:

> @@ -280,7 +291,19 @@ SYM_INNER_LABEL(ftrace_regs_caller_end,
> /* Restore flags */
> popfq
> UNWIND_HINT_FUNC
> - jmp ftrace_epilogue
> +
> + /*
> + * Since we're effectively emulating a tail-call with PUSH;RET
> + * make sure we don't unbalance the RSB and mess up accounting.
> + */
> + ANNOTATE_INTRA_FUNCTION_CALL
> + call 2f
> + int3
> +2:
> + add $8, %rsp
> + ALTERNATIVE __stringify(RET), \
> + __stringify(ANNOTATE_UNRET_SAFE; ret; int3), \
> + X86_FEATURE_CALL_DEPTH
>
> SYM_FUNC_END(ftrace_regs_caller)

Would this code be simpler if we nuked the ftrace_epilogue altogether?

After commit 0c0593b45c9b ("x86/ftrace: Make function graph use ftrace
directly"), the ftrace_epilogue is no longer needed. That was there to make
sure all the trampolines would call the function graph tracer. But now that
function graph tracing is just another ftrace caller, it's not needed
anymore.

Something like the below. It booted and passed the ftrace kselftests.

Feel free to include this in your series.

-- Steve