Re: [RESEND][PATCH v3 14/17] static_call: Add static_cond_call()

From: Linus Torvalds
Date: Wed Mar 25 2020 - 14:27:03 EST


On Wed, Mar 25, 2020 at 11:13 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> To clarify; the problem is a task getting preempted with its RIP at the
> RET. Then when we rewrite the text to be a CALL/JMP.d32 it will read
> garbage (1 byte into the displacement of the instruction) instead of a
> RET when it resumes.

Yeah, I realized it when you mentioned it. I was trying to come up
with some clever way to avoid it, but can't see anything.

I can come up with insane models - you could replace the xor;ret
sequence with a jump to a trampoline where you've aligned the target
trampoline so that the third byte in the "jmp xxx" remains a 'ret'
instruction. Then replace _that_ one with a "call_rcu()" callback.
Wild handwaving of "I'm sure this could be made to work".

But nothing remotely sane comes to mind.

Linus