From: Josh Poimboeuf <jpoimboe@redhat.com>
To: x86@kernel.org, Alexei Starovoitov <ast@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Daniel Borkmann <daniel@iogearbox.net>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Song Liu <songliubraving@fb.com>, Kairui Song <kasong@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
David Laight <David.Laight@ACULAB.COM>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@kernel.org>
Subject: [PATCH v2 3/5] x86/bpf: Move epilogue generation to a dedicated function
Date: Fri, 14 Jun 2019 12:56:42 -0500 [thread overview]
Message-ID: <950a6d53bb000ca4cdd946ec6cfd1570c77c2df5.1560534694.git.jpoimboe@redhat.com> (raw)
In-Reply-To: <cover.1560534694.git.jpoimboe@redhat.com>
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>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
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);
+
+ /* 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
next prev parent reply other threads:[~2019-06-14 18:00 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-14 17:56 [PATCH v2 0/5] x86/bpf: unwinder fixes Josh Poimboeuf
2019-06-14 17:56 ` [PATCH v2 1/5] perf/x86: Always store regs->ip in perf_callchain_kernel() Josh Poimboeuf
2019-06-14 20:56 ` Alexei Starovoitov
2019-06-14 21:06 ` Josh Poimboeuf
2019-06-14 21:16 ` Steven Rostedt
2019-06-14 21:20 ` Song Liu
2019-06-14 17:56 ` [PATCH v2 2/5] objtool: Fix ORC unwinding in non-JIT BPF generated code Josh Poimboeuf
2019-06-14 20:58 ` Alexei Starovoitov
2019-06-14 21:07 ` Josh Poimboeuf
2019-06-14 21:09 ` Alexei Starovoitov
2019-06-14 21:19 ` Josh Poimboeuf
2019-06-14 21:22 ` Alexei Starovoitov
2019-06-14 23:17 ` Josh Poimboeuf
2019-06-14 23:30 ` Alexei Starovoitov
2019-06-15 0:02 ` Josh Poimboeuf
2019-06-15 0:06 ` abhja kaanlani
2019-06-15 0:07 ` Alexei Starovoitov
2019-06-17 14:57 ` David Laight
2019-06-14 17:56 ` Josh Poimboeuf [this message]
2019-06-14 17:56 ` [PATCH v2 4/5] x86/bpf: Fix 64-bit JIT frame pointer usage Josh Poimboeuf
2019-06-14 21:05 ` Alexei Starovoitov
2019-06-14 21:19 ` Josh Poimboeuf
2019-06-14 21:27 ` Alexei Starovoitov
2019-06-14 23:13 ` Josh Poimboeuf
2019-06-14 23:23 ` Alexei Starovoitov
2019-06-14 23:54 ` Josh Poimboeuf
2019-06-15 0:02 ` Alexei Starovoitov
2019-06-15 4:27 ` Josh Poimboeuf
2019-06-15 5:16 ` Alexei Starovoitov
2019-06-15 12:57 ` Josh Poimboeuf
2019-06-14 17:56 ` [PATCH v2 5/5] x86/unwind/orc: Fall back to using frame pointers for generated code Josh Poimboeuf
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=950a6d53bb000ca4cdd946ec6cfd1570c77c2df5.1560534694.git.jpoimboe@redhat.com \
--to=jpoimboe@redhat.com \
--cc=David.Laight@ACULAB.COM \
--cc=ast@kernel.org \
--cc=bp@alien8.de \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kasong@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=tglx@linutronix.de \
--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;
as well as URLs for NNTP newsgroup(s).