selftests/bpf: Add bpf_get_func_ip tests for uprobe on function entry

Adding get_func_ip tests for uprobe on function entry that
validates that bpf_get_func_ip returns proper values from
both uprobe and return uprobe.

Tested-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20230807085956.2344866-3-jolsa@kernel.org
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
This commit is contained in:
Jiri Olsa
2023-08-07 10:59:55 +02:00
committed by Martin KaFai Lau
parent a3c485a5d8
commit e43163ed1c
2 changed files with 34 additions and 2 deletions

View File

@@ -1,8 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/bpf.h>
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <stdbool.h>
char _license[] SEC("license") = "GPL";
@@ -83,3 +82,25 @@ int test6(struct pt_regs *ctx)
test6_result = (const void *) addr == 0;
return 0;
}
unsigned long uprobe_trigger;
__u64 test7_result = 0;
SEC("uprobe//proc/self/exe:uprobe_trigger")
int BPF_UPROBE(test7)
{
__u64 addr = bpf_get_func_ip(ctx);
test7_result = (const void *) addr == (const void *) uprobe_trigger;
return 0;
}
__u64 test8_result = 0;
SEC("uretprobe//proc/self/exe:uprobe_trigger")
int BPF_URETPROBE(test8, int ret)
{
__u64 addr = bpf_get_func_ip(ctx);
test8_result = (const void *) addr == (const void *) uprobe_trigger;
return 0;
}