@@ -893,7 +893,8 @@ static void emit_tail_call(struct jit_ctx *ctx)
emit_nop(ctx);
}
-static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
+static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
+ bool extra_pass)
{
const u8 code = insn->code;
const u8 dst = bpf2sparc[insn->dst_reg];
@@ -1214,7 +1215,14 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
/* function call */
case BPF_JMP | BPF_CALL:
{
- u8 *func = ((u8 *)__bpf_call_base) + imm;
+ bool func_addr_fixed;
+ u64 func;
+ int err;
+
+ err = bpf_jit_get_func_addr(ctx->prog, insn, extra_pass,
+ &func, &func_addr_fixed);
+ if (err)
+ return err;
ctx->saw_call = true;
@@ -1445,7 +1453,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
return 0;
}
-static int build_body(struct jit_ctx *ctx)
+static int build_body(struct jit_ctx *ctx, bool extra_pass)
{
const struct bpf_prog *prog = ctx->prog;
int i;
@@ -1455,7 +1463,7 @@ static int build_body(struct jit_ctx *ctx)
int ret;
ctx->offset[i] = ctx->idx;
- ret = build_insn(insn, ctx);
+ ret = build_insn(insn, ctx, extra_pass);
if (ret < 0)
return ret;
@@ -1549,7 +1557,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
ctx.idx = 0;
build_prologue(&ctx);
- if (build_body(&ctx)) {
+ if (build_body(&ctx, extra_pass)) {
prog = orig_prog;
goto out_off;
}
@@ -1586,7 +1594,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
build_prologue(&ctx);
- if (build_body(&ctx)) {
+ if (build_body(&ctx, extra_pass)) {
bpf_jit_binary_free(header);
prog = orig_prog;
goto out_off;
@@ -2091,6 +2091,13 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
if (insn->src_reg == BPF_PSEUDO_CALL)
goto notyet;
+ err = bpf_jit_get_func_addr(bpf_prog, insn, extra_pass,
+ &func_addr,
+ &func_addr_fixed);
+ if (err)
+ return err;
+ func = (u8 *)(unsigned long)func_addr;
+
if (insn->src_reg == BPF_PSEUDO_KFUNC_CALL) {
int err;
Preparation for moving kfunc address from bpf_insn.imm. Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> --- arch/sparc/net/bpf_jit_comp_64.c | 20 ++++++++++++++------ arch/x86/net/bpf_jit_comp32.c | 7 +++++++ 2 files changed, 21 insertions(+), 6 deletions(-)