20-24 September 2021
US/Pacific timezone

Update on BPF support in the GNU Toolchain

20 Sep 2021, 10:15
GNU Tools track/Virtual-Room (LPC Virtual)

GNU Tools track/Virtual-Room

LPC Virtual

GNU Tools Track GNU Tools Track


Jose E. Marchesi (GNU Project, Oracle Inc.) David FaustMr Guillermo Martinez (Oracle)


BPF is a virtual machine that resides in the Linux kernel. Initially intended for user-level packet capture and filtering, BPF is nowadays generalized to serve as a general-purpose infrastructure also for non-networking purposes. BPF programs are often written manually, directly in assembly instructions. However, people often want to write their BPF programs in C. We recently added support for this virtual architecture to the GNU Toolchain, to complement the already existing support in LLVM.

In this talk we will first be showing and discussing the latest developments related to this peculiar target. This includes the support for new instructions, atomics, architecture versioning, the BTF debugging format, and the support for the CO-RE (Compile-once, Run-Everywhere) mechanism in GCC, that allows to compile binary BPF programs that are portable between several kernel versions. Then we will show several on-going efforts, such as the addition of a verifier-aware testsuite to GCC (using a command-line access to the kernel verifier).

Finally, we will be addressing a very interesting problem that is arising in this field of compiled BPF. In this model where C code is processed by an optimizing compiler to generate assembly, and then checked by a run-time always-changing verifier, driven by delicate heuristics, it can be very difficult to predict the behavior of the later just by looking at the C code, in non-trivial cases. This can be very frustrating, as our own in-house experience with DTrace2 demonstrates. We have identified some particular language constructs (like loops) and compiler optimization passes that are most prone to lead to this situation.

I agree to abide by the anti-harassment policy I agree

Primary authors

Jose E. Marchesi (GNU Project, Oracle Inc.) David Faust Mr Guillermo Martinez (Oracle)

Presentation Materials