Re: [RFC][PATCH] ftrace/x86: Emulate call function while updating in breakpoint handler

From: Linus Torvalds
Date: Tue Apr 30 2019 - 14:39:37 EST


On Tue, Apr 30, 2019 at 10:49 AM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> +
> +asm(
> + ".text\n"
> +
> + /* Trampoline for function update with interrupts enabled */
> + ".global ftrace_emulate_call_irqoff\n"
> + ".type ftrace_emulate_call_irqoff, @function\n"
> + "ftrace_emulate_call_irqoff:\n\t"
> + "push %gs:ftrace_bp_call_return\n\t"

Well, as mentioned in my original suggestion, this won't work on
32-bit, or on UP. They have different models for per-cpu data (32-bti
uses %fs, and UP doesn't use a segment override at all).

Maybe we just don't care about UP at all for this code, of course.

And maybe we can make the decision to also make 32-bit just not use
this either - so maybe the code is ok per se, just needs to make sure
it never triggers for the cases that it's not written for..

> + "ftrace_emulate_call_update_irqoff:\n\t"
> + "push %gs:ftrace_bp_call_return\n\t"
> + "sti\n\t"
> + "jmp *ftrace_update_func_call\n"

.. and this should then use the "push push sti ret" model instead.

Plus get updated for objtool complaints.

Anyway, since Andy really likes the entry code change, can we have
that patch in parallel and judge the difference that way? Iirc, that
was x86-64 specific too.

Linus