Skip to content

[PW_SID:1123580] Mixing bpf2bpf and tailcalls for RV64#2245

Closed
linux-riscv-bot wants to merge 8 commits into
workflow__riscv__fixesfrom
pw1123580
Closed

[PW_SID:1123580] Mixing bpf2bpf and tailcalls for RV64#2245
linux-riscv-bot wants to merge 8 commits into
workflow__riscv__fixesfrom
pw1123580

Conversation

@linux-riscv-bot

Copy link
Copy Markdown

PR for series 1123580 applied to workflow__riscv__fixes

Name: Mixing bpf2bpf and tailcalls for RV64
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1123580
Version: 6

Linux RISC-V bot and others added 8 commits July 8, 2026 07:37
Extract the is_struct_ops_tramp helper, and use it in riscv
as the current checks are somewhat hacky.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
When bpf_int_jit_compile() is called for subprograms, it returns early
during the first pass (!prog->is_func || extra_pass is false), keeping
ctx->offset alive for the subsequent extra pass.

If JIT compilation fails for a later subprogram, the BPF core aborts
and calls bpf_jit_free() to clean up the first subprogram. However,
bpf_jit_free() fails to free jit_data->ctx.offset, which causes a
memory leak of the JIT context offsets array.

Fix this by adding the missing kfree(jit_data->ctx.offset) in
bpf_jit_free().

Fixes: 48a8f78 ("bpf, riscv: use prog pack allocator in the BPF JIT")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
It is unnecessary to allocate continuous physical memory for cache
buffer, and when ebpf program is too large, it may cause memory
allocation failure.

Acked-by: Björn Töpel <bjorn@kernel.org>
Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
When CONFIG_CFI_CLANG is enabled, prog->bpf_func already skips the kcfi
instruction during setup. Including it again in the tailcall jump offset
causes it to jump over an extra 4 bytes, skipping the stack pointer
adjustment, which will result in kernel stack corruption.

Fixes: 30a59cc ("riscv, bpf: Fix possible infinite tailcall when CONFIG_CFI_CLANG is enabled")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add RV_TAILCALL_OFFSET macro to format tailcall offset, and correct the
relevant comments.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
In the current RV64 JIT, if we just don't initialize the TCC in subprog,
the TCC can be propagated from the parent process to the subprocess, but
the updated TCC of the parent process cannot be restored when the
subprocess exits. Since the RV64 TCC is initialized before saving the
callee saved registers into the stack, we cannot use the callee saved
register to pass the TCC, otherwise the original value of the callee
saved register will be destroyed. So we implemented mixing bpf2bpf and
tailcalls similar to x86_64, i.e. using a non-callee saved register to
transfer the TCC between functions, and saving that register to the
stack to protect the TCC value. As for the tailcall hierarchy issue,
inspired by the s390's low-overhead approach, we store TCC from
RV_REG_TCC back to stack after calling bpf2bpf call or calling orig bpf
func in bpf trampoline.

Tests test_bpf.ko and test_verifier have passed, as well as the relative
testcases of test_progs*.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The RV64 BPF JIT now supports mixing bpf2bpf and tailcalls.
Therefore, the tailcall_bpf2bpf tests can be safely removed
from the riscv64 denylist.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 120.54 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1783.56 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 2220.68 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.38 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 23.00 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.18 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 82.15 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
kdoc
Desc: Detects for kdoc errors
Duration: 0.79 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 120.27 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1424.09 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1779.12 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.65 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 22.23 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.54 seconds
Result: WARNING
Output:

WARNING: Reported-by: should be immediately followed by Closes: or Link: with a URL to the report
#19: 
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Pu Lehui <pulehui@huawei.com>

total: 0 errors, 1 warnings, 0 checks, 7 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit cba4037b3568 ("riscv, bpf: Fix memory leak in bpf_jit_free") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 1 warnings, 0 checks, 7 lines checked
WARNING: Reported-by: should be immediately followed by Closes: or Link: with a URL to the report


@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 84.31 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free"
kdoc
Desc: Detects for kdoc errors
Duration: 0.73 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free"
module-param
Desc: Detect module_param changes
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 5: "[bpf-next,v6,5/7] riscv, bpf: Add RV_TAILCALL_OFFSET macro to format tailcall offset"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 5: "[bpf-next,v6,5/7] riscv, bpf: Add RV_TAILCALL_OFFSET macro to format tailcall offset"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 5: "[bpf-next,v6,5/7] riscv, bpf: Add RV_TAILCALL_OFFSET macro to format tailcall offset"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 121.36 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1447.16 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1809.19 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.89 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 22.39 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.86 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 82.20 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
kdoc
Desc: Detects for kdoc errors
Duration: 0.79 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 122.24 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1127.75 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1456.43 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.77 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 22.22 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.60 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 83.70 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
kdoc
Desc: Detects for kdoc errors
Duration: 0.78 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot
linux-riscv-bot force-pushed the workflow__riscv__fixes branch from a50938c to 40ba5ca Compare July 8, 2026 17:32
@linux-riscv-bot
linux-riscv-bot deleted the pw1123580 branch July 9, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant