Skip to content

Commit 00d5d22

Browse files
Dave ThalerAlexei Starovoitov
authored andcommitted
bpf, docs: Editorial nits in instruction-set.rst
This patch addresses a number of editorial nits including spelling, punctuation, grammar, and wording consistency issues in instruction-set.rst. Signed-off-by: Dave Thaler <[email protected]> Acked-by: David Vernet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent ba0cbe2 commit 00d5d22

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

Documentation/bpf/standardization/instruction-set.rst

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ a type's signedness (`S`) and bit width (`N`), respectively.
4343
===== =========
4444

4545
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
4747
numbers.
4848

4949
Functions
@@ -108,7 +108,7 @@ conformance group means it must support all instructions in that conformance
108108
group.
109109

110110
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
112112
instructions for the runtime. Thus, capability discovery in terms of
113113
conformance groups might be done manually by users or automatically by tools.
114114

@@ -181,10 +181,13 @@ A basic instruction is encoded as follows::
181181
(`64-bit immediate instructions`_ reuse this field for other purposes)
182182

183183
**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)
185186

186187
**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)
188191

189192
**imm**
190193
signed integer immediate value
@@ -228,10 +231,12 @@ This is depicted in the following figure::
228231
operation to perform, encoded as explained above
229232

230233
**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
232236

233237
**offset**
234-
signed integer offset used with pointer arithmetic
238+
signed integer offset used with pointer arithmetic, unless
239+
otherwise specified
235240

236241
**imm**
237242
signed integer immediate value
@@ -342,8 +347,8 @@ where '(u32)' indicates that the upper 32 bits are zeroed.
342347

343348
dst = dst ^ imm
344349

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'.
347352

348353
Division, multiplication, and modulo operations for ``ALU`` are part
349354
of the "divmul32" conformance group, and division, multiplication, and
@@ -370,10 +375,10 @@ etc. This specification requires that signed modulo use truncated division
370375
a % n = a - n * trunc(a / n)
371376

372377
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.
375380
``{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,
377382
``MOVSX`` is only defined for register source operands (``X``).
378383

379384
The ``NEG`` instruction is only defined when the source bit is clear
@@ -411,19 +416,19 @@ conformance group.
411416

412417
Examples:
413418

414-
``{END, TO_LE, ALU}`` with imm = 16/32/64 means::
419+
``{END, TO_LE, ALU}`` with 'imm' = 16/32/64 means::
415420

416421
dst = htole16(dst)
417422
dst = htole32(dst)
418423
dst = htole64(dst)
419424

420-
``{END, TO_BE, ALU}`` with imm = 16/32/64 means::
425+
``{END, TO_BE, ALU}`` with 'imm' = 16/32/64 means::
421426

422427
dst = htobe16(dst)
423428
dst = htobe32(dst)
424429
dst = htobe64(dst)
425430

426-
``{END, TO_LE, ALU64}`` with imm = 16/32/64 means::
431+
``{END, TO_LE, ALU64}`` with 'imm' = 16/32/64 means::
427432

428433
dst = bswap16(dst)
429434
dst = bswap32(dst)
@@ -475,7 +480,7 @@ where 's>=' indicates a signed '>=' comparison.
475480

476481
gotol +imm
477482

478-
where 'imm' means the branch offset comes from insn 'imm' field.
483+
where 'imm' means the branch offset comes from the 'imm' field.
479484

480485
Note that there are two flavors of ``JA`` instructions. The
481486
``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
494499
set of function calls exposed by the underlying platform.
495500

496501
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
498503
for each program type, but address values are unique across all program types.
499504

500505
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
502507
identifies the helper name and type.
503508

504509
Program-local functions
505510
~~~~~~~~~~~~~~~~~~~~~~~
506511
Program-local functions are functions exposed by the same BPF program as the
507512
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.
510515

511516
Load and store instructions
512517
===========================
513518

514519
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::
516521

517522
+-+-+-+-+-+-+-+-+
518523
|mode |sz |class|
@@ -580,7 +585,7 @@ instructions that transfer data between a register and memory.
580585

581586
dst = *(signed size *) (src + offset)
582587

583-
Where size is one of: ``B``, ``H``, or ``W``, and
588+
Where '<size>' is one of: ``B``, ``H``, or ``W``, and
584589
'signed size' is one of: s8, s16, or s32.
585590

586591
Atomic operations

0 commit comments

Comments
 (0)