Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s64ilp32: ebpf_jit: Fix the incorrect jump addresses and index offsets in tail_call #16

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions arch/riscv/net/bpf_jit_comp64.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,32 @@ static int emit_bpf_tail_call(int insn, struct rv_jit_context *ctx)
* if (!prog)
* goto out;
*/
#ifdef CONFIG_ARCH_RV64ILP32
emit_slli(RV_REG_T2, RV_REG_A2, 2, ctx);
#else
emit_slli(RV_REG_T2, RV_REG_A2, 3, ctx);
#endif
emit_add(RV_REG_T2, RV_REG_T2, RV_REG_A1, ctx);
off = offsetof(struct bpf_array, ptrs);
if (is_12b_check(off, insn))
return -1;
#ifdef CONFIG_ARCH_RV64ILP32
emit_lw(RV_REG_T2, off, RV_REG_T2, ctx);
#else
emit_ld(RV_REG_T2, off, RV_REG_T2, ctx);
#endif
off = ninsns_rvoff(tc_ninsn - (ctx->ninsns - start_insn));
emit_branch(BPF_JEQ, RV_REG_T2, RV_REG_ZERO, off, ctx);

/* goto *(prog->bpf_func + 4); */
off = offsetof(struct bpf_prog, bpf_func);
if (is_12b_check(off, insn))
return -1;
#ifdef CONFIG_ARCH_RV64ILP32
emit_lw(RV_REG_T3, off, RV_REG_T2, ctx);
#else
emit_ld(RV_REG_T3, off, RV_REG_T2, ctx);
#endif
__build_epilogue(true, ctx);
return 0;
}
Expand Down