> powerpc64/bpf: use consistent tailcall offset in trampoline
>
> Ideally, the offset used to load the tail call info field and to find
> the pass by reference address for tail call field should be the same.
> But while setting up the tail call info in the trampoline, this was
> not followed. This can be misleading and can lead to unpredicable

This isn't a bug, but "unpredicable" should be "unpredictable".

> results if and when bpf_has_stack_frame() ends up returning true
> for trampoline frame.

> diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
> --- a/arch/powerpc/net/bpf_jit_comp.c
> +++ b/arch/powerpc/net/bpf_jit_comp.c

[ ... ]

> @@ -658,7 +656,7 @@ static void bpf_trampoline_setup_tail_call_info(u32 
> *image, struct codegen_context *ctx,
>                */
>               EMIT(PPC_RAW_CMPLWI(_R3, MAX_TAIL_CALL_CNT));
>               PPC_BCC_CONST_SHORT(COND_GT, 8);
> -             EMIT(PPC_RAW_ADDI(_R3, _R4, 
> bpf_jit_stack_tailcallinfo_offset(ctx)));
> +             EMIT(PPC_RAW_ADDI(_R3, _R4, -BPF_PPC_TAILCALL));
>               /*
>                * From ...(1) above:
>                * trampoline_frame_bottom =                            ...(2)
>                *      func_frame_offset - bpf_dummy_frame_size
>                *
>                * Using ...(2) derived above:
>                * trampoline_tail_call_info_offset =                  ...(3)
>                *      trampoline_frame_bottom - tailcallinfo_offset

The comment still references "tailcallinfo_offset" but the local
variable by that name was removed in this patch. Should this say
"BPF_PPC_TAILCALL" instead?

>                *
>                * From ...(3):
>                * Use trampoline_tail_call_info_offset to write reference of 
> main's
>                * tail_call_info in trampoline frame.
>                */
>               EMIT(PPC_RAW_STL(_R3, _R1, (func_frame_offset - 
> bpf_dummy_frame_size)
> -                                                             - 
> tailcallinfo_offset));
> +                                                             - 
> BPF_PPC_TAILCALL));


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/22053464899

AI-authorship-score: low
AI-authorship-explanation: The patch follows standard kernel conventions with a 
human-like typo in the commit message, and addresses a specific powerpc BPF JIT 
implementation detail consistent with the author's domain expertise.
issues-found: 2
issue-severity-score: low
issue-severity-explanation: Two minor issues found: a stale comment referencing 
a removed local variable, and a spelling error in the commit message. Neither 
affects code correctness or runtime behavior.

Reply via email to