From: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
To: Hari Bathini <hbathini@linux.ibm.com>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Cc: bpf@vger.kernel.org, Madhavan Srinivasan <maddy@linux.ibm.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Saket Kumar Bhaskar <skb99@linux.ibm.com>,
Abhishek Dubey <adubey@linux.ibm.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2 1/5] powerpc64/bpf: do not increment tailcall count when prog is NULL
Date: Sat, 21 Feb 2026 09:10:36 +0530 [thread overview]
Message-ID: <b53acfaf-9f56-48f0-9e0d-d7af272c6683@linux.ibm.com> (raw)
In-Reply-To: <20260220063933.196141-2-hbathini@linux.ibm.com>
On 20/02/26 12:09 pm, Hari Bathini wrote:
> Do not increment tailcall count, if tailcall did not succeed due to
> missing BPF program.
>
> Fixes: ce0761419fae ("powerpc/bpf: Implement support for tail calls")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
> ---
>
> * No changes since v1.
>
>
> arch/powerpc/net/bpf_jit_comp64.c | 39 +++++++++++++++++--------------
> 1 file changed, 21 insertions(+), 18 deletions(-)
>
> diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
> index b1a3945ccc9f..44ce8a8783f9 100644
> --- a/arch/powerpc/net/bpf_jit_comp64.c
> +++ b/arch/powerpc/net/bpf_jit_comp64.c
> @@ -522,9 +522,30 @@ static int bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 o
>
> /*
> * tail_call_info++; <- Actual value of tcc here
> + * Writeback this updated value only if tailcall succeeds.
> */
> EMIT(PPC_RAW_ADDI(bpf_to_ppc(TMP_REG_1), bpf_to_ppc(TMP_REG_1), 1));
>
> + /* prog = array->ptrs[index]; */
> + EMIT(PPC_RAW_MULI(bpf_to_ppc(TMP_REG_2), b2p_index, 8));
> + EMIT(PPC_RAW_ADD(bpf_to_ppc(TMP_REG_2), bpf_to_ppc(TMP_REG_2), b2p_bpf_array));
> + EMIT(PPC_RAW_LD(bpf_to_ppc(TMP_REG_2), bpf_to_ppc(TMP_REG_2),
> + offsetof(struct bpf_array, ptrs)));
> +
> + /*
> + * if (prog == NULL)
> + * goto out;
> + */
> + EMIT(PPC_RAW_CMPLDI(bpf_to_ppc(TMP_REG_2), 0));
> + PPC_BCC_SHORT(COND_EQ, out);
> +
> + /* goto *(prog->bpf_func + prologue_size); */
> + EMIT(PPC_RAW_LD(bpf_to_ppc(TMP_REG_2), bpf_to_ppc(TMP_REG_2),
> + offsetof(struct bpf_prog, bpf_func)));
> + EMIT(PPC_RAW_ADDI(bpf_to_ppc(TMP_REG_2), bpf_to_ppc(TMP_REG_2),
> + FUNCTION_DESCR_SIZE + bpf_tailcall_prologue_size));
> + EMIT(PPC_RAW_MTCTR(bpf_to_ppc(TMP_REG_2)));
> +
> /*
> * Before writing updated tail_call_info, distinguish if current frame
> * is storing a reference to tail_call_info or actual tcc value in
> @@ -539,24 +560,6 @@ static int bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 o
> /* Writeback updated value to tail_call_info */
> EMIT(PPC_RAW_STD(bpf_to_ppc(TMP_REG_1), bpf_to_ppc(TMP_REG_2), 0));
>
> - /* prog = array->ptrs[index]; */
> - EMIT(PPC_RAW_MULI(bpf_to_ppc(TMP_REG_1), b2p_index, 8));
> - EMIT(PPC_RAW_ADD(bpf_to_ppc(TMP_REG_1), bpf_to_ppc(TMP_REG_1), b2p_bpf_array));
> - EMIT(PPC_RAW_LD(bpf_to_ppc(TMP_REG_1), bpf_to_ppc(TMP_REG_1), offsetof(struct bpf_array, ptrs)));
> -
> - /*
> - * if (prog == NULL)
> - * goto out;
> - */
> - EMIT(PPC_RAW_CMPLDI(bpf_to_ppc(TMP_REG_1), 0));
> - PPC_BCC_SHORT(COND_EQ, out);
> -
> - /* goto *(prog->bpf_func + prologue_size); */
> - EMIT(PPC_RAW_LD(bpf_to_ppc(TMP_REG_1), bpf_to_ppc(TMP_REG_1), offsetof(struct bpf_prog, bpf_func)));
> - EMIT(PPC_RAW_ADDI(bpf_to_ppc(TMP_REG_1), bpf_to_ppc(TMP_REG_1),
> - FUNCTION_DESCR_SIZE + bpf_tailcall_prologue_size));
> - EMIT(PPC_RAW_MTCTR(bpf_to_ppc(TMP_REG_1)));
> -
> /* tear down stack, restore NVRs, ... */
> bpf_jit_emit_common_epilogue(image, ctx);
>
Tested this by patch, Please add below tag.
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Regards,
Venkat.
next prev parent reply other threads:[~2026-02-21 3:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-20 6:39 [PATCH v2 0/5] powerpc64/bpf: various fixes Hari Bathini
2026-02-20 6:39 ` [PATCH v2 1/5] powerpc64/bpf: do not increment tailcall count when prog is NULL Hari Bathini
2026-02-21 3:40 ` Venkat Rao Bagalkote [this message]
2026-02-20 6:39 ` [PATCH v2 2/5] powerpc64/bpf: fix the address returned by bpf_get_func_ip Hari Bathini
2026-02-21 3:41 ` Venkat Rao Bagalkote
2026-02-22 12:21 ` adubey
2026-02-20 6:39 ` [PATCH v2 3/5] powerpc64/bpf: use consistent tailcall offset in trampoline Hari Bathini
2026-02-22 13:07 ` adubey
2026-03-03 13:43 ` Hari Bathini
2026-02-20 6:39 ` [PATCH v2 4/5] powerpc64/bpf: remove BPF redzone protection in trampoline stack Hari Bathini
2026-02-21 3:43 ` Venkat Rao Bagalkote
2026-02-20 6:39 ` [PATCH v2 5/5] powerpc64/bpf: fix handling of BPF stack in exception callback Hari Bathini
2026-02-23 9:03 ` adubey
2026-03-03 13:46 ` Hari Bathini
2026-02-24 12:28 ` adubey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b53acfaf-9f56-48f0-9e0d-d7af272c6683@linux.ibm.com \
--to=venkat88@linux.ibm.com \
--cc=adubey@linux.ibm.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=hbathini@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=skb99@linux.ibm.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox