Re: [PATCH v2] ftrace/x86: Remove jumps to ftrace_epilogue and simplify trampolines

From: Steven Rostedt
Date: Tue Jul 19 2022 - 15:19:34 EST


On Tue, 19 Jul 2022 10:32:01 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
> index 5b4efc927d80..7225ccca94b9 100644
> --- a/arch/x86/kernel/ftrace.c
> +++ b/arch/x86/kernel/ftrace.c
> @@ -301,8 +301,6 @@ union ftrace_op_code_union {
> } __attribute__((packed));
> };
>
> -#define RET_SIZE 1 + IS_ENABLED(CONFIG_SLS)
> -
> static unsigned long
> create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
> {
> @@ -319,7 +317,6 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
> void *ip;
> /* 48 8b 15 <offset> is movq <offset>(%rip), %rdx */
> unsigned const char op_ref[] = { 0x48, 0x8b, 0x15 };
> - unsigned const char retq[] = { RET_INSN_OPCODE, INT3_INSN_OPCODE };
> union ftrace_op_code_union op_ptr;
> int ret;
>
> @@ -341,14 +338,14 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
>
> /*
> * Allocate enough size to store the ftrace_caller code,
> - * the iret , as well as the address of the ftrace_ops this
> - * trampoline is used for.
> + * as well as the address of the ftrace_ops this trampoline
> + * is used for.
> */
> - trampoline = alloc_tramp(size + RET_SIZE + sizeof(void *));
> + trampoline = alloc_tramp(size + sizeof(void *));
> if (!trampoline)
> return 0;
>

Bah, I didn't realize that Linus already applied the retbleed patches. The
above conflicts.

I'll rebase it and send out a v3.

-- Steve