Messages in this thread | | | Date | Wed, 25 Mar 2020 19:13:39 +0100 | From | Peter Zijlstra <> | Subject | Re: [RESEND][PATCH v3 14/17] static_call: Add static_cond_call() |
| |
On Tue, Mar 24, 2020 at 06:03:06PM +0100, Peter Zijlstra wrote: > On Tue, Mar 24, 2020 at 09:33:21AM -0700, Linus Torvalds wrote:
> > Of course, one alternative is to just say "instead of using NOP, use > > 'xorl %eax,%eax'", and then we'd have the rule that a NULL conditional > > function returns zero (or NULL). > > > > I _think_ a "xorl %eax,%eax ; retq" is just three bytes and would fit > > in the tailcall slot too. > > Correct. The only problem is that our text patching machinery can't > replace multiple instructions :/
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.
Now, there are ways to fix this, the easiest being calling synchronize_rcu_tasks() just like optprobes does (see also commit 5c02ece81848 ("x86/kprobes: Fix ordering while text-patching")).
It would mean patching a call away from NULL will be 'expensive' but it ought to work.
I'll try and do the patch, see what it looks like.
| |