@@ -14,8 +14,10 @@ Versions
14
14
The current Instruction Set Architecture (ISA) version, sometimes referred to in other documents
15
15
as a "CPU" version, is 3. This document also covers older versions of the ISA.
16
16
17
- *Clang implementation note *: Clang can select the eBPF ISA version using
18
- ``-mcpu=v2 `` for example to select version 2.
17
+ **Note **
18
+
19
+ *Clang implementation *: Clang can select the eBPF ISA version using
20
+ ``-mcpu=v2 `` for example to select version 2.
19
21
20
22
Registers and calling convention
21
23
================================
@@ -37,18 +39,22 @@ that the value in the register is moved to the BPF stack. The reverse operation
37
39
of moving the variable from the BPF stack to the register is called filling.
38
40
The reason for spilling/filling is due to the limited number of registers.
39
41
40
- *Linux implementation note *: In the Linux kernel, the exit value for eBPF
41
- programs is passed as a 32 bit value.
42
+ **Note **
43
+
44
+ *Linux implementation *: In the Linux kernel, the exit value for eBPF
45
+ programs is passed as a 32 bit value.
42
46
43
47
Upon entering execution of an eBPF program, registers R1 - R5 initially can contain
44
48
the input arguments for the program (similar to the argc/argv pair for a typical C program).
45
49
The actual number of registers used, and their meaning, is defined by the program type;
46
50
for example, a networking program might have an argument that includes network packet data
47
51
and/or metadata.
48
52
49
- *Linux implementation note *: In the Linux kernel, all program types only use
50
- R1 which contains the "context", which is typically a structure containing all
51
- the inputs needed.
53
+ **Note **
54
+
55
+ *Linux implementation *: In the Linux kernel, all program types only use
56
+ R1 which contains the "context", which is typically a structure containing all
57
+ the inputs needed.
52
58
53
59
Instruction encoding
54
60
====================
@@ -162,9 +168,11 @@ otherwise identical operations.
162
168
Support for ``BPF_ALU `` is required in ISA version 3, and optional in earlier
163
169
versions.
164
170
165
- *Clang implementation note *:
166
- For ISA versions prior to 3, Clang v7.0 and later can enable ``BPF_ALU `` support with
167
- ``-Xclang -target-feature -Xclang +alu32 ``.
171
+ **Note **
172
+
173
+ *Clang implementation *:
174
+ For ISA versions prior to 3, Clang v7.0 and later can enable ``BPF_ALU `` support with
175
+ ``-Xclang -target-feature -Xclang +alu32 ``.
168
176
169
177
The 4-bit 'code' field encodes the operation as follows:
170
178
@@ -202,9 +210,11 @@ Examples:
202
210
203
211
where '(uint32_t)' indicates truncation to 32 bits.
204
212
205
- *Linux implementation note *: In the Linux kernel, uint32_t is expressed as u32,
206
- uint64_t is expressed as u64, etc. This document uses the standard C terminology
207
- as the cross-platform specification.
213
+ **Note **
214
+
215
+ *Linux implementation *: In the Linux kernel, uint32_t is expressed as u32,
216
+ uint64_t is expressed as u64, etc. This document uses the standard C terminology
217
+ as the cross-platform specification.
208
218
209
219
``BPF_ADD | BPF_X | BPF_ALU64 `` (0x0f) means::
210
220
@@ -239,9 +249,11 @@ used to select what byte order the operation converts from or to:
239
249
BPF_TO_BE 0x08 convert between host byte order and big endian
240
250
========= ===== =================================================
241
251
242
- *Linux implementation note *:
243
- ``BPF_FROM_LE `` and ``BPF_FROM_BE `` exist as aliases for ``BPF_TO_LE `` and
244
- ``BPF_TO_BE `` respectively.
252
+ **Note **
253
+
254
+ *Linux implementation *:
255
+ ``BPF_FROM_LE `` and ``BPF_FROM_BE `` exist as aliases for ``BPF_TO_LE `` and
256
+ ``BPF_TO_BE `` respectively.
245
257
246
258
The 'imm' field encodes the width of the swap operations. The following widths
247
259
are supported: 16, 32 and 64. The following table summarizes the resulting
@@ -443,12 +455,14 @@ The ``BPF_CMPXCHG`` operation atomically compares the value addressed by
443
455
value that was at ``dst + offset `` before the operation is zero-extended
444
456
and loaded back to ``R0 ``.
445
457
446
- *Clang implementation note *:
447
- Clang can generate atomic instructions by default when ``-mcpu=v3 `` is
448
- enabled. If a lower version for ``-mcpu `` is set, the only atomic instruction
449
- Clang can generate is ``BPF_ADD `` *without * ``BPF_FETCH ``. If you need to enable
450
- the atomics features, while keeping a lower ``-mcpu `` version, you can use
451
- ``-Xclang -target-feature -Xclang +alu32 ``.
458
+ **Note **
459
+
460
+ *Clang implementation *:
461
+ Clang can generate atomic instructions by default when ``-mcpu=v3 `` is
462
+ enabled. If a lower version for ``-mcpu `` is set, the only atomic instruction
463
+ Clang can generate is ``BPF_ADD `` *without * ``BPF_FETCH ``. If you need to enable
464
+ the atomics features, while keeping a lower ``-mcpu `` version, you can use
465
+ ``-Xclang -target-feature -Xclang +alu32 ``.
452
466
453
467
64-bit immediate instructions
454
468
-----------------------------
@@ -488,7 +502,9 @@ These instructions have seven implicit operands:
488
502
* Registers R1-R5 are scratch registers that are clobbered by the
489
503
instruction.
490
504
491
- *Linux implementation note *: In Linux, R6 references a struct sk_buff.
505
+ **Note **
506
+
507
+ *Linux implementation *: In Linux, R6 references a struct sk_buff.
492
508
493
509
These instructions have an implicit program exit condition as well. If an
494
510
eBPF program attempts access data beyond the packet boundary, the
0 commit comments