1*e939f3d1SIhor Solodrai // SPDX-License-Identifier: GPL-2.0 2*e939f3d1SIhor Solodrai /* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */ 3*e939f3d1SIhor Solodrai 4*e939f3d1SIhor Solodrai #include <vmlinux.h> 5*e939f3d1SIhor Solodrai #include <bpf/bpf_helpers.h> 6*e939f3d1SIhor Solodrai #include "bpf_misc.h" 7*e939f3d1SIhor Solodrai 8*e939f3d1SIhor Solodrai extern int bpf_kfunc_implicit_arg(int a) __weak __ksym; 9*e939f3d1SIhor Solodrai extern int bpf_kfunc_implicit_arg_impl(int a, struct bpf_prog_aux *aux) __weak __ksym; /* illegal */ 10*e939f3d1SIhor Solodrai extern int bpf_kfunc_implicit_arg_legacy(int a, int b) __weak __ksym; 11*e939f3d1SIhor Solodrai extern int bpf_kfunc_implicit_arg_legacy_impl(int a, int b, struct bpf_prog_aux *aux) __weak __ksym; 12*e939f3d1SIhor Solodrai 13*e939f3d1SIhor Solodrai char _license[] SEC("license") = "GPL"; 14*e939f3d1SIhor Solodrai 15*e939f3d1SIhor Solodrai SEC("syscall") 16*e939f3d1SIhor Solodrai __retval(5) 17*e939f3d1SIhor Solodrai int test_kfunc_implicit_arg(void *ctx) 18*e939f3d1SIhor Solodrai { 19*e939f3d1SIhor Solodrai return bpf_kfunc_implicit_arg(5); 20*e939f3d1SIhor Solodrai } 21*e939f3d1SIhor Solodrai 22*e939f3d1SIhor Solodrai SEC("syscall") 23*e939f3d1SIhor Solodrai __failure __msg("cannot find address for kernel function bpf_kfunc_implicit_arg_impl") 24*e939f3d1SIhor Solodrai int test_kfunc_implicit_arg_impl_illegal(void *ctx) 25*e939f3d1SIhor Solodrai { 26*e939f3d1SIhor Solodrai return bpf_kfunc_implicit_arg_impl(5, NULL); 27*e939f3d1SIhor Solodrai } 28*e939f3d1SIhor Solodrai 29*e939f3d1SIhor Solodrai SEC("syscall") 30*e939f3d1SIhor Solodrai __retval(7) 31*e939f3d1SIhor Solodrai int test_kfunc_implicit_arg_legacy(void *ctx) 32*e939f3d1SIhor Solodrai { 33*e939f3d1SIhor Solodrai return bpf_kfunc_implicit_arg_legacy(3, 4); 34*e939f3d1SIhor Solodrai } 35*e939f3d1SIhor Solodrai 36*e939f3d1SIhor Solodrai SEC("syscall") 37*e939f3d1SIhor Solodrai __retval(11) 38*e939f3d1SIhor Solodrai int test_kfunc_implicit_arg_legacy_impl(void *ctx) 39*e939f3d1SIhor Solodrai { 40*e939f3d1SIhor Solodrai return bpf_kfunc_implicit_arg_legacy_impl(5, 6, NULL); 41*e939f3d1SIhor Solodrai } 42