Skip to content

Commit dc7d744

Browse files
Xu Kuohaiborkmann
authored andcommitted
bpf, arm64: Fix incorrect runtime stats
When __bpf_prog_enter() returns zero, the arm64 register x20 that stores prog start time is not assigned to zero, causing incorrect runtime stats. To fix it, assign the return value of bpf_prog_enter() to x20 register immediately upon its return. Fixes: efc9909 ("bpf, arm64: Add bpf trampoline for arm64") Reported-by: Ivan Babrou <[email protected]> Signed-off-by: Xu Kuohai <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Tested-by: Ivan Babrou <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 37eacb9 commit dc7d744

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/arm64/net/bpf_jit_comp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,15 +1844,15 @@ static void invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_link *l,
18441844

18451845
emit_call(enter_prog, ctx);
18461846

1847+
/* save return value to callee saved register x20 */
1848+
emit(A64_MOV(1, A64_R(20), A64_R(0)), ctx);
1849+
18471850
/* if (__bpf_prog_enter(prog) == 0)
18481851
* goto skip_exec_of_prog;
18491852
*/
18501853
branch = ctx->image + ctx->idx;
18511854
emit(A64_NOP, ctx);
18521855

1853-
/* save return value to callee saved register x20 */
1854-
emit(A64_MOV(1, A64_R(20), A64_R(0)), ctx);
1855-
18561856
emit(A64_ADD_I(1, A64_R(0), A64_SP, args_off), ctx);
18571857
if (!p->jited)
18581858
emit_addr_mov_i64(A64_R(1), (const u64)p->insnsi, ctx);

0 commit comments

Comments
 (0)