The Linux Kernel Logo
6.16.0-rc1
  • eBPF verifier
  • libbpf
  • BPF Standardization
    • 1 BPF Instruction Set Architecture (ISA)
    • 1 BPF ABI Recommended Conventions and Guidelines v1.0
      • 1.1 Registers and calling convention
  • BPF Type Format (BTF)
  • Frequently asked questions (FAQ)
  • Syscall API
  • Helper functions
  • BPF Kernel Functions (kfuncs)
  • BPF cpumask kfuncs
  • BPF filesystem kfuncs
  • Program Types
  • BPF maps
  • Running BPF programs from userspace
  • Classic BPF vs eBPF
  • BPF Iterators
  • BPF licensing
  • Testing and debugging BPF
  • 1 Clang implementation notes
  • 1 Linux implementation notes
  • Other
  • Redirect
The Linux Kernel
  • BPF Standardization
  • 1 BPF ABI Recommended Conventions and Guidelines v1.0
  • View page source

Contents

  • 1 BPF ABI Recommended Conventions and Guidelines v1.0

    • 1.1 Registers and calling convention

1 BPF ABI Recommended Conventions and Guidelines v1.0¶

This is version 1.0 of an informational document containing recommended conventions and guidelines for producing portable BPF program binaries.

1.1 Registers and calling convention¶

BPF has 10 general purpose registers and a read-only frame pointer register, all of which are 64-bits wide.

The BPF calling convention is defined as:

  • R0: return value from function calls, and exit value for BPF programs

  • R1 - R5: arguments for function calls

  • R6 - R9: callee saved registers that function calls will preserve

  • R10: read-only frame pointer to access stack

R0 - R5 are scratch registers and BPF programs needs to spill/fill them if necessary across calls.

The BPF program needs to store the return value into register R0 before doing an EXIT.

Previous Next

© Copyright The kernel development community.

Built with Sphinx using a theme provided by Read the Docs.