On Fri, 10 May 2019 14:31:31 +0200 Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote: > On Fri, May 10, 2019 at 01:58:31PM +0900, Masami Hiramatsu wrote: > > On Thu, 9 May 2019 19:14:16 +0200 > > Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote: > > > > Ideally also the optimized kprobe trampoline, but I've not managed to > > > fully comprehend that one. > > > > As you pointed in other reply, save/restore can be a macro, but > > each trampoline code is slightly different. Optprobe template has > > below parts > > > > (jumped from probed address) > > [store regs] > > [setup function arguments (pt_regs and probed address)] > > [handler call] > > [restore regs] > > [execute copied instruction] > > instruction_s_ ? Yes. > > The JMP to this trampoline is likely 5 bytes and could have clobbered > multiple instructions, we'd then have to place them all here, and > > > [jump back to probed address] > > jump to after whatever instructions were clobbered by the JMP. Right! > > Note that there is a limitation that if it is optiomized probe, user > > handler can not change regs->ip. (we can not use "ret" after executed > > a copied instruction, which must run on same stack) > > Changing regs->ip in this case is going to be massively dodgy indeed :-) > But so would changing much else; changing stack layout would also be > somewhat tricky. Yes, so the stack must be same after [restore regs]. Thank you, -- Masami Hiramatsu <mhiramat@xxxxxxxxxx>