mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: X86 ML <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	Kairui Song <kasong@redhat.com>
Subject: Re: [PATCH 3/9] x86/bpf: Move epilogue generation to a dedicated function
Date: Thu, 13 Jun 2019 18:57:10 +0000	[thread overview]
Message-ID: <A753FBC1-3781-4A47-B0AD-A4300C552F7B@fb.com> (raw)
In-Reply-To: <b091755f6053b4a3f66de9c168d4f73a751a5661.1560431531.git.jpoimboe@redhat.com>



> 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
> 


  reply	other threads:[~2019-06-13 18:58 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 13:20 [PATCH 0/9] x86/bpf: unwinder fixes Josh Poimboeuf
2019-06-13 13:20 ` [PATCH 1/9] perf/x86: Always store regs->ip in perf_callchain_kernel() Josh Poimboeuf
2019-06-13 13:20 ` [PATCH 2/9] objtool: Fix ORC unwinding in non-JIT BPF generated code Josh Poimboeuf
2019-06-13 20:57   ` Alexei Starovoitov
2019-06-14  1:20     ` Josh Poimboeuf
2019-06-14  1:37       ` Alexei Starovoitov
2019-06-14  1:51         ` Josh Poimboeuf
2019-06-14  7:08       ` Peter Zijlstra
2019-06-14  7:35         ` Alexei Starovoitov
2019-06-14  8:11           ` Peter Zijlstra
2019-06-14 15:13             ` Alexei Starovoitov
2019-06-14 16:11               ` Josh Poimboeuf
2019-06-13 13:21 ` [PATCH 3/9] x86/bpf: Move epilogue generation to a dedicated function Josh Poimboeuf
2019-06-13 18:57   ` Song Liu [this message]
2019-06-13 19:12     ` Josh Poimboeuf
2019-06-13 13:21 ` [PATCH 4/9] x86/bpf: Simplify prologue generation Josh Poimboeuf
2019-06-13 13:21 ` [PATCH 5/9] x86/bpf: Support SIB byte generation Josh Poimboeuf
2019-06-13 13:21 ` [PATCH 6/9] x86/bpf: Fix JIT frame pointer usage Josh Poimboeuf
2019-06-13 21:58   ` Alexei Starovoitov
2019-06-14  1:22     ` Josh Poimboeuf
2019-06-14  1:39       ` Alexei Starovoitov
2019-06-14  1:52         ` Josh Poimboeuf
2019-06-14 10:50     ` David Laight
2019-06-14 13:44       ` Josh Poimboeuf
2019-06-14 13:58         ` David Laight
2019-06-14 17:07           ` Josh Poimboeuf
2019-06-17 15:07             ` David Laight
2019-06-13 13:21 ` [PATCH 7/9] x86/unwind/orc: Fall back to using frame pointers for generated code Josh Poimboeuf
2019-06-13 22:00   ` Alexei Starovoitov
2019-06-14  1:30     ` Josh Poimboeuf
2019-06-14  1:42       ` Alexei Starovoitov
2019-06-14  1:58         ` Josh Poimboeuf
2019-06-14  2:28           ` Josh Poimboeuf
2019-06-14  4:50             ` Josh Poimboeuf
2019-06-14  6:00               ` Alexei Starovoitov
2019-06-14  7:41                 ` Peter Zijlstra
2019-06-14 13:31                   ` Josh Poimboeuf
2019-06-14 15:29                   ` Alexei Starovoitov
2019-06-14 13:34                 ` Josh Poimboeuf
2019-06-14 15:31                   ` Alexei Starovoitov
2019-06-14 15:56                     ` Josh Poimboeuf
2019-06-13 13:21 ` [PATCH 8/9] x86/bpf: Convert asm comments to AT&T syntax Josh Poimboeuf
2019-06-13 18:52   ` Song Liu
2019-06-13 19:11     ` Josh Poimboeuf
2019-06-14  7:42     ` Peter Zijlstra
2019-06-14 15:13       ` Song Liu
2019-06-13 13:21 ` [PATCH 9/9] x86/bpf: Convert MOV function/macro argument ordering " Josh Poimboeuf
2019-06-13 19:00 ` [PATCH 0/9] x86/bpf: unwinder fixes Song Liu
2019-06-13 20:41 ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A753FBC1-3781-4A47-B0AD-A4300C552F7B@fb.com \
    --to=songliubraving@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jpoimboe@redhat.com \
    --cc=kasong@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®