]>
Commit | Line | Data |
---|---|---|
d87bef3a | 1 | @c Copyright (C) 2019-2023 Free Software Foundation, Inc. |
f8861f5d JM |
2 | @c This is part of the GAS manual. |
3 | @c For copying conditions, see the file as.texinfo. | |
4 | ||
5 | @ifset GENERIC | |
6 | @page | |
7 | @node BPF-Dependent | |
8 | @chapter BPF Dependent Features | |
9 | @end ifset | |
10 | ||
11 | @ifclear GENERIC | |
12 | @node Machine Dependencies | |
13 | @chapter BPF Dependent Features | |
14 | @end ifclear | |
15 | ||
16 | @cindex BPF support | |
17 | @menu | |
675b9d61 NC |
18 | * BPF Options:: Options |
19 | * BPF Syntax:: Syntax | |
20 | * BPF Directives:: Machine Directives | |
21 | * BPF Opcodes:: Opcodes | |
22 | * BPF Pseudo-C Syntax:: Alternative Pseudo-C Assembly Syntax | |
f8861f5d JM |
23 | @end menu |
24 | ||
25 | @node BPF Options | |
675b9d61 | 26 | @section Options |
f8861f5d JM |
27 | @cindex BPF options (none) |
28 | @cindex options for BPF (none) | |
29 | ||
30 | @c man begin OPTIONS | |
31 | @table @gcctabopt | |
32 | ||
33 | @cindex @option{-EB} command-line option, BPF | |
34 | @item -EB | |
35 | This option specifies that the assembler should emit big-endian eBPF. | |
36 | ||
37 | @cindex @option{-EL} command-line option, BPF | |
38 | @item -EL | |
39 | This option specifies that the assembler should emit little-endian | |
40 | eBPF. | |
41 | @end table | |
42 | ||
43 | Note that if no endianness option is specified in the command line, | |
44 | the host endianness is used. | |
45 | @c man end | |
46 | ||
675b9d61 NC |
47 | @node BPF Syntax |
48 | @section Syntax | |
49 | @menu | |
50 | * BPF-Chars:: Special Characters | |
51 | * BPF-Regs:: Register Names | |
52 | * BPF-Pseudo-Maps:: Pseudo map fds | |
53 | @end menu | |
54 | ||
55 | @node BPF-Chars | |
56 | @subsection Special Characters | |
f8861f5d JM |
57 | |
58 | @cindex line comment character, BPF | |
59 | @cindex BPF line comment character | |
675b9d61 NC |
60 | The presence of a @samp{;} on a line indicates the start of a comment |
61 | that extends to the end of the current line. If a @samp{#} appears as | |
62 | the first character of a line, the whole line is treated as a comment. | |
f8861f5d JM |
63 | |
64 | @cindex statement separator, BPF | |
65 | Statements and assembly directives are separated by newlines. | |
66 | ||
675b9d61 NC |
67 | @node BPF-Regs |
68 | @subsection Register Names | |
f8861f5d JM |
69 | |
70 | @cindex BPF register names | |
71 | @cindex register names, BPF | |
72 | The eBPF processor provides ten general-purpose 64-bit registers, | |
73 | which are read-write, and a read-only frame pointer register: | |
74 | ||
75 | @table @samp | |
76 | @item %r0 .. %r9 | |
77 | General-purpose registers. | |
78 | @item %r10 | |
675b9d61 | 79 | Frame pointer register. |
f8861f5d JM |
80 | @end table |
81 | ||
675b9d61 NC |
82 | Some registers have additional names, to reflect their role in the |
83 | eBPF ABI: | |
f8861f5d JM |
84 | |
85 | @table @samp | |
675b9d61 NC |
86 | @item %a |
87 | This is @samp{%r0}. | |
88 | @item %ctx | |
89 | This is @samp{%r6}. | |
90 | @item %fp | |
91 | This is @samp{%r10}. | |
f8861f5d JM |
92 | @end table |
93 | ||
675b9d61 NC |
94 | @node BPF-Pseudo-Maps |
95 | @subsection Pseudo Maps | |
96 | ||
97 | @cindex pseudo map fd, BPF | |
98 | The @samp{LDDW} instruction can take a literal pseudo map file | |
99 | descriptor as its second argument. This uses the syntax | |
100 | @samp{%map_fd(N)} where @samp{N} is a signed number. | |
101 | ||
102 | For example, to load the address of the pseudo map with file | |
103 | descriptor @samp{2} in register @samp{r1} we would do: | |
104 | ||
105 | @smallexample | |
106 | lddw %r1, %map_fd(2) | |
107 | @end smallexample | |
f8861f5d | 108 | |
e0b989a6 | 109 | @node BPF Directives |
675b9d61 | 110 | @section Machine Directives |
e0b989a6 JM |
111 | |
112 | @cindex machine directives, BPF | |
113 | ||
114 | The BPF version of @code{@value{AS}} supports the following additional | |
115 | machine directives: | |
116 | ||
117 | @table @code | |
118 | @cindex @code{half} directive, BPF | |
119 | @item .word | |
120 | The @code{.half} directive produces a 16 bit value. | |
121 | ||
122 | @cindex @code{word} directive, BPF | |
123 | @item .word | |
124 | The @code{.word} directive produces a 32 bit value. | |
125 | ||
126 | @cindex @code{dword} directive, BPF | |
127 | @item .dword | |
128 | The @code{.dword} directive produces a 64 bit value. | |
129 | @end table | |
130 | ||
675b9d61 NC |
131 | @node BPF Opcodes |
132 | @section Opcodes | |
f8861f5d JM |
133 | |
134 | @cindex BPF opcodes | |
135 | @cindex opcodes for BPF | |
136 | In the instruction descriptions below the following field descriptors | |
137 | are used: | |
138 | ||
139 | @table @code | |
675b9d61 NC |
140 | @item %d |
141 | Destination general-purpose register whose role is to be destination | |
142 | of an operation. | |
143 | @item %s | |
f8861f5d JM |
144 | Source general-purpose register whose role is to be the source of an |
145 | operation. | |
146 | @item disp16 | |
147 | 16-bit signed PC-relative offset, measured in number of 64-bit words, | |
148 | minus one. | |
149 | @item disp32 | |
150 | 32-bit signed PC-relative offset, measured in number of 64-bit words, | |
151 | minus one. | |
152 | @item offset16 | |
675b9d61 | 153 | Signed 16-bit immediate. |
f8861f5d JM |
154 | @item imm32 |
155 | Signed 32-bit immediate. | |
156 | @item imm64 | |
157 | Signed 64-bit immediate. | |
158 | @end table | |
159 | ||
675b9d61 | 160 | @subsubsection Arithmetic instructions |
f8861f5d JM |
161 | |
162 | The destination register in these instructions act like an | |
163 | accumulator. | |
164 | ||
165 | @table @code | |
675b9d61 | 166 | @item add %d, (%s|imm32) |
f8861f5d | 167 | 64-bit arithmetic addition. |
675b9d61 | 168 | @item sub %d, (%s|imm32) |
f8861f5d | 169 | 64-bit arithmetic subtraction. |
675b9d61 | 170 | @item mul %d, (%s|imm32) |
f8861f5d | 171 | 64-bit arithmetic multiplication. |
675b9d61 | 172 | @item div %d, (%s|imm32) |
f8861f5d | 173 | 64-bit arithmetic integer division. |
675b9d61 | 174 | @item mod %d, (%s|imm32) |
f8861f5d | 175 | 64-bit integer remainder. |
675b9d61 | 176 | @item and %d, (%s|imm32) |
f8861f5d | 177 | 64-bit bit-wise ``and'' operation. |
675b9d61 | 178 | @item or %d, (%s|imm32) |
f8861f5d | 179 | 64-bit bit-wise ``or'' operation. |
675b9d61 | 180 | @item xor %d, (%s|imm32) |
f8861f5d | 181 | 64-bit bit-wise exclusive-or operation. |
675b9d61 NC |
182 | @item lsh %d, (%s|imm32) |
183 | 64-bit left shift, by @code{%s} or @code{imm32} bits. | |
184 | @item rsh %d, (%s|imm32) | |
185 | 64-bit right logical shift, by @code{%s} or @code{imm32} bits. | |
186 | @item arsh %d, (%s|imm32) | |
187 | 64-bit right arithmetic shift, by @code{%s} or @code{imm32} bits. | |
188 | @item neg %d | |
f8861f5d | 189 | 64-bit arithmetic negation. |
675b9d61 NC |
190 | @item mov %d, (%s|imm32) |
191 | Move the 64-bit value of @code{%s} in @code{%d}, or load @code{imm32} | |
192 | in @code{%d}. | |
f8861f5d JM |
193 | @end table |
194 | ||
675b9d61 | 195 | @subsubsection 32-bit arithmetic instructions |
f8861f5d JM |
196 | |
197 | The destination register in these instructions act as an accumulator. | |
198 | ||
199 | @table @code | |
675b9d61 | 200 | @item add32 %d, (%s|imm32) |
f8861f5d | 201 | 32-bit arithmetic addition. |
675b9d61 | 202 | @item sub32 %d, (%s|imm32) |
f8861f5d | 203 | 32-bit arithmetic subtraction. |
675b9d61 | 204 | @item mul32 %d, (%s|imm32) |
f8861f5d | 205 | 32-bit arithmetic multiplication. |
675b9d61 | 206 | @item div32 %d, (%s|imm32) |
f8861f5d | 207 | 32-bit arithmetic integer division. |
675b9d61 | 208 | @item mod32 %d, (%s|imm32) |
f8861f5d | 209 | 32-bit integer remainder. |
675b9d61 | 210 | @item and32 %d, (%s|imm32) |
f8861f5d | 211 | 32-bit bit-wise ``and'' operation. |
675b9d61 | 212 | @item or32 %d, (%s|imm32) |
f8861f5d | 213 | 32-bit bit-wise ``or'' operation. |
675b9d61 | 214 | @item xor32 %d, (%s|imm32) |
f8861f5d | 215 | 32-bit bit-wise exclusive-or operation. |
675b9d61 NC |
216 | @item lsh32 %d, (%s|imm32) |
217 | 32-bit left shift, by @code{%s} or @code{imm32} bits. | |
218 | @item rsh32 %d, (%s|imm32) | |
219 | 32-bit right logical shift, by @code{%s} or @code{imm32} bits. | |
220 | @item arsh32 %d, (%s|imm32) | |
221 | 32-bit right arithmetic shift, by @code{%s} or @code{imm32} bits. | |
222 | @item neg32 %d | |
f8861f5d | 223 | 32-bit arithmetic negation. |
675b9d61 NC |
224 | @item mov32 %d, (%s|imm32) |
225 | Move the 32-bit value of @code{%s} in @code{%d}, or load @code{imm32} | |
226 | in @code{%d}. | |
f8861f5d JM |
227 | @end table |
228 | ||
675b9d61 | 229 | @subsubsection Endianness conversion instructions |
5cbe5492 JM |
230 | |
231 | @table @code | |
675b9d61 NC |
232 | @item endle %d, (16|32|64) |
233 | Convert the 16-bit, 32-bit or 64-bit value in @code{%d} to | |
234 | little-endian. | |
235 | @item endbe %d, (16|32|64) | |
236 | Convert the 16-bit, 32-bit or 64-bit value in @code{%d} to big-endian. | |
5cbe5492 JM |
237 | @end table |
238 | ||
675b9d61 | 239 | @subsubsection 64-bit load and pseudo maps |
f8861f5d JM |
240 | |
241 | @table @code | |
675b9d61 NC |
242 | @item lddw %d, imm64 |
243 | Load the given signed 64-bit immediate, or pseudo map descriptor, to | |
244 | the destination register @code{%d}. | |
245 | @item lddw %d, %map_fd(N) | |
246 | Load the address of the given pseudo map fd @emph{N} to the | |
247 | destination register @code{%d}. | |
f8861f5d JM |
248 | @end table |
249 | ||
675b9d61 | 250 | @subsubsection Load instructions for socket filters |
f8861f5d JM |
251 | |
252 | The following instructions are intended to be used in socket filters, | |
253 | and are therefore not general-purpose: they make assumptions on the | |
254 | contents of several registers. See the file | |
255 | @file{Documentation/networking/filter.txt} in the Linux kernel source | |
256 | tree for more information. | |
257 | ||
258 | Absolute loads: | |
259 | ||
260 | @table @code | |
3719fd55 | 261 | @item ldabsdw imm32 |
f8861f5d | 262 | Absolute 64-bit load. |
3719fd55 | 263 | @item ldabsw imm32 |
f8861f5d | 264 | Absolute 32-bit load. |
3719fd55 | 265 | @item ldabsh imm32 |
f8861f5d | 266 | Absolute 16-bit load. |
3719fd55 | 267 | @item ldabsb imm32 |
f8861f5d JM |
268 | Absolute 8-bit load. |
269 | @end table | |
270 | ||
271 | Indirect loads: | |
272 | ||
273 | @table @code | |
675b9d61 | 274 | @item ldinddw %s, imm32 |
f8861f5d | 275 | Indirect 64-bit load. |
675b9d61 | 276 | @item ldindw %s, imm32 |
f8861f5d | 277 | Indirect 32-bit load. |
675b9d61 | 278 | @item ldindh %s, imm32 |
f8861f5d | 279 | Indirect 16-bit load. |
3719fd55 | 280 | @item ldindb %s, imm32 |
f8861f5d JM |
281 | Indirect 8-bit load. |
282 | @end table | |
283 | ||
675b9d61 | 284 | @subsubsection Generic load/store instructions |
f8861f5d JM |
285 | |
286 | General-purpose load and store instructions are provided for several | |
287 | word sizes. | |
288 | ||
289 | Load to register instructions: | |
290 | ||
291 | @table @code | |
675b9d61 | 292 | @item ldxdw %d, [%s+offset16] |
f8861f5d | 293 | Generic 64-bit load. |
675b9d61 | 294 | @item ldxw %d, [%s+offset16] |
f8861f5d | 295 | Generic 32-bit load. |
675b9d61 | 296 | @item ldxh %d, [%s+offset16] |
f8861f5d | 297 | Generic 16-bit load. |
675b9d61 | 298 | @item ldxb %d, [%s+offset16] |
f8861f5d JM |
299 | Generic 8-bit load. |
300 | @end table | |
301 | ||
302 | Store from register instructions: | |
303 | ||
304 | @table @code | |
675b9d61 | 305 | @item stxdw [%d+offset16], %s |
f8861f5d | 306 | Generic 64-bit store. |
675b9d61 | 307 | @item stxw [%d+offset16], %s |
f8861f5d | 308 | Generic 32-bit store. |
675b9d61 | 309 | @item stxh [%d+offset16], %s |
f8861f5d | 310 | Generic 16-bit store. |
675b9d61 | 311 | @item stxb [%d+offset16], %s |
f8861f5d JM |
312 | Generic 8-bit store. |
313 | @end table | |
314 | ||
315 | Store from immediates instructions: | |
316 | ||
317 | @table @code | |
675b9d61 | 318 | @item stddw [%d+offset16], imm32 |
f8861f5d | 319 | Store immediate as 64-bit. |
675b9d61 | 320 | @item stdw [%d+offset16], imm32 |
f8861f5d | 321 | Store immediate as 32-bit. |
675b9d61 | 322 | @item stdh [%d+offset16], imm32 |
f8861f5d | 323 | Store immediate as 16-bit. |
675b9d61 | 324 | @item stdb [%d+offset16], imm32 |
f8861f5d JM |
325 | Store immediate as 8-bit. |
326 | @end table | |
327 | ||
675b9d61 | 328 | @subsubsection Jump instructions |
f8861f5d JM |
329 | |
330 | eBPF provides the following compare-and-jump instructions, which | |
331 | compare the values of the two given registers, or the values of a | |
332 | register and an immediate, and perform a branch in case the comparison | |
333 | holds true. | |
334 | ||
335 | @table @code | |
675b9d61 | 336 | @item ja %d,(%s|imm32),disp16 |
f8861f5d | 337 | Jump-always. |
675b9d61 | 338 | @item jeq %d,(%s|imm32),disp16 |
dcdec68b | 339 | Jump if equal, unsigned. |
675b9d61 | 340 | @item jgt %d,(%s|imm32),disp16 |
dcdec68b | 341 | Jump if greater, unsigned. |
675b9d61 | 342 | @item jge %d,(%s|imm32),disp16 |
f8861f5d | 343 | Jump if greater or equal. |
675b9d61 | 344 | @item jlt %d,(%s|imm32),disp16 |
f8861f5d | 345 | Jump if lesser. |
675b9d61 | 346 | @item jle %d,(%s|imm32),disp16 |
f8861f5d | 347 | Jump if lesser or equal. |
675b9d61 | 348 | @item jset %d,(%s|imm32),disp16 |
f8861f5d | 349 | Jump if signed equal. |
675b9d61 | 350 | @item jne %d,(%s|imm32),disp16 |
f8861f5d | 351 | Jump if not equal. |
675b9d61 | 352 | @item jsgt %d,(%s|imm32),disp16 |
f8861f5d | 353 | Jump if signed greater. |
675b9d61 | 354 | @item jsge %d,(%s|imm32),disp16 |
f8861f5d | 355 | Jump if signed greater or equal. |
675b9d61 | 356 | @item jslt %d,(%s|imm32),disp16 |
f8861f5d | 357 | Jump if signed lesser. |
675b9d61 | 358 | @item jsle %d,(%s|imm32),disp16 |
f8861f5d JM |
359 | Jump if signed lesser or equal. |
360 | @end table | |
361 | ||
362 | A call instruction is provided in order to perform calls to other eBPF | |
363 | functions, or to external kernel helpers: | |
364 | ||
365 | @table @code | |
675b9d61 | 366 | @item call (disp32|imm32) |
f8861f5d JM |
367 | Jump and link to the offset @emph{disp32}, or to the kernel helper |
368 | function identified by @emph{imm32}. | |
369 | @end table | |
370 | ||
371 | Finally: | |
372 | ||
373 | @table @code | |
374 | @item exit | |
375 | Terminate the eBPF program. | |
376 | @end table | |
377 | ||
675b9d61 | 378 | @subsubsection Atomic instructions |
f8861f5d | 379 | |
675b9d61 NC |
380 | Atomic exchange-and-add instructions are provided in two flavors: one |
381 | for swapping 64-bit quantities and another for 32-bit quantities. | |
dcdec68b | 382 | |
d218e7fe | 383 | @table @code |
675b9d61 NC |
384 | @item xadddw [%d+offset16],%s |
385 | Exchange-and-add a 64-bit value at the specified location. | |
386 | @item xaddw [%d+offset16],%s | |
387 | Exchange-and-add a 32-bit value at the specified location. | |
388 | @end table | |
dcdec68b | 389 | |
675b9d61 NC |
390 | @node BPF Pseudo-C Syntax |
391 | @section BPF Pseudo-C Syntax | |
dcdec68b | 392 | |
675b9d61 NC |
393 | This assembler supports another syntax to denote BPF instructions, |
394 | which is an alternative to the normal looking syntax documented above. | |
395 | This alternatative syntax, which we call @dfn{pseudo-C syntax}, is | |
396 | supported by the LLVM/clang integrated assembler. | |
dcdec68b | 397 | |
675b9d61 NC |
398 | This syntax is very unconventional, but we need to support it in order |
399 | to support inline assembly in existing BPF programs. | |
dcdec68b | 400 | |
675b9d61 NC |
401 | Note that the assembler is able to parse sources in which both |
402 | syntaxes coexist: some instructions can use the usual assembly like | |
403 | syntax, whereas some other instructions in the same file can use the | |
404 | pseudo-C syntax. | |
dcdec68b | 405 | |
675b9d61 | 406 | @subsubsection Pseudo-C Register Names |
d218e7fe | 407 | |
675b9d61 NC |
408 | All BPF registers are 64-bit long. However, in the Pseudo-C syntax |
409 | registers can be referred using different names, which actually | |
410 | reflect the kind of instruction they appear on: | |
02f68ef2 | 411 | |
675b9d61 NC |
412 | @table @samp |
413 | @item r0..r9 | |
414 | General-purpose register in an instruction that operates on its value | |
415 | as if it was a 64-bit value. | |
416 | @item w0..w9 | |
417 | General-purpose register in an instruction that operates on its value | |
418 | as if it was a 32-bit value. | |
02f68ef2 DF |
419 | @end table |
420 | ||
421 | @noindent | |
675b9d61 NC |
422 | Note that in the Pseudo-C syntax register names are not preceded by |
423 | @code{%} characters. | |
d218e7fe | 424 | |
675b9d61 | 425 | @subsubsection Arithmetic instructions |
d218e7fe | 426 | |
675b9d61 NC |
427 | In all the instructions below, the operations are 64-bit or 32-bit |
428 | depending on the names used to refer to the registers. For example | |
429 | @code{r3 += r2} will perform 64-bit addition, whereas @code{w3 += w2} | |
430 | will perform 32-bit addition. Mixing register prefixes is an error, | |
431 | for example @code{r3 += w2}. | |
d218e7fe | 432 | |
675b9d61 NC |
433 | @table @code |
434 | @item dst_reg += (imm32|src_reg) | |
435 | Arithmetic addition. | |
436 | @item dst_reg -= (imm32|src_reg) | |
437 | Arithmetic subtraction. | |
438 | @item dst_reg *= (imm32|src_reg) | |
439 | Arithmetic multiplication. | |
440 | @item dst_reg /= (imm32|src_reg) | |
441 | Arithmetic integer unsigned division. | |
442 | @item dst_reg %= (imm32|src_reg) | |
443 | Arithmetic integer unsigned remainder. | |
444 | @item dst_reg &= (imm32|src_reg) | |
445 | Bit-wise ``and'' operation. | |
446 | @item dst_reg |= (imm32|src_reg) | |
447 | Bit-wise ``or'' operation. | |
448 | @item dst_reg ^= (imm32|src_reg) | |
449 | Bit-wise exclusive-or operation. | |
450 | @item dst_reg <<= (imm32|src_reg) | |
451 | Left shift, by whatever specified number of bits. | |
452 | @item dst_reg >>= (imm32|src_reg) | |
453 | Right logical shift, by whatever specified number of bits. | |
454 | @item dst_reg s>>= (imm32|src_reg) | |
455 | Right arithmetic shift, by whatever specified number of bits. | |
456 | @item dst_reg = (imm32|src_reg) | |
457 | Move the value in @code{imm32} or @code{src_reg} in @code{dst_reg}. | |
458 | @item dst_reg = -dst_reg | |
459 | Arithmetic negation. | |
dcdec68b JM |
460 | @end table |
461 | ||
675b9d61 | 462 | @subsubsection Endianness conversion instructions |
dcdec68b JM |
463 | |
464 | @table @code | |
675b9d61 NC |
465 | @item dst_reg = le16 src_reg |
466 | Convert the 16-bit value in @code{src_reg} to little-endian. | |
467 | @item dst_reg = le32 src_reg | |
468 | Convert the 32-bit value in @code{src_reg} to little-endian. | |
469 | @item dst_reg = le64 src_reg | |
470 | Convert the 64-bit value in @code{src_reg} to little-endian. | |
471 | @item dst_reg = be16 src_reg | |
472 | Convert the 16-bit value in @code{src_reg} to big-endian. | |
473 | @item dst_reg = be32 src_reg | |
474 | Convert the 32-bit value in @code{src_reg} to big-endian. | |
475 | @item dst_reg = be64 src_reg | |
476 | Convert the 64-bit value in @code{src_reg} to big-endian. | |
dcdec68b JM |
477 | @end table |
478 | ||
675b9d61 | 479 | @subsubsection 64-bit load and pseudo maps |
dcdec68b JM |
480 | |
481 | @table @code | |
675b9d61 NC |
482 | @item dst_reg = imm64 ll |
483 | Load the given signed 64-bit immediate, or pseudo map descriptor, to | |
484 | the destination register @code{dst_reg}. | |
dcdec68b JM |
485 | @end table |
486 | ||
675b9d61 | 487 | @subsubsection Load instructions for socket filters |
02f68ef2 DF |
488 | |
489 | @table @code | |
675b9d61 NC |
490 | @item r0 = *(u8 *)skb[imm32] |
491 | Absolute 8-bit load. | |
492 | @item r0 = *(u16 *)skb[imm32] | |
493 | Absolute 16-bit load. | |
494 | @item r0 = *(u32 *)skb[imm32] | |
495 | Absolute 32-bit load. | |
496 | @item r0 = *(u64 *)skb[imm32] | |
497 | Absolute 64-bit load. | |
498 | @item r0 = *(u8 *)skb[src_reg + imm32] | |
499 | Indirect 8-bit load. | |
500 | @item r0 = *(u16 *)skb[src_reg + imm32] | |
501 | Indirect 16-bit load. | |
502 | @item r0 = *(u32 *)skb[src_reg + imm32] | |
503 | Indirect 32-bit load. | |
504 | @item r0 = *(u64 *)skb[src_reg + imm32] | |
505 | Indirect 64-bit load. | |
02f68ef2 DF |
506 | @end table |
507 | ||
675b9d61 | 508 | @subsubsection Generic load/store instructions |
dcdec68b JM |
509 | |
510 | @table @code | |
675b9d61 NC |
511 | @item dst_reg = *(u8 *)(src_reg + offset16) |
512 | Generic 8-bit load. | |
513 | @item dst_reg = *(u16 *)(src_reg + offset16) | |
514 | Generic 16-bit load. | |
515 | @item dst_reg = *(u32 *)(src_reg + offset16) | |
516 | Generic 32-bit load. | |
517 | @item dst_reg = *(u64 *)(src_reg + offset16) | |
518 | Generic 64-bit load. | |
519 | @c XXX stb | |
520 | @c NO PSEUDOC-SYNTAX | |
521 | @c XXX sth | |
522 | @c NO PSEUDOC-SYNTAX | |
523 | @c XXX stw | |
524 | @c NO PSEUDOC-SYNTAX | |
525 | @c XXX stdw | |
526 | @c NO PSEUDOC-SYNTAX | |
527 | @item *(u8 *)(dst_reg + offset16) = src_reg | |
528 | Generic 8-bit store. | |
529 | @item *(u16 *)(dst_reg + offset16) = src_reg | |
530 | Generic 16-bit store. | |
531 | @item *(u32 *)(dst_reg + offset16) = src_reg | |
532 | Generic 32-bit store. | |
533 | @item *(u64 *)(dst_reg + offset16) = src_reg | |
534 | Generic 64-bit store. | |
dcdec68b JM |
535 | @end table |
536 | ||
675b9d61 | 537 | @subsubsection Jump instructions |
dcdec68b JM |
538 | |
539 | @table @code | |
675b9d61 NC |
540 | @item goto disp16 |
541 | Jump-always. | |
542 | @item if dst_reg == (imm32|src_reg) goto disp16 | |
543 | Jump if equal. | |
544 | @item if dst_reg & (imm32|src_reg) goto disp16 | |
545 | Jump if signed equal. | |
546 | @item if dst_reg != (imm32|src_reg) goto disp16 | |
547 | Jump if not equal. | |
548 | @item if dst_reg > (imm32|src_reg) goto disp16 | |
549 | Jump if bigger, unsigned. | |
550 | @item if dst_reg < (imm32|src_reg) goto disp16 | |
551 | Jump if smaller, unsigned. | |
552 | @item if dst_reg >= (imm32|src_reg) goto disp16 | |
553 | Jump if bigger or equal, unsigned. | |
554 | @item if dst_reg <= (imm32|src_reg) goto disp16 | |
555 | Jump if smaller or equal, unsigned. | |
556 | @item if dst_reg s> (imm32|src_reg) goto disp16 | |
557 | Jump if bigger, signed. | |
558 | @item if dst_reg s< (imm32|src_reg) goto disp16 | |
559 | Jump if smaller, signed. | |
560 | @item if dst_reg s>= (imm32|src_reg) goto disp16 | |
561 | Jump if bigger or equal, signed. | |
562 | @item if dst_reg s<= (imm32|src_reg) goto disp16 | |
563 | Jump if smaller or equal, signed. | |
564 | @item call imm32 | |
565 | Jump and link. | |
566 | @item exit | |
567 | Terminate the eBPF program. | |
dcdec68b JM |
568 | @end table |
569 | ||
675b9d61 | 570 | @subsubsection Atomic instructions |
dcdec68b JM |
571 | |
572 | @table @code | |
675b9d61 NC |
573 | @item lock *(u64 *)(dst_reg + offset16) += src_reg |
574 | Exchange-and-add a 64-bit value at the specified location. | |
575 | @item lock *(u32 *)(dst_reg + offset16) += src_reg | |
576 | Exchange-and-add a 32-bit value at the specified location. | |
dcdec68b | 577 | @end table |