bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Fix test_attach_probe for powerpc uprobes
@ 2021-03-01 19:04 Jiri Olsa
  2021-03-01 22:58 ` Yonghong Song
  2021-03-02  0:34 ` Andrii Nakryiko
  0 siblings, 2 replies; 15+ messages in thread
From: Jiri Olsa @ 2021-03-01 19:04 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: netdev, bpf, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Toke Høiland-Jørgensen,
	Yauheni Kaliuta

When testing uprobes we the test gets GEP (Global Entry Point)
address from kallsyms, but then the function is called locally
so the uprobe is not triggered.

Fixing this by adjusting the address to LEP (Local Entry Point)
for powerpc arch.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 .../selftests/bpf/prog_tests/attach_probe.c    | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
index a0ee87c8e1ea..c3cfb48d3ed0 100644
--- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c
+++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
@@ -2,6 +2,22 @@
 #include <test_progs.h>
 #include "test_attach_probe.skel.h"
 
+#if defined(__powerpc64__)
+/*
+ * We get the GEP (Global Entry Point) address from kallsyms,
+ * but then the function is called locally, so we need to adjust
+ * the address to get LEP (Local Entry Point).
+ */
+#define LEP_OFFSET 8
+
+static ssize_t get_offset(ssize_t offset)
+{
+	return offset + LEP_OFFSET;
+}
+#else
+#define get_offset(offset) (offset)
+#endif
+
 ssize_t get_base_addr() {
 	size_t start, offset;
 	char buf[256];
@@ -36,7 +52,7 @@ void test_attach_probe(void)
 	if (CHECK(base_addr < 0, "get_base_addr",
 		  "failed to find base addr: %zd", base_addr))
 		return;
-	uprobe_offset = (size_t)&get_base_addr - base_addr;
+	uprobe_offset = get_offset((size_t)&get_base_addr - base_addr);
 
 	skel = test_attach_probe__open_and_load();
 	if (CHECK(!skel, "skel_open", "failed to open skeleton\n"))
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-03-05 13:39 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 19:04 [PATCH bpf-next] selftests/bpf: Fix test_attach_probe for powerpc uprobes Jiri Olsa
2021-03-01 22:58 ` Yonghong Song
2021-03-02 10:35   ` Jiri Olsa
2021-03-03  6:40     ` Naveen N. Rao
2021-03-03 22:49       ` Jiri Olsa
2021-03-04  0:46       ` Michael Ellerman
2021-03-04 15:55         ` Jiri Olsa
2021-03-04  1:34           ` Naveen N. Rao
2021-03-05 13:38             ` Jiri Olsa
2021-03-02  0:34 ` Andrii Nakryiko
2021-03-02 11:14   ` Jiri Olsa
2021-03-02 17:19     ` Yonghong Song
2021-03-03  6:42       ` Naveen N. Rao
2021-03-02 18:31     ` Andrii Nakryiko
2021-03-02 18:58       ` Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).