From: Puranjay Mohan <puranjay@kernel•org>
To: bpf@vger•kernel.org, "Yonghong Song" <yonghong.song@linux•dev>
Cc: Puranjay Mohan <puranjay@kernel•org>,
"Alexei Starovoitov" <ast@kernel•org>,
"Daniel Borkmann" <daniel@iogearbox•net>,
"Andrii Nakryiko" <andrii@kernel•org>,
"Martin KaFai Lau" <martin.lau@linux•dev>,
"Eduard Zingerman" <eddyz87@gmail•com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail•com>,
"Song Liu" <song@kernel•org>,
"Xu Kuohai" <xukuohai@huaweicloud•com>,
"Catalin Marinas" <catalin.marinas@arm•com>,
"Will Deacon" <will@kernel•org>,
linux-arm-kernel@lists•infradead.org
Subject: [PATCH bpf-next 1/2] bpf, arm64: Fix redundant MOV and clarify stack arg comments
Date: Thu, 28 May 2026 09:17:47 -0700 [thread overview]
Message-ID: <20260528161750.1900674-2-puranjay@kernel.org> (raw)
In-Reply-To: <20260528161750.1900674-1-puranjay@kernel.org>
emit_stack_arg_store_imm() materializes the immediate into tmp and
then moves tmp to the target register (x5-x7). Emit the immediate
directly into the target register to avoid the redundant MOV.
While here, qualify the bare "FP" in the stack-layout ASCII art as
"A64_FP" so it is not confused with BPF_FP, and note that incoming
stack arguments sit above the FP/LR pair pushed by the callee
prologue.
Suggested-by: Will Deacon <will@kernel•org>
Signed-off-by: Puranjay Mohan <puranjay@kernel•org>
---
arch/arm64/net/bpf_jit_comp.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index e3bbeaa94590..b4abc3138f37 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -546,7 +546,8 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf)
* low
*
* Stack args 6-8 are passed in x5-x7, args 9+ at [SP].
- * Incoming args 9+ are at [FP + 16], [FP + 24], ...
+ * Incoming args 9+ are at [A64_FP + 16], [A64_FP + 24], ...
+ * (above the saved FP/LR pair pushed in the callee prologue).
*/
emit_kcfi(is_main_prog ? cfi_bpf_hash : cfi_bpf_subprog_hash, ctx);
@@ -1235,11 +1236,12 @@ static void emit_stack_arg_store_imm(s32 imm, s16 bpf_off, const u8 tmp, struct
{
int idx = -bpf_off / sizeof(u64) - 1;
- emit_a64_mov_i(1, tmp, imm, ctx);
- if (idx < NR_STACK_ARG_REGS)
- emit(A64_MOV(1, stack_arg_reg[idx], tmp), ctx);
- else
+ if (idx < NR_STACK_ARG_REGS) {
+ emit_a64_mov_i(1, stack_arg_reg[idx], imm, ctx);
+ } else {
+ emit_a64_mov_i(1, tmp, imm, ctx);
emit(A64_STR64I(tmp, A64_SP, (idx - NR_STACK_ARG_REGS) * sizeof(u64)), ctx);
+ }
}
/* JITs an eBPF instruction.
--
2.53.0-Meta
next prev parent reply other threads:[~2026-05-28 16:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 16:17 [PATCH bpf-next 0/2] bpf, arm64: Stack argument fixes Puranjay Mohan
2026-05-28 16:17 ` Puranjay Mohan [this message]
2026-05-28 16:17 ` [PATCH bpf-next 2/2] selftests/bpf: Use at least 10 args in stack argument tests Puranjay Mohan
2026-05-28 20:55 ` Yonghong Song
2026-06-01 0:50 ` [PATCH bpf-next 0/2] bpf, arm64: Stack argument fixes patchwork-bot+netdevbpf
2026-06-01 12:22 ` Will Deacon
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=20260528161750.1900674-2-puranjay@kernel.org \
--to=puranjay@kernel$(echo .)org \
--cc=andrii@kernel$(echo .)org \
--cc=ast@kernel$(echo .)org \
--cc=bpf@vger$(echo .)kernel.org \
--cc=catalin.marinas@arm$(echo .)com \
--cc=daniel@iogearbox$(echo .)net \
--cc=eddyz87@gmail$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=martin.lau@linux$(echo .)dev \
--cc=memxor@gmail$(echo .)com \
--cc=song@kernel$(echo .)org \
--cc=will@kernel$(echo .)org \
--cc=xukuohai@huaweicloud$(echo .)com \
--cc=yonghong.song@linux$(echo .)dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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