All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org, Networking <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Joe Stringer <joe@wand.net.nz>, Yonghong Song <yhs@fb.com>,
	Martin Lau <kafai@fb.com>, Jann Horn <jannh@google.com>,
	Andrey Ignatov <rdna@fb.com>
Subject: Re: [PATCH bpf-next v6 11/16] bpf, libbpf: support global data/bss/rodata sections
Date: Mon, 22 Apr 2019 21:06:07 -0700	[thread overview]
Message-ID: <CAEf4BzbYZAsNkVkYddws7inyFkFGmwkQ9Yb0G2hUdw_5Kufgaw@mail.gmail.com> (raw)
In-Reply-To: <82026bc1-066d-9779-ec3a-83e086fc1780@iogearbox.net>

On Mon, Apr 22, 2019 at 5:58 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 04/19/2019 03:18 AM, Andrii Nakryiko wrote:
> > On Tue, Apr 9, 2019 at 2:20 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
> >>
> [...]
> >> +       def->type = BPF_MAP_TYPE_ARRAY;
> >> +       def->key_size = sizeof(int);
> >> +       def->value_size = data->d_size;
> >> +       def->max_entries = 1;
> >> +       def->map_flags = type == LIBBPF_MAP_RODATA ?
> >> +                        BPF_F_RDONLY_PROG : 0;
> >
> > This is breaking BPF programs (even those that don't use global data,
> > as they still have .rodata section, though I haven't investigated its
> > contents) on kernels that don't yet support BPF_F_RDONLY_PROG flag
> > yet. We probably need to probe support for that flag first, before
> > using it. Just giving heads up, as I just discovered it trying to sync
> > libbpf on github.
>
> Thanks for reporting! On a quick look test_progs (modulo global data test)
> seems to pass with an slightly older kernel. I'll retry with a latest LLVM git
> tree tomorrow with our test suite. Did you see a specific one failing or do you
> have a reproducer in case it's something not covered where I could look into?

You need to add something like this to trigger .rodata section
generation (BPF code doesn't have to use that struct, it just needs to
be present):

const struct { int x, y; } bla = {};

This will cause libbpf to create a map for .rodata and specify
BPF_F_RDONLY_PROG flag, which on older kernels will be rejected.

  reply	other threads:[~2019-04-23  4:06 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 21:20 [PATCH bpf-next v6 00/16] BPF support for global data Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 01/16] bpf: implement lookup-free direct value access for maps Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 02/16] bpf: do not retain flags that are not tied to map lifetime Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 03/16] bpf: add program side {rd, wr}only support for maps Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 04/16] bpf: add syscall side map freeze support Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 05/16] bpf: allow . char as part of the object name Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 06/16] bpf: add specification for BTF Var and DataSec kinds Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 07/16] bpf: kernel side support for BTF Var and DataSec Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 08/16] bpf: allow for key-less BTF in array map Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 09/16] bpf: sync {btf, bpf}.h uapi header from tools infrastructure Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 10/16] bpf, libbpf: refactor relocation handling Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 11/16] bpf, libbpf: support global data/bss/rodata sections Daniel Borkmann
2019-04-19  1:18   ` Andrii Nakryiko
2019-04-23  0:35     ` Daniel Borkmann
2019-04-23  4:06       ` Andrii Nakryiko [this message]
2019-04-23  8:31         ` Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 12/16] bpf, libbpf: add support for BTF Var and DataSec Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 13/16] bpf: bpftool support for dumping data/bss/rodata sections Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 14/16] bpf, selftest: test {rd, wr}only flags and direct value access Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 15/16] bpf, selftest: test global data/bss/rodata sections Daniel Borkmann
2019-04-09 21:20 ` [PATCH bpf-next v6 16/16] bpf, selftest: add test cases for BTF Var and DataSec Daniel Borkmann

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=CAEf4BzbYZAsNkVkYddws7inyFkFGmwkQ9Yb0G2hUdw_5Kufgaw@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jannh@google.com \
    --cc=joe@wand.net.nz \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=rdna@fb.com \
    --cc=yhs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.