@@ -43,7 +43,7 @@ a type's signedness (`S`) and bit width (`N`), respectively.
43
43
===== =========
44
44
45
45
For example, `u32 ` is a type whose valid values are all the 32-bit unsigned
46
- numbers and `s16 ` is a types whose valid values are all the 16-bit signed
46
+ numbers and `s16 ` is a type whose valid values are all the 16-bit signed
47
47
numbers.
48
48
49
49
Functions
@@ -108,7 +108,7 @@ conformance group means it must support all instructions in that conformance
108
108
group.
109
109
110
110
The use of named conformance groups enables interoperability between a runtime
111
- that executes instructions, and tools as such compilers that generate
111
+ that executes instructions, and tools such as compilers that generate
112
112
instructions for the runtime. Thus, capability discovery in terms of
113
113
conformance groups might be done manually by users or automatically by tools.
114
114
@@ -181,10 +181,13 @@ A basic instruction is encoded as follows::
181
181
(`64-bit immediate instructions `_ reuse this field for other purposes)
182
182
183
183
**dst_reg **
184
- destination register number (0-10)
184
+ destination register number (0-10), unless otherwise specified
185
+ (future instructions might reuse this field for other purposes)
185
186
186
187
**offset **
187
- signed integer offset used with pointer arithmetic
188
+ signed integer offset used with pointer arithmetic, except where
189
+ otherwise specified (some arithmetic instructions reuse this field
190
+ for other purposes)
188
191
189
192
**imm **
190
193
signed integer immediate value
@@ -228,10 +231,12 @@ This is depicted in the following figure::
228
231
operation to perform, encoded as explained above
229
232
230
233
**regs **
231
- The source and destination register numbers, encoded as explained above
234
+ The source and destination register numbers (unless otherwise
235
+ specified), encoded as explained above
232
236
233
237
**offset **
234
- signed integer offset used with pointer arithmetic
238
+ signed integer offset used with pointer arithmetic, unless
239
+ otherwise specified
235
240
236
241
**imm **
237
242
signed integer immediate value
@@ -342,8 +347,8 @@ where '(u32)' indicates that the upper 32 bits are zeroed.
342
347
343
348
dst = dst ^ imm
344
349
345
- Note that most instructions have instruction offset of 0. Only three instructions
346
- (``SDIV ``, ``SMOD ``, ``MOVSX ``) have a non-zero offset.
350
+ Note that most arithmetic instructions have ' offset' set to 0. Only three instructions
351
+ (``SDIV ``, ``SMOD ``, ``MOVSX ``) have a non-zero ' offset' .
347
352
348
353
Division, multiplication, and modulo operations for ``ALU `` are part
349
354
of the "divmul32" conformance group, and division, multiplication, and
@@ -370,10 +375,10 @@ etc. This specification requires that signed modulo use truncated division
370
375
a % n = a - n * trunc(a / n)
371
376
372
377
The ``MOVSX `` instruction does a move operation with sign extension.
373
- ``{MOVSX, X, ALU} `` :term: `sign extends<Sign Extend> ` 8-bit and 16-bit operands into 32
374
- bit operands, and zeroes the remaining upper 32 bits.
378
+ ``{MOVSX, X, ALU} `` :term: `sign extends<Sign Extend> ` 8-bit and 16-bit operands into
379
+ 32- bit operands, and zeroes the remaining upper 32 bits.
375
380
``{MOVSX, X, ALU64} `` :term: `sign extends<Sign Extend> ` 8-bit, 16-bit, and 32-bit
376
- operands into 64 bit operands. Unlike other arithmetic instructions,
381
+ operands into 64- bit operands. Unlike other arithmetic instructions,
377
382
``MOVSX `` is only defined for register source operands (``X ``).
378
383
379
384
The ``NEG `` instruction is only defined when the source bit is clear
@@ -411,19 +416,19 @@ conformance group.
411
416
412
417
Examples:
413
418
414
- ``{END, TO_LE, ALU} `` with imm = 16/32/64 means::
419
+ ``{END, TO_LE, ALU} `` with ' imm' = 16/32/64 means::
415
420
416
421
dst = htole16(dst)
417
422
dst = htole32(dst)
418
423
dst = htole64(dst)
419
424
420
- ``{END, TO_BE, ALU} `` with imm = 16/32/64 means::
425
+ ``{END, TO_BE, ALU} `` with ' imm' = 16/32/64 means::
421
426
422
427
dst = htobe16(dst)
423
428
dst = htobe32(dst)
424
429
dst = htobe64(dst)
425
430
426
- ``{END, TO_LE, ALU64} `` with imm = 16/32/64 means::
431
+ ``{END, TO_LE, ALU64} `` with ' imm' = 16/32/64 means::
427
432
428
433
dst = bswap16(dst)
429
434
dst = bswap32(dst)
@@ -475,7 +480,7 @@ where 's>=' indicates a signed '>=' comparison.
475
480
476
481
gotol +imm
477
482
478
- where 'imm' means the branch offset comes from insn 'imm' field.
483
+ where 'imm' means the branch offset comes from the 'imm' field.
479
484
480
485
Note that there are two flavors of ``JA `` instructions. The
481
486
``JMP `` class permits a 16-bit jump offset specified by the 'offset'
@@ -494,25 +499,25 @@ Helper functions are a concept whereby BPF programs can call into a
494
499
set of function calls exposed by the underlying platform.
495
500
496
501
Historically, each helper function was identified by an address
497
- encoded in the imm field. The available helper functions may differ
502
+ encoded in the ' imm' field. The available helper functions may differ
498
503
for each program type, but address values are unique across all program types.
499
504
500
505
Platforms that support the BPF Type Format (BTF) support identifying
501
- a helper function by a BTF ID encoded in the imm field, where the BTF ID
506
+ a helper function by a BTF ID encoded in the ' imm' field, where the BTF ID
502
507
identifies the helper name and type.
503
508
504
509
Program-local functions
505
510
~~~~~~~~~~~~~~~~~~~~~~~
506
511
Program-local functions are functions exposed by the same BPF program as the
507
512
caller, and are referenced by offset from the call instruction, similar to
508
- ``JA ``. The offset is encoded in the imm field of the call instruction.
509
- A ``EXIT `` within the program-local function will return to the caller.
513
+ ``JA ``. The offset is encoded in the ' imm' field of the call instruction.
514
+ An ``EXIT `` within the program-local function will return to the caller.
510
515
511
516
Load and store instructions
512
517
===========================
513
518
514
519
For load and store instructions (``LD ``, ``LDX ``, ``ST ``, and ``STX ``), the
515
- 8-bit 'opcode' field is divided as::
520
+ 8-bit 'opcode' field is divided as follows ::
516
521
517
522
+-+-+-+-+-+-+-+-+
518
523
|mode |sz |class|
@@ -580,7 +585,7 @@ instructions that transfer data between a register and memory.
580
585
581
586
dst = *(signed size *) (src + offset)
582
587
583
- Where size is one of: ``B ``, ``H ``, or ``W ``, and
588
+ Where '< size>' is one of: ``B ``, ``H ``, or ``W ``, and
584
589
'signed size' is one of: s8, s16, or s32.
585
590
586
591
Atomic operations
0 commit comments