Re: [PATCH v3 3/5] LoongArch: BPF: Allow programs 2 KiB of stack

From: Tiezhu Yang

Date: Mon Nov 30 2026 - 06:36:54 EST


On 11/26/26 11:40 AM, George Guo wrote:
From: George Guo <guodongtai@xxxxxxxxxx>

...

@@ -140,27 +144,25 @@ static void build_prologue(struct jit_ctx *ctx)
*/
const bool is_exception_prog = prog->aux->exception_boundary ||
prog->aux->exception_cb;
-
- bpf_stack_adjust = round_up(ctx->prog->aux->stack_depth, 16);
-
- /* To store ra, fp, s0, s1, s2, s3, s4, s5 */
- stack_adjust += sizeof(long) * 8;
-
- /* To store tcc and tcc_ptr */
- stack_adjust += sizeof(long) * 2;
+ /* To store ra, fp, s0, s1, s2, s3, s4, s5, tcc and tcc_ptr */
+ int size = sizeof(long) * 10;
if (ctx->arena_vm_start || is_exception_prog)
- stack_adjust += sizeof(long);
+ size += sizeof(long);
- stack_adjust = round_up(stack_adjust, 16);
+ return round_up(size, 16);
+}

Patch 2 modifies the frame size calculation and this patch
immediately refactors it into jit_save_area_size(). Please
order the 2 KiB stack patch before the exceptions patch.

That way, the exception frame changes (s6-s8) only need to
be added once in jit_save_area_size(), IMO.

Thanks,
Tiezhu