Re: [PATCH bpf-next] selftests/bpf: Fix test_attach_probe for powerpc uprobes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 03, 2021 at 12:10:43PM +0530, Naveen N. Rao wrote:
> On 2021/03/02 11:35AM, Jiri Olsa wrote:
> > On Mon, Mar 01, 2021 at 02:58:53PM -0800, Yonghong Song wrote:
> > > 
> > > 
> > > On 3/1/21 11:04 AM, Jiri Olsa 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@xxxxxxxxxx>
> > > > ---
> > > >   .../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__)
> 
> This needs to be specific to ELF v2 ABI, so you'll need to check 
> _CALL_ELF. See commit d5c2e2c17ae1d6 ("perf probe ppc64le: Prefer symbol 
> table lookup over DWARF") for an example.

i see, there's the outer #if _CALL_ELF I missed

> 
> > > > +/*
> > > > + * 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).
> > > 
> > > Any documentation in the kernel about this behavior? This will
> > > help to validate the change without trying with powerpc64 qemu...
> 
> I don't think we have documented this in the kernel anywhere, but this 
> is specific to the ELF v2 ABI and is described there:
> - 2.3.2.1.  Function Prologue: 
>   http://cdn.openpowerfoundation.org/wp-content/uploads/resources/leabi/content/dbdoclet.50655240___RefHeading___Toc377640597.html
> - 3.4.1.  Symbol Values:
>    http://cdn.openpowerfoundation.org/wp-content/uploads/resources/leabi/content/dbdoclet.50655241_95185.html
> 
> > 
> > we got similar fix in perf:
> > 
> > 7b6ff0bdbf4f perf probe ppc64le: Fixup function entry if using kallsyms lookup
> > 
> > CC-ing few other folks from ppc land for more info
> 
> Thanks.
> 
> > > 
> > > > + */
> > > > +#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"))
> > > > 
> 
> As documented in the links above, the right way to identify local entry 
> point (LEP) is by looking at the symbol table. Falling back to using a 
> hardcoded offset of 8 is a reasonable workaround if we don't have access 
> to the symbol table.

thanks for the all the info, I'll send v2 with _CALL_ELF check

jirka




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux