Commit 3b2ec214 authored by Alexei Starovoitov's avatar Alexei Starovoitov Committed by Andrii Nakryiko

selftests/bpf: Add light skeleton test for kfunc detection.

Add light skeleton test for kfunc detection and denylist it for s390.
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230321203854.3035-5-alexei.starovoitov@gmail.com
parent 708cdc57
...@@ -11,6 +11,7 @@ get_stack_raw_tp # user_stack corrupted user stack ...@@ -11,6 +11,7 @@ get_stack_raw_tp # user_stack corrupted user stack
iters/testmod_seq* # s390x doesn't support kfuncs in modules yet iters/testmod_seq* # s390x doesn't support kfuncs in modules yet
kprobe_multi_bench_attach # bpf_program__attach_kprobe_multi_opts unexpected error: -95 kprobe_multi_bench_attach # bpf_program__attach_kprobe_multi_opts unexpected error: -95
kprobe_multi_test # relies on fentry kprobe_multi_test # relies on fentry
ksyms_btf/weak_ksyms* # test_ksyms_weak__open_and_load unexpected error: -22 (kfunc)
ksyms_module # test_ksyms_module__open_and_load unexpected error: -9 (?) ksyms_module # test_ksyms_module__open_and_load unexpected error: -9 (?)
ksyms_module_libbpf # JIT does not support calling kernel function (kfunc) ksyms_module_libbpf # JIT does not support calling kernel function (kfunc)
ksyms_module_lskel # test_ksyms_module_lskel__open_and_load unexpected error: -9 (?) ksyms_module_lskel # test_ksyms_module_lskel__open_and_load unexpected error: -9 (?)
......
...@@ -20,6 +20,8 @@ __u64 out__non_existent_typed = -1; ...@@ -20,6 +20,8 @@ __u64 out__non_existent_typed = -1;
/* test existing weak symbols can be resolved. */ /* test existing weak symbols can be resolved. */
extern const struct rq runqueues __ksym __weak; /* typed */ extern const struct rq runqueues __ksym __weak; /* typed */
extern const void bpf_prog_active __ksym __weak; /* typeless */ extern const void bpf_prog_active __ksym __weak; /* typeless */
struct task_struct *bpf_task_acquire(struct task_struct *p) __ksym __weak;
void bpf_testmod_test_mod_kfunc(int i) __ksym __weak;
/* non-existent weak symbols. */ /* non-existent weak symbols. */
...@@ -29,6 +31,7 @@ extern const void bpf_link_fops1 __ksym __weak; ...@@ -29,6 +31,7 @@ extern const void bpf_link_fops1 __ksym __weak;
/* typed symbols, default to zero. */ /* typed symbols, default to zero. */
extern const int bpf_link_fops2 __ksym __weak; extern const int bpf_link_fops2 __ksym __weak;
void invalid_kfunc(void) __ksym __weak;
SEC("raw_tp/sys_enter") SEC("raw_tp/sys_enter")
int pass_handler(const void *ctx) int pass_handler(const void *ctx)
...@@ -50,6 +53,18 @@ int pass_handler(const void *ctx) ...@@ -50,6 +53,18 @@ int pass_handler(const void *ctx)
if (&bpf_link_fops2) /* can't happen */ if (&bpf_link_fops2) /* can't happen */
out__non_existent_typed = (__u64)bpf_per_cpu_ptr(&bpf_link_fops2, 0); out__non_existent_typed = (__u64)bpf_per_cpu_ptr(&bpf_link_fops2, 0);
if (!bpf_ksym_exists(bpf_task_acquire))
/* dead code won't be seen by the verifier */
bpf_task_acquire(0);
if (!bpf_ksym_exists(bpf_testmod_test_mod_kfunc))
/* dead code won't be seen by the verifier */
bpf_testmod_test_mod_kfunc(0);
if (bpf_ksym_exists(invalid_kfunc))
/* dead code won't be seen by the verifier */
invalid_kfunc();
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment