Message ID | b091755f6053b4a3f66de9c168d4f73a751a5661.1560431531.git.jpoimboe@redhat.com |
---|---|
State | Changes Requested |
Delegated to: | BPF Maintainers |
Headers | show |
Series | x86/bpf: unwinder fixes | expand |
> On Jun 13, 2019, at 6:21 AM, Josh Poimboeuf <jpoimboe@redhat.com> wrote: > > Improve code readability by moving the BPF JIT function epilogue > generation code to a dedicated emit_epilogue() function, analagous to > the existing emit_prologue() function. > > Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> > --- > arch/x86/net/bpf_jit_comp.c | 37 ++++++++++++++++++++++++------------- > 1 file changed, 24 insertions(+), 13 deletions(-) > > diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c > index 32bfab4e21eb..da8c988b0f0f 100644 > --- a/arch/x86/net/bpf_jit_comp.c > +++ b/arch/x86/net/bpf_jit_comp.c > @@ -240,6 +240,28 @@ static void emit_prologue(u8 **pprog, u32 stack_depth, bool ebpf_from_cbpf) > *pprog = prog; > } > > +static void emit_epilogue(u8 **pprog) > +{ > + u8 *prog = *pprog; > + int cnt = 0; > + > + /* mov rbx, qword ptr [rbp+0] */ > + EMIT4(0x48, 0x8B, 0x5D, 0); > + /* mov r13, qword ptr [rbp+8] */ > + EMIT4(0x4C, 0x8B, 0x6D, 8); > + /* mov r14, qword ptr [rbp+16] */ > + EMIT4(0x4C, 0x8B, 0x75, 16); > + /* mov r15, qword ptr [rbp+24] */ > + EMIT4(0x4C, 0x8B, 0x7D, 24); Shall we update these comments to AT&T syntax? Thanks, Song > + > + /* add rbp, AUX_STACK_SPACE */ > + EMIT4(0x48, 0x83, 0xC5, AUX_STACK_SPACE); > + EMIT1(0xC9); /* leave */ > + EMIT1(0xC3); /* ret */ > + > + *pprog = prog; > +} > + > /* > * Generate the following code: > * > @@ -1036,19 +1058,8 @@ xadd: if (is_imm8(insn->off)) > seen_exit = true; > /* Update cleanup_addr */ > ctx->cleanup_addr = proglen; > - /* mov rbx, qword ptr [rbp+0] */ > - EMIT4(0x48, 0x8B, 0x5D, 0); > - /* mov r13, qword ptr [rbp+8] */ > - EMIT4(0x4C, 0x8B, 0x6D, 8); > - /* mov r14, qword ptr [rbp+16] */ > - EMIT4(0x4C, 0x8B, 0x75, 16); > - /* mov r15, qword ptr [rbp+24] */ > - EMIT4(0x4C, 0x8B, 0x7D, 24); > - > - /* add rbp, AUX_STACK_SPACE */ > - EMIT4(0x48, 0x83, 0xC5, AUX_STACK_SPACE); > - EMIT1(0xC9); /* leave */ > - EMIT1(0xC3); /* ret */ > + > + emit_epilogue(&prog); > break; > > default: > -- > 2.20.1 >
On Thu, Jun 13, 2019 at 06:57:10PM +0000, Song Liu wrote: > > > > On Jun 13, 2019, at 6:21 AM, Josh Poimboeuf <jpoimboe@redhat.com> wrote: > > > > Improve code readability by moving the BPF JIT function epilogue > > generation code to a dedicated emit_epilogue() function, analagous to > > the existing emit_prologue() function. > > > > Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> > > --- > > arch/x86/net/bpf_jit_comp.c | 37 ++++++++++++++++++++++++------------- > > 1 file changed, 24 insertions(+), 13 deletions(-) > > > > diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c > > index 32bfab4e21eb..da8c988b0f0f 100644 > > --- a/arch/x86/net/bpf_jit_comp.c > > +++ b/arch/x86/net/bpf_jit_comp.c > > @@ -240,6 +240,28 @@ static void emit_prologue(u8 **pprog, u32 stack_depth, bool ebpf_from_cbpf) > > *pprog = prog; > > } > > > > +static void emit_epilogue(u8 **pprog) > > +{ > > + u8 *prog = *pprog; > > + int cnt = 0; > > + > > + /* mov rbx, qword ptr [rbp+0] */ > > + EMIT4(0x48, 0x8B, 0x5D, 0); > > + /* mov r13, qword ptr [rbp+8] */ > > + EMIT4(0x4C, 0x8B, 0x6D, 8); > > + /* mov r14, qword ptr [rbp+16] */ > > + EMIT4(0x4C, 0x8B, 0x75, 16); > > + /* mov r15, qword ptr [rbp+24] */ > > + EMIT4(0x4C, 0x8B, 0x7D, 24); > > Shall we update these comments to AT&T syntax? Yes, but they're updated with all the others in patch 8.
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 32bfab4e21eb..da8c988b0f0f 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -240,6 +240,28 @@ static void emit_prologue(u8 **pprog, u32 stack_depth, bool ebpf_from_cbpf) *pprog = prog; } +static void emit_epilogue(u8 **pprog) +{ + u8 *prog = *pprog; + int cnt = 0; + + /* mov rbx, qword ptr [rbp+0] */ + EMIT4(0x48, 0x8B, 0x5D, 0); + /* mov r13, qword ptr [rbp+8] */ + EMIT4(0x4C, 0x8B, 0x6D, 8); + /* mov r14, qword ptr [rbp+16] */ + EMIT4(0x4C, 0x8B, 0x75, 16); + /* mov r15, qword ptr [rbp+24] */ + EMIT4(0x4C, 0x8B, 0x7D, 24); + + /* add rbp, AUX_STACK_SPACE */ + EMIT4(0x48, 0x83, 0xC5, AUX_STACK_SPACE); + EMIT1(0xC9); /* leave */ + EMIT1(0xC3); /* ret */ + + *pprog = prog; +} + /* * Generate the following code: * @@ -1036,19 +1058,8 @@ xadd: if (is_imm8(insn->off)) seen_exit = true; /* Update cleanup_addr */ ctx->cleanup_addr = proglen; - /* mov rbx, qword ptr [rbp+0] */ - EMIT4(0x48, 0x8B, 0x5D, 0); - /* mov r13, qword ptr [rbp+8] */ - EMIT4(0x4C, 0x8B, 0x6D, 8); - /* mov r14, qword ptr [rbp+16] */ - EMIT4(0x4C, 0x8B, 0x75, 16); - /* mov r15, qword ptr [rbp+24] */ - EMIT4(0x4C, 0x8B, 0x7D, 24); - - /* add rbp, AUX_STACK_SPACE */ - EMIT4(0x48, 0x83, 0xC5, AUX_STACK_SPACE); - EMIT1(0xC9); /* leave */ - EMIT1(0xC3); /* ret */ + + emit_epilogue(&prog); break; default:
Improve code readability by moving the BPF JIT function epilogue generation code to a dedicated emit_epilogue() function, analagous to the existing emit_prologue() function. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> --- arch/x86/net/bpf_jit_comp.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-)