summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/get_func_ip_test.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2021-07-14 11:44:00 +0200
committerAlexei Starovoitov <ast@kernel.org>2021-07-15 17:59:23 -0700
commit8237e75420897a4bf9b38b67cd243331bbd96a01 (patch)
tree4c31210d0e19c5a633a6ebc298aa7aa63485fb58 /tools/testing/selftests/bpf/progs/get_func_ip_test.c
parenta2488b5f483f18e6e34be2a15eb4a79f4a0d8728 (diff)
selftests/bpf: Add test for bpf_get_func_ip in kprobe+offset probe
Adding test for bpf_get_func_ip in kprobe+ofset probe. Because of the offset value it's arch specific, enabling the new test only for x86_64 architecture. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20210714094400.396467-9-jolsa@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/progs/get_func_ip_test.c')
-rw-r--r--tools/testing/selftests/bpf/progs/get_func_ip_test.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/get_func_ip_test.c b/tools/testing/selftests/bpf/progs/get_func_ip_test.c
index ba3e107b52dd..acd587b6e859 100644
--- a/tools/testing/selftests/bpf/progs/get_func_ip_test.c
+++ b/tools/testing/selftests/bpf/progs/get_func_ip_test.c
@@ -10,6 +10,7 @@ extern const void bpf_fentry_test2 __ksym;
extern const void bpf_fentry_test3 __ksym;
extern const void bpf_fentry_test4 __ksym;
extern const void bpf_modify_return_test __ksym;
+extern const void bpf_fentry_test6 __ksym;
__u64 test1_result = 0;
SEC("fentry/bpf_fentry_test1")
@@ -60,3 +61,13 @@ int BPF_PROG(test5, int a, int *b, int ret)
test5_result = (const void *) addr == &bpf_modify_return_test;
return ret;
}
+
+__u64 test6_result = 0;
+SEC("kprobe/bpf_fentry_test6+0x5")
+int test6(struct pt_regs *ctx)
+{
+ __u64 addr = bpf_get_func_ip(ctx);
+
+ test6_result = (const void *) addr == &bpf_fentry_test6 + 5;
+ return 0;
+}