Skip to content

Commit f663a03

Browse files
AsphalttAlexei Starovoitov
authored andcommitted
bpf, x64: Remove tail call detection
As 'prog->aux->tail_call_reachable' is correct for tail call present, it's unnecessary to detect tail call in x86 jit. Therefore, let's remove it. Signed-off-by: Leon Hwang <hffilwlqm@gmail.com> Link: https://lore.kernel.org/r/20240610124224.34673-3-hffilwlqm@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 01793ed commit f663a03

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

arch/x86/net/bpf_jit_comp.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,13 +1234,11 @@ bool ex_handler_bpf(const struct exception_table_entry *x, struct pt_regs *regs)
12341234
}
12351235

12361236
static void detect_reg_usage(struct bpf_insn *insn, int insn_cnt,
1237-
bool *regs_used, bool *tail_call_seen)
1237+
bool *regs_used)
12381238
{
12391239
int i;
12401240

12411241
for (i = 1; i <= insn_cnt; i++, insn++) {
1242-
if (insn->code == (BPF_JMP | BPF_TAIL_CALL))
1243-
*tail_call_seen = true;
12441242
if (insn->dst_reg == BPF_REG_6 || insn->src_reg == BPF_REG_6)
12451243
regs_used[0] = true;
12461244
if (insn->dst_reg == BPF_REG_7 || insn->src_reg == BPF_REG_7)
@@ -1324,7 +1322,6 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image, u8 *rw_image
13241322
struct bpf_insn *insn = bpf_prog->insnsi;
13251323
bool callee_regs_used[4] = {};
13261324
int insn_cnt = bpf_prog->len;
1327-
bool tail_call_seen = false;
13281325
bool seen_exit = false;
13291326
u8 temp[BPF_MAX_INSN_SIZE + BPF_INSN_SAFETY];
13301327
u64 arena_vm_start, user_vm_start;
@@ -1336,11 +1333,7 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image, u8 *rw_image
13361333
arena_vm_start = bpf_arena_get_kern_vm_start(bpf_prog->aux->arena);
13371334
user_vm_start = bpf_arena_get_user_vm_start(bpf_prog->aux->arena);
13381335

1339-
detect_reg_usage(insn, insn_cnt, callee_regs_used,
1340-
&tail_call_seen);
1341-
1342-
/* tail call's presence in current prog implies it is reachable */
1343-
tail_call_reachable |= tail_call_seen;
1336+
detect_reg_usage(insn, insn_cnt, callee_regs_used);
13441337

13451338
emit_prologue(&prog, bpf_prog->aux->stack_depth,
13461339
bpf_prog_was_classic(bpf_prog), tail_call_reachable,

0 commit comments

Comments
 (0)