Skip to content

Commit 10541b3

Browse files
Xu Kuohaiborkmann
authored andcommitted
riscv, bpf: Fix incorrect runtime stats
When __bpf_prog_enter() returns zero, the s1 register is not set to zero, resulting in incorrect runtime stats. Fix it by setting s1 immediately upon the return of __bpf_prog_enter(). Fixes: 49b5e77 ("riscv, bpf: Add bpf trampoline support for RV64") Signed-off-by: Xu Kuohai <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Reviewed-by: Pu Lehui <[email protected]> Acked-by: Björn Töpel <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent dc7d744 commit 10541b3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/riscv/net/bpf_jit_comp64.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,16 +722,16 @@ static int invoke_bpf_prog(struct bpf_tramp_link *l, int args_off, int retval_of
722722
if (ret)
723723
return ret;
724724

725+
/* store prog start time */
726+
emit_mv(RV_REG_S1, RV_REG_A0, ctx);
727+
725728
/* if (__bpf_prog_enter(prog) == 0)
726729
* goto skip_exec_of_prog;
727730
*/
728731
branch_off = ctx->ninsns;
729732
/* nop reserved for conditional jump */
730733
emit(rv_nop(), ctx);
731734

732-
/* store prog start time */
733-
emit_mv(RV_REG_S1, RV_REG_A0, ctx);
734-
735735
/* arg1: &args_off */
736736
emit_addi(RV_REG_A0, RV_REG_FP, -args_off, ctx);
737737
if (!p->jited)

0 commit comments

Comments
 (0)