bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: Andrii Nakryiko <andrii@kernel.org>, bpf <bpf@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>,
	Dave Marchevsky <davemarchevsky@fb.com>
Subject: Re: [PATCH bpf-next 7/7] selftests/bpf: add urandom_read shared lib and USDTs
Date: Fri, 1 Apr 2022 09:59:13 -0700	[thread overview]
Message-ID: <CAEf4BzYzwmwcRNkUywz_JW0LMCSgDB=D7ee9i19q6xN2QkekMQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.LRH.2.23.451.2203312310230.18524@MyRouter>

On Thu, Mar 31, 2022 at 3:14 PM Alan Maguire <alan.maguire@oracle.com> wrote:
>
> On Fri, 25 Mar 2022, Andrii Nakryiko wrote:
>
> > Extend urandom_read helper binary to include USDTs of 4 combinations:
> > semaphore/semaphoreless (refcounted and non-refcounted) and based in
> > executable or shared library. We also extend urandom_read with ability
> > to report it's own PID to parent process and wait for parent process to
> > ready itself up for tracing urandom_read. We utilize popen() and
> > underlying pipe properties for proper signaling.
> >
> > Once urandom_read is ready, we add few tests to validate that libbpf's
> > USDT attachment handles all the above combinations of semaphore (or lack
> > of it) and static or shared library USDTs. Also, we validate that libbpf
> > handles shared libraries both with PID filter and without one (i.e., -1
> > for PID argument).
> >
> > Having the shared library case tested with and without PID is important
> > because internal logic differs on kernels that don't support BPF
> > cookies. On such older kernels, attaching to USDTs in shared libraries
> > without specifying concrete PID doesn't work in principle, because it's
> > impossible to determine shared library's load address to derive absolute
> > IPs for uprobe attachments. Without absolute IPs, it's impossible to
> > perform correct look up of USDT spec based on uprobe's absolute IP (the
> > only kind available from BPF at runtime). This is not the problem on
> > newer kernels with BPF cookie as we don't need IP-to-ID lookup because
> > BPF cookie value *is* spec ID.
> >
> > So having those two situations as separate subtests is good because
> > libbpf CI is able to test latest selftests against old kernels (e.g.,
> > 4.9 and 5.5), so we'll be able to disable PID-less shared lib attachment
> > for old kernels, but will still leave PID-specific one enabled to validate
> > this legacy logic is working correctly.
> >
> > Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
>
>
> haven't looked at this in depth yet, but hit a compilation error on
> aarch64:
>
>   LIB      liburandom_read.so
> /usr/bin/ld: /tmp/ccNy8cuv.o: relocation R_AARCH64_ADR_PREL_PG_HI21
> against symbol `urandlib_read_with_sema_semaphore' which may bind
> externally can not be used when making a shared object; recompile with
> -fPIC
> /tmp/ccNy8cuv.o: In function `urandlib_read_with_sema':
> /home/opc/src/bpf-next/tools/testing/selftests/bpf/urandom_read_lib1.c:12:(.text+0x10):
> dangerous relocation: unsupported relocation
> collect2: error: ld returned 1 exit status
> make: *** [Makefile:173:
> /home/opc/src/bpf-next/tools/testing/selftests/bpf/liburandom_read.so]
> Error 1
>
> following did fix it:
>
> diff --git a/tools/testing/selftests/bpf/Makefile
> b/tools/testing/selftests/bpf/Makefile
> index 58da22c019a8..c89e2948276b 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -170,7 +170,7 @@ $(OUTPUT)/%:%.c
>
>  $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c
>         $(call msg,LIB,,$@)
> -       $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) --shared -o $@
> +       $(Q)$(CC) $(CFLAGS) -fPIC $(LDFLAGS) $^ $(LDLIBS) --shared -o $@
>

Yep, forgot about -fPIC, thanks. Curious that it still works on x86 just fine :)

BTW, if you are interested in arm architecture, it would be great to
get some help to setup CI for ARMs. We have s390x and x86_64, it's a
great way to prevent lots of bugs. We just don't have anyone actively
supporting this for ARMs.

>  $(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c
> $(OUTPUT)/liburandom_read.so
>         $(call msg,BINARY,,$@)
>

      reply	other threads:[~2022-04-01 16:59 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-25  5:29 [PATCH bpf-next 0/7] Add libbpf support for USDTs Andrii Nakryiko
2022-03-25  5:29 ` [PATCH bpf-next 1/7] libbpf: add BPF-side of USDT support Andrii Nakryiko
2022-03-30  3:10   ` Hengqi Chen
2022-03-30 15:22     ` Hengqi Chen
2022-03-31  5:44       ` Andrii Nakryiko
2022-03-30 15:36     ` Hengqi Chen
2022-03-31  5:48       ` Andrii Nakryiko
2022-03-31  5:44     ` Andrii Nakryiko
2022-03-31 11:30   ` Alan Maguire
2022-03-31 18:49     ` Andrii Nakryiko
2022-03-31 20:52       ` Andrii Nakryiko
2022-03-31 18:34   ` program local storage. Was: " Alexei Starovoitov
2022-03-31 20:13     ` Andrii Nakryiko
2022-04-01  0:38       ` Alexei Starovoitov
2022-04-01 16:56         ` Andrii Nakryiko
2022-03-25  5:29 ` [PATCH bpf-next 2/7] libbpf: wire up USDT API and bpf_link integration Andrii Nakryiko
2022-03-30  3:24   ` Hengqi Chen
2022-03-31  5:56     ` Andrii Nakryiko
2022-03-31 12:13   ` Alan Maguire
2022-03-31 19:02     ` Andrii Nakryiko
2022-03-25  5:29 ` [PATCH bpf-next 3/7] libbpf: add USDT notes parsing and resolution logic Andrii Nakryiko
2022-03-31 13:37   ` Alan Maguire
2022-03-31 19:13     ` Andrii Nakryiko
2022-03-25  5:29 ` [PATCH bpf-next 4/7] libbpf: wire up spec management and other arch-independent USDT logic Andrii Nakryiko
2022-03-31 14:49   ` Alan Maguire
2022-03-31 19:16     ` Andrii Nakryiko
2022-03-25  5:29 ` [PATCH bpf-next 5/7] libbpf: add x86-specific USDT arg spec parsing logic Andrii Nakryiko
2022-03-31 15:13   ` Alan Maguire
2022-03-31 19:20     ` Andrii Nakryiko
2022-03-25  5:29 ` [PATCH bpf-next 6/7] selftests/bpf: add basic USDT selftests Andrii Nakryiko
2022-03-31 15:54   ` Alan Maguire
2022-03-31 19:28     ` Andrii Nakryiko
2022-03-25  5:29 ` [PATCH bpf-next 7/7] selftests/bpf: add urandom_read shared lib and USDTs Andrii Nakryiko
2022-03-31 22:13   ` Alan Maguire
2022-04-01 16:59     ` Andrii Nakryiko [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='CAEf4BzYzwmwcRNkUywz_JW0LMCSgDB=D7ee9i19q6xN2QkekMQ@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davemarchevsky@fb.com \
    --cc=kernel-team@fb.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).