Add support for the instructions array map type in the LoongArch JIT by calling bpf_prog_update_insn_ptrs() with the offsets that map xlated_offset to the jited_offset in the final image. LoongArch JIT already has this offset array which was being used for bpf_prog_fill_jited_linfo() and can be used directly for the function bpf_prog_update_insn_ptrs(). This is similar to commit 84b1c40d5b4d ("bpf: arm64: Add support for instructions array"). Signed-off-by: Tiezhu Yang --- arch/loongarch/net/bpf_jit.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c index 873b2b146f02..415b945bf818 100644 --- a/arch/loongarch/net/bpf_jit.c +++ b/arch/loongarch/net/bpf_jit.c @@ -2401,6 +2401,13 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr for (i = 0; i <= prog->len; i++) ctx.offset[i] *= LOONGARCH_INSN_SIZE; bpf_prog_fill_jited_linfo(prog, ctx.offset + 1); + /* + * The bpf_prog_update_insn_ptrs function expects offsets to + * point to the first byte of the jitted instruction (unlike + * the bpf_prog_fill_jited_linfo above, which, for historical + * reasons, expects to point to the next instruction) + */ + bpf_prog_update_insn_ptrs(prog, ctx.offset, ctx.ro_image); out_offset: kvfree(ctx.offset); -- 2.42.0