Skip to content

Fix two tailcall-related issues #5544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: bpf-next_base
Choose a base branch
from

Conversation

kernel-patches-daemon-bpf-rc[bot]
Copy link

Pull request for series with
subject: Fix two tailcall-related issues
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=977599

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: c4b1be9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=977599
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 26d0e53
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=977599
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 0df1a55
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=977599
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: cce3fee
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=977599
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 1230be8
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=977599
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 212ec92
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=977599
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 621af19
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=977599
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 564606f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=977599
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 38d95be
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=977599
version: 1

Haoran Jiang added 2 commits July 2, 2025 11:47
…emit_bpf_tail_call function

For a ebpf subprog JIT,the last call bpf_int_jit_compile function will
directly enter the skip_init_ctx process. At this point, out_offset = -1,
the jmp_offset in emit_bpf_tail_call is calculated
by #define jmp_offset (out_offset - (cur_offset)) is a negative number,
which does not meet expectations.The final generated assembly as follow.

54:	bgeu        	$a2, $t1, -8	    # 0x0000004c
58:	addi.d      	$a6, $s5, -1
5c:	bltz        	$a6, -16	    # 0x0000004c
60:	alsl.d      	$t2, $a2, $a1, 0x3
64:	ld.d        	$t2, $t2, 264
68:	beq         	$t2, $zero, -28	    # 0x0000004c

Before apply this patch, the follow test case will reveal soft lock issues.

cd tools/testing/selftests/bpf/
./test_progs --allow=tailcalls/tailcall_bpf2bpf_1

dmesg:
watchdog: BUG: soft lockup - CPU#2 stuck for 26s! [test_progs:25056]

Signed-off-by: Haoran Jiang <jianghaoran@kylinos.cn>
In specific use cases combining tailcalls and BPF-to-BPF calls,
MAX_TAIL_CALL_CNT won't work because of missing tail_call_cnt
back-propagation from callee to caller。This patch fixes this
tailcall issue caused by abusing the tailcall in bpf2bpf feature
on LoongArch like the way of "bpf, x64: Fix tailcall hierarchy".

push tail_call_cnt_ptr and tail_call_cnt into the stack,
tail_call_cnt_ptr is passed between tailcall and bpf2bpf,
uses tail_call_cnt_ptr to increment tail_call_cnt.

Signed-off-by: Haoran Jiang <jianghaoran@kylinos.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants