|
@@ -216,7 +216,7 @@ struct jit_context {
|
|
|
/* emit x64 prologue code for BPF program and check it's size.
|
|
|
* bpf_tail_call helper will skip it while jumping into another program
|
|
|
*/
|
|
|
-static void emit_prologue(u8 **pprog, u32 stack_depth)
|
|
|
+static void emit_prologue(u8 **pprog, u32 stack_depth, bool ebpf_from_cbpf)
|
|
|
{
|
|
|
u8 *prog = *pprog;
|
|
|
int cnt = 0;
|
|
@@ -251,18 +251,21 @@ static void emit_prologue(u8 **pprog, u32 stack_depth)
|
|
|
/* mov qword ptr [rbp+24],r15 */
|
|
|
EMIT4(0x4C, 0x89, 0x7D, 24);
|
|
|
|
|
|
- /* Clear the tail call counter (tail_call_cnt): for eBPF tail calls
|
|
|
- * we need to reset the counter to 0. It's done in two instructions,
|
|
|
- * resetting rax register to 0 (xor on eax gets 0 extended), and
|
|
|
- * moving it to the counter location.
|
|
|
- */
|
|
|
+ if (!ebpf_from_cbpf) {
|
|
|
+ /* Clear the tail call counter (tail_call_cnt): for eBPF tail
|
|
|
+ * calls we need to reset the counter to 0. It's done in two
|
|
|
+ * instructions, resetting rax register to 0, and moving it
|
|
|
+ * to the counter location.
|
|
|
+ */
|
|
|
|
|
|
- /* xor eax, eax */
|
|
|
- EMIT2(0x31, 0xc0);
|
|
|
- /* mov qword ptr [rbp+32], rax */
|
|
|
- EMIT4(0x48, 0x89, 0x45, 32);
|
|
|
+ /* xor eax, eax */
|
|
|
+ EMIT2(0x31, 0xc0);
|
|
|
+ /* mov qword ptr [rbp+32], rax */
|
|
|
+ EMIT4(0x48, 0x89, 0x45, 32);
|
|
|
+
|
|
|
+ BUILD_BUG_ON(cnt != PROLOGUE_SIZE);
|
|
|
+ }
|
|
|
|
|
|
- BUILD_BUG_ON(cnt != PROLOGUE_SIZE);
|
|
|
*pprog = prog;
|
|
|
}
|
|
|
|
|
@@ -453,7 +456,8 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
|
|
|
int proglen = 0;
|
|
|
u8 *prog = temp;
|
|
|
|
|
|
- emit_prologue(&prog, bpf_prog->aux->stack_depth);
|
|
|
+ emit_prologue(&prog, bpf_prog->aux->stack_depth,
|
|
|
+ bpf_prog_was_classic(bpf_prog));
|
|
|
|
|
|
if (seen_ld_abs)
|
|
|
emit_load_skb_data_hlen(&prog);
|