BPF List
 help / color / mirror / Atom feed
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	bpf <bpf@vger.kernel.org>
Subject: Re: EF_BPF_GNU_XBPF
Date: Thu, 03 Sep 2020 00:10:07 +0200	[thread overview]
Message-ID: <87k0xb25kw.fsf@oracle.com> (raw)
In-Reply-To: <d0a6eb38-76a4-b335-878b-647fe68f937a@iogearbox.net> (Daniel Borkmann's message of "Wed, 2 Sep 2020 23:33:17 +0200")


Hi Daniel.

>>>> As such, the property of being verifiable is irrelevant.
>>>
>>> No. It's a fundamental property of BPF.
>>> If it's not verifiable it's not BPF.
>> Sure.
>> 
>>> It's not xBPF either.
>> Heh, beg to differ :)
>> 
>>> Please call it something else and don't confuse people that your ISA
>>> has any overlap with BPF. It doesn't. It's not verifiable.
>> Nonsense.  xBPF has as much overlap with BPF as it can have: around
>> 99%.
>> The purpose of having the e_flag is to avoid confusion, not to
>> increase
>> it.  xBPF objects are mainly used to test the GCC BPF backend (and other
>> purposes we have in mind, like ease the debugging of BPF programs) but
>> we want to eliminate the chance of these objects to be confused with
>> legit BPF files, and used as such.
>
> I fully agree with Alexei. Looking at [0], if some of these extensions are
> useful and help/optimize code generation, why not add them to the BPF runtime
> in the kernel so they can be properly used in general for code generation
> from gcc/llvm in BPF backend?

The reasons why xBPF came to existence are:

1) Due to BPF being so restrictive, many hundreds of GCC tests won't
   even build, because they use functions having more than 5 arguments,
   or functions with too big stack frames, or indirect calls, etc.  We
   want to be able to test our backend properly, so we added the -mxbpf
   option in order to relax some of these restrictions.

2) We are working on a BPF simulator that works with GDB.  For that to
   work, we needed to add a "breakpoint" instruction that GDB can patch
   in the program.  Having a simulator also allows us to run more GCC
   tests.

3) With some extensions, it becomes possible to support DWARF call frame
   information, and therefore to debug BPF programs in GDB with
   unwinding support.  You can build with -mxbpf, debug, then build
   again without -mxbpf.

[We have received messages from people saying that a more relaxed
 variant of BPF would be useful in some userland contexts, and xbpf
 could certainly be used for that, but that's secondary.]

So, xBPF is mainly about compiler validation and debugging of BPF
programs.  It is not about helping with code optimization, and the
extensions it implements are clearly unsuitable for the kernel.

That's why it is important to clearly flag the ELF files that make use
of these extensions, and therefore our intention of using a bit in
e_flags for that purpose, and this thread.

The LLVM backend could also benefit from xBPF, for exactly the same
reasons than GCC.  In fact, right now the LLVM backend generates
non-conforming BPF instructions under certain circumstances, and the
resulting (invalid) objects are not annotated at all.

> xBPF would indeed be highly confusing if it cannot be used from the
> runtime (unless these are properly integrated into the kernel,
> verified and thus become a fixed part of eBPF ISA).
>
>   [0] https://linuxplumbersconf.org/event/7/contributions/724/attachments/636/1166/bpf.pdf

My intention was to discuss about these matters during LPC in the
Toolchain MC:

https://linuxplumbersconf.org/event/7/contributions/752/attachments/689/1288/toolchain-MC-bpf-discussion.pdf

Unfortunately no BPF people were present during the session, probably
because of scheduling, but we can do so via email.

We just want to provide good tools to you people :)

  reply	other threads:[~2020-09-02 22:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-02 18:18 EF_BPF_GNU_XBPF Jose E. Marchesi
2020-09-02 19:31 ` EF_BPF_GNU_XBPF Alexei Starovoitov
2020-09-02 20:19   ` EF_BPF_GNU_XBPF Jose E. Marchesi
2020-09-02 20:32     ` EF_BPF_GNU_XBPF Alexei Starovoitov
2020-09-02 21:17       ` EF_BPF_GNU_XBPF Jose E. Marchesi
2020-09-02 21:33         ` EF_BPF_GNU_XBPF Daniel Borkmann
2020-09-02 22:10           ` Jose E. Marchesi [this message]
2020-09-02 23:22             ` EF_BPF_GNU_XBPF David Miller
2020-09-02 23:40               ` EF_BPF_GNU_XBPF Jose E. Marchesi
2020-09-02 23:20           ` EF_BPF_GNU_XBPF David Miller
2020-09-02 23:18       ` EF_BPF_GNU_XBPF David Miller
2020-09-02 23:27         ` EF_BPF_GNU_XBPF Jose E. Marchesi

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=87k0xb25kw.fsf@oracle.com \
    --to=jose.marchesi@oracle.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    /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