Skip to content

Commit a5912c3

Browse files
puranjaymohanborkmann
authored andcommitted
riscv, bpf: Optimize stack usage of trampoline
When BPF_TRAMP_F_CALL_ORIG is not set, stack space for passing arguments on stack doesn't need to be reserved because the original function is not called. Only reserve space for stacked arguments when BPF_TRAMP_F_CALL_ORIG is set. Signed-off-by: Puranjay Mohan <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Pu Lehui <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent fd8db07 commit a5912c3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/riscv/net/bpf_jit_comp64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
892892
stack_size += 8;
893893
sreg_off = stack_size;
894894

895-
if (nr_arg_slots - RV_MAX_REG_ARGS > 0)
895+
if ((flags & BPF_TRAMP_F_CALL_ORIG) && (nr_arg_slots - RV_MAX_REG_ARGS > 0))
896896
stack_size += (nr_arg_slots - RV_MAX_REG_ARGS) * 8;
897897

898898
stack_size = round_up(stack_size, STACK_ALIGN);

0 commit comments

Comments
 (0)