Re: [PATCH v2 2/4] LoongArch: BPF: Move arena register slot below TCC context

From: Tiezhu Yang

Date: Mon Jul 06 2026 - 01:21:00 EST


On 2026/7/6 下午12:29, bot+bpf-ci@xxxxxxxxxx wrote:
LoongArch: BPF: Move arena register slot below TCC context

Currently, the stack layout places the optional arena register slot above
the tail call counter context. When arena_vm_start is dynamically enabled,
it shifts the relative offset of the tcc_ptr slot within the stack frame,
causing hardcoded tracking macros to mismatch and potentially leading to
memory misalignment or corruption.
To fix this, move the arena register save and restore sequences below the
tail call counter context slots in both build_prologue() and epilogue. It
needs to update __build_epilogue() to insert a proper offset decrement to
safely skip the unneeded tcc_ptr reading block while accurately aligning
with the relocated arena slot at the very bottom.
With this patch, the tcc_ptr slot is always positioned at a fixed distance
directly underneath the base callee-saved registers that is independent of
whether the arena features are on.
Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>

This looks like a fix for a memory misalignment or corruption bug affecting
arena BPF programs. Should it carry a Fixes: tag?

The buggy stack layout, where the arena register save/restore and the extra
stack reservation sit above the tail call counter context, appears to have
been introduced by:

Fixes: ef54c517a937 ("LoongArch: BPF: Implement PROBE_MEM32 pseudo instructions")

OK, will add it in v3.

Thanks,
Tiezhu