summaryrefslogtreecommitdiffstats
path: root/Documentation/bpf/standardization/abi.rst
blob: 41514137cb7b84924caf2e7aaf0bd3598682c0b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
.. contents::
.. sectnum::

===================================================
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.

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``.