lkml.org 
[lkml]   [2015]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH net-next 2/4] x86: bpf_jit: implement bpf_tail_call() helper
On Tue, May 19, 2015 at 4:59 PM, Alexei Starovoitov <ast@plumgrid.com> wrote:
> bpf_tail_call() arguments:
> ctx - context pointer
> jmp_table - one of BPF_MAP_TYPE_PROG_ARRAY maps used as the jump table
> index - index in the jump table
>
> In this implementation x64 JIT bypasses stack unwind and jumps into the
> callee program after prologue, so the callee program reuses the same stack.
>
> The logic can be roughly expressed in C like:
>
> u32 tail_call_cnt;
>
> void *jumptable[2] = { &&label1, &&label2 };
>
> int bpf_prog1(void *ctx)
> {
> label1:
> ...
> }
>
> int bpf_prog2(void *ctx)
> {
> label2:
> ...
> }
>
> int bpf_prog1(void *ctx)
> {
> ...
> if (tail_call_cnt++ < MAX_TAIL_CALL_CNT)
> goto *jumptable[index]; ... and pass my 'ctx' to callee ...
>
> ... fall through if no entry in jumptable ...
> }
>

What causes the stack pointer to be right? Is there some reason that
the stack pointer is the same no matter where you are in the generated
code?

--Andy


\
 
 \ /
  Last update: 2015-05-20 02:41    [W:0.086 / U:0.512 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site