From: Pu Lehui Implement callx by emitting a jalr instruction to jump to the target subprog address held in rd, and marking the call as it clobbers RV_REG_RA. Signed-off-by: Pu Lehui --- arch/riscv/net/bpf_jit_comp64.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c index 7ce9f8460c59..88430825f4f5 100644 --- a/arch/riscv/net/bpf_jit_comp64.c +++ b/arch/riscv/net/bpf_jit_comp64.c @@ -2071,6 +2071,13 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx, emit_mv(bpf_to_rv_reg(BPF_REG_0, ctx), RV_REG_A0, ctx); break; } + + /* indirect call to a bpf subprog via the address in rd */ + case BPF_JMP | BPF_CALL | BPF_X: + mark_call(ctx); + emit_jalr(RV_REG_RA, rd, 0, ctx); + break; + /* tail call */ case BPF_JMP | BPF_TAIL_CALL: if (emit_bpf_tail_call(i, ctx)) @@ -2397,3 +2404,8 @@ bool bpf_jit_supports_exceptions(void) */ return IS_ENABLED(CONFIG_FRAME_POINTER); } + +bool bpf_jit_supports_callx(void) +{ + return true; +} -- 2.34.1