summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorYonghong Song <yonghong.song@linux.dev>2026-08-18 22:52:54 -0700
committerEduard Zingerman <eddyz87@gmail.com>2026-08-21 10:49:27 -0700
commit34c3503cb29ad0f73d413b83a0586e53d832bb90 (patch)
tree1843ca5ac5b007dca59f6a16f5160ae0bbb38bbb /scripts
parentcf5b96d9554815780f864d6f0014ac384e9be59c (diff)
downloadlinux-next-34c3503cb29ad0f73d413b83a0586e53d832bb90.tar.gz
linux-next-34c3503cb29ad0f73d413b83a0586e53d832bb90.zip
bpf: Wire up JIT support for 16-byte kfunc returns
LLVM 23 returns an __int128, or a struct/union larger than 8 bytes and no larger than 16 bytes, in the BPF R0:R2 register pair. The previous patch added the shared helpers describing that convention; wire up the JIT side so that the second half of the return value actually lands in R2. Placing the second return half into R2 is possible on any JIT, but it needs architecture-specific JIT work. Rather than requiring every JIT to implement it at once, add a bpf_jit_supports_kfunc_ret_reg_pair() capability, defaulting to false in the generic core; an architecture opts in once its JIT handles the R0:R2 pair, and the remaining ones are left for future work. Only the x86-64, arm64 and riscv64 JITs opt in so far. On arm64 and riscv64 the native second return register is already BPF R2 (x1 in bpf2a64[] and a1 in regmap[] respectively), so the upper half needs no move at all, unlike x86-64's RDX->RSI. The lower half is covered by the move into BPF R0 that those JITs already emit after every call, from x0 into x8 and from a0 into a5. This has been tested on x86-64 and arm64. The riscv64 path is expected to work by the same register-mapping reasoning as arm64 but has not been tested. bpf_add_kfunc_call() also rejects a kfunc that is marked KF_FASTCALL and returns more than 8 bytes. The bpf_fastcall contract implemented by mark_fastcall_pattern_for_call() assumes a call clobbers R0 plus the registers holding its arguments, so a return in the R0:R2 pair would clobber an R2 the caller expects the fastcall pattern to preserve. Such a kfunc is rejected with -EOPNOTSUPP as well. Signed-off-by: Yonghong Song <yonghong.song@linux.dev> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://patch.msgid.link/20260819055254.3295610-1-yonghong.song@linux.dev Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions