From: Jiri Olsa <jolsa@redhat.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: "Jiri Olsa" <jolsa@kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andriin@fb.com>,
Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
"Martin KaFai Lau" <kafai@fb.com>,
"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"KP Singh" <kpsingh@chromium.org>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Yauheni Kaliuta" <ykaliuta@redhat.com>
Subject: Re: [PATCH bpf-next] selftests/bpf: Fix test_attach_probe for powerpc uprobes
Date: Tue, 2 Mar 2021 19:58:38 +0100 [thread overview]
Message-ID: <YD6K3nex6MQ09u8U@krava> (raw)
In-Reply-To: <CAEf4Bzah8Au01NvtwSogpkr3etwQ3_bObj3GObG8Lb3N0DqZwA@mail.gmail.com>
On Tue, Mar 02, 2021 at 10:31:41AM -0800, Andrii Nakryiko wrote:
> On Tue, Mar 2, 2021 at 3:14 AM Jiri Olsa <jolsa@redhat.com> wrote:
> >
> > On Mon, Mar 01, 2021 at 04:34:24PM -0800, Andrii Nakryiko wrote:
> > > On Mon, Mar 1, 2021 at 11:11 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > > >
> > > > 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)
> > >
> > > if we mark this function __weak global, would it work as is? Would it
> > > get an address of a global entry point? I know nothing about this GEP
> > > vs LEP stuff, interesting :)
> >
> > you mean get_base_addr? it's already global
> >
> > all the calls to get_base_addr within the object are made
> > to get_base_addr+0x8
> >
> > 00000000100350c0 <test_attach_probe>:
> > ...
> > 100350e0: 59 fd ff 4b bl 10034e38 <get_base_addr+0x8>
> > ...
> > 100358a8: 91 f5 ff 4b bl 10034e38 <get_base_addr+0x8>
> >
> >
> > I'm following perf fix we had for similar issue:
> > 7b6ff0bdbf4f perf probe ppc64le: Fixup function entry if using kallsyms lookup
> >
> > I'll get more info on that
>
> My thinking was that if you mark the function as __weak, then the
> compiler is not allowed to assume that the actual implementation of
> that function will come from the same object (because it might be
> replaced by the linker later), so it has to be pessimistic and use
> global entry, no? Totally theoritizing here, of course.
ah ok.. good idea, but it's still jumping to +8 in my test
# nm test_progs | grep get_base_addr
0000000010034e30 W get_base_addr
100350e0: 59 fd ff 4b bl 10034e38 <get_base_addr+0x8>
looks like it's linker, because compiler leaves just jump to next instruction
jirka
prev parent reply other threads:[~2021-03-03 4:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YD6K3nex6MQ09u8U@krava \
--to=jolsa@redhat.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=toke@redhat.com \
--cc=yhs@fb.com \
--cc=ykaliuta@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).