public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Yonghong Song <yonghong.song@linux.dev>, bpf <bpf@vger.kernel.org>
Subject: Re: GCC and binutils support for BPF V4 instructions
Date: Sun, 30 Jul 2023 23:06:30 +0200	[thread overview]
Message-ID: <87edkpkt2h.fsf@oracle.com> (raw)
In-Reply-To: <CAADnVQ+gLXpeY-kOJ_cEAuoXkrQeeD+KL6jsFfyDXcm+rk-xmg@mail.gmail.com> (Alexei Starovoitov's message of "Sun, 30 Jul 2023 09:53:51 -0700")


> On Sat, Jul 29, 2023 at 9:54 PM Jose E. Marchesi
> <jose.marchesi@oracle.com> wrote:
>>
>> The individual flags... I am not sure, other arches have them, but maybe
>> having them in BPF doesn't make much sense and it is not worth the extra
>> complication and wasted bits in e_flags.  How realistic is to expect
>> that some kernel may support a particular version of the BPF ISA, and
>> also have support for some particular instruction from a later ISA as
>> the result of a backport or something?  Not for me to judge... I was
>> already bitten by my utter ignorance on kernel business when I added
>> that silly useless -mkernel=VERSION option to GCC 8-)
>>
>> What I am pretty sure is that we will need something like EF_BPF_CPUVER
>> if we are ever gonna support relaxation in any linker external to
>> libbpf, and also to detect (and error/warn) when several objects with
>> different BPF versions are linked together.
>
> Ok. Let's start with EF_BPF_CPUVER 0xF
> and not waste bits on individual instructions, as you said.
> When kernel backports are done the patches are sent together.
> It wouldn't be wise to backport SDIV without JMP32, for example.
> git history will get screwed up and further backports will be a pain.
> The risk of untested combinations increases, etc.
> I think it's safe to assume that a given kernel will support either v3
> or v4.

This is good to know.  Thanks for explaining.

> The kernel version doesn't matter, of course :)

Yeah GCC no longer supports -mkernel :P

Allright, so I just pushed a binutils patch for elf.h, the disassembler,
the assembler and readelf:

  https://sourceware.org/pipermail/binutils/2023-July/128723.html

Note that the ISA version selection logic in the disassembler is:

1. If the user specifies an explicit version (v1, v2, v3, v4) then use
   it.

2. Otherwise, use the EF_BPF_CPUVER bits in the ELF header to derive the
   version to use:

   2.1. If the CPUVER is zero, then use the latest supported version
        (currently v4).  This is for backwards compability.

   2.2. Else, if CPUVER is one of the supported versions by the
        disassembler (currently 1, 2, 3 or 4) then use it.

   2.3. Else, emit an error "unknown BPF CPU version %d".

Maybe 2.3 should be a warning instead of an error...

  reply	other threads:[~2023-07-30 21:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-28 16:41 GCC and binutils support for BPF V4 instructions Jose E. Marchesi
2023-07-28 16:47 ` Alexei Starovoitov
2023-07-28 17:06   ` Jose E. Marchesi
2023-07-28 16:59 ` Yonghong Song
2023-07-28 17:40   ` Jose E. Marchesi
2023-07-28 18:01     ` Jose E. Marchesi
2023-07-28 23:49       ` Alexei Starovoitov
2023-07-29  8:29         ` Jose E. Marchesi
2023-07-29 17:56           ` Alexei Starovoitov
2023-07-30  4:54             ` Jose E. Marchesi
2023-07-30 16:12               ` Yonghong Song
2023-07-30 19:11                 ` Jose E. Marchesi
2023-07-30 16:53               ` Alexei Starovoitov
2023-07-30 21:06                 ` Jose E. Marchesi [this message]
2023-07-31 18:10                   ` Alexei Starovoitov

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=87edkpkt2h.fsf@oracle.com \
    --to=jose.marchesi@oracle.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=yonghong.song@linux.dev \
    /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