From: Lukas Stockner <lukas@lukasstockner.de>
To: Hari Bathini <hbathini@linux.ibm.com>,
Christophe Leroy <chleroy@kernel.org>,
bpf@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Cc: Naveen N Rao <naveen@kernel.org>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Lukas Stockner <lukas@lukasstockner.de>
Subject: [PATCH 2/4] powerpc32/bpf: fetch fifth argument in BPF subprograms
Date: Sun, 22 Nov 2026 20:42:03 +0100 [thread overview]
Message-ID: <20261122194205.218543-3-lukas@lukasstockner.de> (raw)
In-Reply-To: <20261122194205.218543-1-lukas@lukasstockner.de>
Commit 7dd0e2848764 ("powerpc/bpf/32: BPF prog is never called with more
than one arg") removed the BPF_REG_5 load since it's not used for program
arguments, but that is only true for regular programs - subprograms may
get up to five arguments, so the load is required there.
Fixes: 7dd0e2848764 ("powerpc/bpf/32: BPF prog is never called with more than one arg")
Signed-off-by: Lukas Stockner <lukas@lukasstockner.de>
---
arch/powerpc/net/bpf_jit_comp32.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/powerpc/net/bpf_jit_comp32.c b/arch/powerpc/net/bpf_jit_comp32.c
index 261ac0646b96..9f55dd4bdfd6 100644
--- a/arch/powerpc/net/bpf_jit_comp32.c
+++ b/arch/powerpc/net/bpf_jit_comp32.c
@@ -199,6 +199,13 @@ void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx)
if (bpf_is_seen_register(ctx, i))
EMIT(PPC_RAW_STW(i, _R1, bpf_jit_stack_offsetof(ctx, i)));
+ /* If this is a subprogram, load fifth argument from the stack */
+ if (ctx->is_subprog && bpf_is_seen_register(ctx, bpf_to_ppc(BPF_REG_5))) {
+ int offset = bpf_has_stack_frame(ctx) ? BPF_PPC_STACKFRAME(ctx) : 0;
+ EMIT(PPC_RAW_LWZ(bpf_to_ppc(BPF_REG_5) - 1, _R1, offset + 8));
+ EMIT(PPC_RAW_LWZ(bpf_to_ppc(BPF_REG_5), _R1, offset + 12));
+ }
+
/* Setup frame pointer to point to the bpf stack area */
if (bpf_is_seen_register(ctx, bpf_to_ppc(BPF_REG_FP))) {
EMIT(PPC_RAW_LI(bpf_to_ppc(BPF_REG_FP) - 1, 0));
--
2.56.0
next prev parent reply other threads:[~2026-11-22 22:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 19:42 [PATCH 0/4] powerpc32/bpf: fix BPF-to-BPF calls and instruction folding Lukas Stockner
2026-11-22 19:42 ` [PATCH 1/4] powerpc32/bpf: fix argument passing for subprograms Lukas Stockner
2026-11-23 7:46 ` Christophe Leroy (CS GROUP)
2026-11-22 19:42 ` Lukas Stockner [this message]
2026-11-22 19:42 ` [PATCH 3/4] powerpc32/bpf: mark all argument registers seen in function calls Lukas Stockner
2026-11-22 19:42 ` [PATCH 4/4] powerpc32/bpf: don't fold MOV into instructions that use dst_reg Lukas Stockner
2026-11-22 20:14 ` bot+bpf-ci
2026-11-28 18:32 ` Christophe Leroy (CS GROUP)
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=20261122194205.218543-3-lukas@lukasstockner.de \
--to=lukas@lukasstockner.de \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chleroy@kernel.org \
--cc=daniel@iogearbox.net \
--cc=hbathini@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=naveen@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