netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Andrii Nakryiko <andriin@fb.com>, bpf <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf 0/9] Fix various issues with 32-bit libbpf
Date: Thu, 13 Aug 2020 13:03:04 -0700	[thread overview]
Message-ID: <CAEf4BzaC7Jd4mg_ToXkm2eM2pxfXBEKxq_+pLkKKP-io4U6Fsw@mail.gmail.com> (raw)
In-Reply-To: <20200813192042.ntv6ybry6ck2s6jg@ast-mbp.dhcp.thefacebook.com>

On Thu, Aug 13, 2020 at 12:20 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Thu, Aug 13, 2020 at 12:17:13AM -0700, Andrii Nakryiko wrote:
> > This patch set contains fixes to libbpf, bpftool, and selftests that were
> > found while testing libbpf and selftests built in 32-bit mode. 64-bit nature
> > of BPF target and 32-bit host environment don't always mix together well
> > without extra care, so there were a bunch of problems discovered and fixed.
> >
> > Each individual patch contains additional explanations, where necessary.
> >
> > This series is really a mix of bpf tree fixes and patches that are better
> > landed into bpf-next, once it opens. This is due to a bit riskier changes and
> > new APIs added to allow solving this 32/64-bit mix problem. It would be great
> > to apply patches #1 through #3 to bpf tree right now, and the rest into
> > bpf-next, but I would appreciate reviewing all of them, of course.
>
> why first three only?
> I think btf__set_pointer_size() and friends are necessary in bpf tree.

I don't mind. The "scariest" change is bpftool's skeleton generation
change, so would be good if you double-check the logic of enforcing at
most 4 byte alignment. But it seems logically sound and safe to me.

> The only thing I would suggest is to rename guess_ptr_size() into
> determine_ptr_size() or something.
> It's not guessing it. Looking for 'long' in BTF is precise.

It was a guess only in the sense that it won't work for LLP64 model,
for instance. But that model is used on Windows platforms, it seems.
Linux sticks to ILP32 and LP64, both of which have sizeof(long) ==
sizeof(void *). I'll rename it to determine_ptr_sz() then.

> We can teach pahole and llvm to always emit 'long' type and libbpf can
> fail parsing BTF if 'long' is not found.

It's always the case for vmlinux BTF, so no need there. As for BPF .o
files, libbpf just enforces 64-bit pointer size anyways. So all
typical cases are covered reliably, I think. It's only for some
non-mainstream use cases where people want to use libbpf's BTF API for
some unconventional uses of BTF. I don't know any of such cases
besides our own selftests, but it's a generic library API, so who
knows :)

We also can do detection based on ELF target architecture, for
btf__parse_elf() API. btf__parse_raw() is a bit less lucky in that
regard.

      reply	other threads:[~2020-08-13 20:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13  7:17 [PATCH bpf 0/9] Fix various issues with 32-bit libbpf Andrii Nakryiko
2020-08-13  7:17 ` [PATCH bpf 1/9] tools/bpftool: fix compilation warnings in 32-bit mode Andrii Nakryiko
2020-08-13  7:17 ` [PATCH bpf 2/9] selftest/bpf: " Andrii Nakryiko
2020-08-13  7:17 ` [PATCH bpf 3/9] libbpf: fix BTF-defined map-in-map initialization on 32-bit host arches Andrii Nakryiko
2020-08-13  7:17 ` [PATCH bpf 4/9] libbpf: handle BTF pointer sizes more carefully Andrii Nakryiko
2020-08-13  7:17 ` [PATCH bpf 5/9] selftests/bpf: fix btf_dump test cases on 32-bit arches Andrii Nakryiko
2020-08-13  7:17 ` [PATCH bpf 6/9] libbpf: enforce 64-bitness of BTF for BPF object files Andrii Nakryiko
2020-08-13  7:17 ` [PATCH bpf 7/9] selftests/bpf: correct various core_reloc 64-bit assumptions Andrii Nakryiko
2020-08-13  7:17 ` [PATCH bpf 8/9] tools/bpftool: generate data section struct with conservative alignment Andrii Nakryiko
2020-08-13  7:17 ` [PATCH bpf 9/9] selftests/bpf: make test_varlen work with 32-bit user-space arch Andrii Nakryiko
2020-08-13 19:20 ` [PATCH bpf 0/9] Fix various issues with 32-bit libbpf Alexei Starovoitov
2020-08-13 20:03   ` 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=CAEf4BzaC7Jd4mg_ToXkm2eM2pxfXBEKxq_+pLkKKP-io4U6Fsw@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /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).