lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 04 Mar 2021 11:46:27 +1100
From:   Michael Ellerman <mpe@...erman.id.au>
To:     "Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com>,
        Jiri Olsa <jolsa@...hat.com>
Cc:     Yonghong Song <yhs@...com>, Jiri Olsa <jolsa@...nel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andriin@...com>, netdev@...r.kernel.org,
        bpf@...r.kernel.org, Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...omium.org>,
        Toke Høiland-Jørgensen <toke@...hat.com>,
        Yauheni Kaliuta <ykaliuta@...hat.com>,
        Srikar Dronamraju <srikar@...ux.vnet.ibm.com>,
        Paul Mackerras <paulus@...ba.org>
Subject: Re: [PATCH bpf-next] selftests/bpf: Fix test_attach_probe for
 powerpc uprobes

"Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com> writes:
> 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@...nel.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__)
>
> 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.
>
>> > > +/*
>> > > + * 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

There's a comment in ppc_function_entry(), but I don't think we have any
actual "documentation".

static inline unsigned long ppc_function_entry(void *func)
{
#ifdef PPC64_ELF_ABI_v2
	u32 *insn = func;

	/*
	 * A PPC64 ABIv2 function may have a local and a global entry
	 * point. We need to use the local entry point when patching
	 * functions, so identify and step over the global entry point
	 * sequence.
	 *
	 * The global entry point sequence is always of the form:
	 *
	 * addis r2,r12,XXXX
	 * addi  r2,r2,XXXX
	 *
	 * A linker optimisation may convert the addis to lis:
	 *
	 * lis   r2,XXXX
	 * addi  r2,r2,XXXX
	 */
	if ((((*insn & OP_RT_RA_MASK) == ADDIS_R2_R12) ||
	     ((*insn & OP_RT_RA_MASK) == LIS_R2)) &&
	    ((*(insn+1) & OP_RT_RA_MASK) == ADDI_R2_R2))
		return (unsigned long)(insn + 2);
	else
		return (unsigned long)func;


cheers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ