Re: [PATCH 4/5 v3] ftrace/x86_32: Clean up ftrace_regs_caller

From: Linus Torvalds
Date: Thu Mar 16 2017 - 15:28:23 EST


On Thu, Mar 16, 2017 at 12:19 PM, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> The thing is we don't return, we jump to the location that may be
> modified to run the function graph tracer.

Hmm.

How about just making the stack frame a tiny bit bigger, and getting
rid of *all* the games.

IOW, just duplicate the return address, and make the entry code do

pushfl
pushl $__KERNEL_CS
pushl 8(%esp) /* Save the return ip *again* */
pushl $0
pushl %gs
pushl %fs
pushl %es
pushl %ds
pushl %eax
....

and not have any silly code to modify the old stack frame at all. Just
skip the values (all the segments, ORIG_EAX, duplicated return
address, __KERNEL_CS), and you can finish off with a "popf", and all
you have left i the original return ip that you didn't touch.

Hmm?

Linus