Re: [PATCH bpf] bpf, x64: implement retpoline for tail call

2018-02-22 Thread Daniel Borkmann
On 02/22/2018 04:53 AM, Eric Dumazet wrote: > On Wed, 2018-02-21 at 19:43 -0800, Alexei Starovoitov wrote: >> On Wed, Feb 21, 2018 at 07:04:02PM -0800, Eric Dumazet wrote: >>> On Thu, 2018-02-22 at 01:05 +0100, Daniel Borkmann wrote: >>> >>> ... >>> +/* Instead of plain jmp %rax, we emit a ret

Re: [PATCH bpf] bpf, x64: implement retpoline for tail call

2018-02-21 Thread Alexei Starovoitov
On Wed, Feb 21, 2018 at 07:53:22PM -0800, Eric Dumazet wrote: > > So what kinda comment there would make sense? > > I was thinking of something very explicit : > > /* byte sequence for following assembly code used by eBPF >call ... >... >retq > */ > #define RETPOLINE_RAX_DIRECT_FOR_EB

Re: [PATCH bpf] bpf, x64: implement retpoline for tail call

2018-02-21 Thread Eric Dumazet
On Wed, 2018-02-21 at 19:43 -0800, Alexei Starovoitov wrote: > On Wed, Feb 21, 2018 at 07:04:02PM -0800, Eric Dumazet wrote: > > On Thu, 2018-02-22 at 01:05 +0100, Daniel Borkmann wrote: > > > > ... > > > > > +/* Instead of plain jmp %rax, we emit a retpoline to control > > > + * speculative exec

Re: [PATCH bpf] bpf, x64: implement retpoline for tail call

2018-02-21 Thread Alexei Starovoitov
On Wed, Feb 21, 2018 at 07:04:02PM -0800, Eric Dumazet wrote: > On Thu, 2018-02-22 at 01:05 +0100, Daniel Borkmann wrote: > > ... > > > +/* Instead of plain jmp %rax, we emit a retpoline to control > > + * speculative execution for the indirect branch. > > + */ > > +static void emit_retpoline_rax

Re: [PATCH bpf] bpf, x64: implement retpoline for tail call

2018-02-21 Thread Eric Dumazet
On Thu, 2018-02-22 at 01:05 +0100, Daniel Borkmann wrote: ... > +/* Instead of plain jmp %rax, we emit a retpoline to control > + * speculative execution for the indirect branch. > + */ > +static void emit_retpoline_rax_trampoline(u8 **pprog) > +{ > + u8 *prog = *pprog; > + int cnt = 0; >

[PATCH bpf] bpf, x64: implement retpoline for tail call

2018-02-21 Thread Daniel Borkmann
Implement a retpoline [0] for the BPF tail call JIT'ing that converts the indirect jump via jmp %rax that is used to make the long jump into another JITed BPF image. Since this is subject to speculative execution, we need to control the transient instruction sequence here as well when CONFIG_RETPOL