Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <dthaler1968@gmail.com>
Acked-by: David Vernet <void@manifault.com>
Link: https://lore.kernel.org/r/20240405155245.3618-1-dthaler1968@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Dave Thaler and committed by
Alexei Starovoitov
00d5d22a ba0cbe2b

+26 -21
+26 -21
Documentation/bpf/standardization/instruction-set.rst
··· 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 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 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 ··· 231 228 operation to perform, encoded as explained above 232 229 233 230 **regs** 234 - The source and destination register numbers, encoded as explained above 231 + The source and destination register numbers (unless otherwise 232 + specified), encoded as explained above 235 233 236 234 **offset** 237 - signed integer offset used with pointer arithmetic 235 + signed integer offset used with pointer arithmetic, unless 236 + otherwise specified 238 237 239 238 **imm** 240 239 signed integer immediate value ··· 347 342 348 343 dst = dst ^ imm 349 344 350 - Note that most instructions have instruction offset of 0. Only three instructions 351 - (``SDIV``, ``SMOD``, ``MOVSX``) have a non-zero offset. 345 + Note that most arithmetic instructions have 'offset' set to 0. Only three instructions 346 + (``SDIV``, ``SMOD``, ``MOVSX``) have a non-zero 'offset'. 352 347 353 348 Division, multiplication, and modulo operations for ``ALU`` are part 354 349 of the "divmul32" conformance group, and division, multiplication, and ··· 375 370 a % n = a - n * trunc(a / n) 376 371 377 372 The ``MOVSX`` instruction does a move operation with sign extension. 378 - ``{MOVSX, X, ALU}`` :term:`sign extends<Sign Extend>` 8-bit and 16-bit operands into 32 379 - bit operands, and zeroes the remaining upper 32 bits. 373 + ``{MOVSX, X, ALU}`` :term:`sign extends<Sign Extend>` 8-bit and 16-bit operands into 374 + 32-bit operands, and zeroes the remaining upper 32 bits. 380 375 ``{MOVSX, X, ALU64}`` :term:`sign extends<Sign Extend>` 8-bit, 16-bit, and 32-bit 381 - operands into 64 bit operands. Unlike other arithmetic instructions, 376 + operands into 64-bit operands. Unlike other arithmetic instructions, 382 377 ``MOVSX`` is only defined for register source operands (``X``). 383 378 384 379 The ``NEG`` instruction is only defined when the source bit is clear ··· 416 411 417 412 Examples: 418 413 419 - ``{END, TO_LE, ALU}`` with imm = 16/32/64 means:: 414 + ``{END, TO_LE, ALU}`` with 'imm' = 16/32/64 means:: 420 415 421 416 dst = htole16(dst) 422 417 dst = htole32(dst) 423 418 dst = htole64(dst) 424 419 425 - ``{END, TO_BE, ALU}`` with imm = 16/32/64 means:: 420 + ``{END, TO_BE, ALU}`` with 'imm' = 16/32/64 means:: 426 421 427 422 dst = htobe16(dst) 428 423 dst = htobe32(dst) 429 424 dst = htobe64(dst) 430 425 431 - ``{END, TO_LE, ALU64}`` with imm = 16/32/64 means:: 426 + ``{END, TO_LE, ALU64}`` with 'imm' = 16/32/64 means:: 432 427 433 428 dst = bswap16(dst) 434 429 dst = bswap32(dst) ··· 480 475 481 476 gotol +imm 482 477 483 - where 'imm' means the branch offset comes from insn 'imm' field. 478 + where 'imm' means the branch offset comes from the 'imm' field. 484 479 485 480 Note that there are two flavors of ``JA`` instructions. The 486 481 ``JMP`` class permits a 16-bit jump offset specified by the 'offset' ··· 499 494 set of function calls exposed by the underlying platform. 500 495 501 496 Historically, each helper function was identified by an address 502 - encoded in the imm field. The available helper functions may differ 497 + encoded in the 'imm' field. The available helper functions may differ 503 498 for each program type, but address values are unique across all program types. 504 499 505 500 Platforms that support the BPF Type Format (BTF) support identifying 506 - a helper function by a BTF ID encoded in the imm field, where the BTF ID 501 + a helper function by a BTF ID encoded in the 'imm' field, where the BTF ID 507 502 identifies the helper name and type. 508 503 509 504 Program-local functions 510 505 ~~~~~~~~~~~~~~~~~~~~~~~ 511 506 Program-local functions are functions exposed by the same BPF program as the 512 507 caller, and are referenced by offset from the call instruction, similar to 513 - ``JA``. The offset is encoded in the imm field of the call instruction. 514 - A ``EXIT`` within the program-local function will return to the caller. 508 + ``JA``. The offset is encoded in the 'imm' field of the call instruction. 509 + An ``EXIT`` within the program-local function will return to the caller. 515 510 516 511 Load and store instructions 517 512 =========================== 518 513 519 514 For load and store instructions (``LD``, ``LDX``, ``ST``, and ``STX``), the 520 - 8-bit 'opcode' field is divided as:: 515 + 8-bit 'opcode' field is divided as follows:: 521 516 522 517 +-+-+-+-+-+-+-+-+ 523 518 |mode |sz |class| ··· 585 580 586 581 dst = *(signed size *) (src + offset) 587 582 588 - Where size is one of: ``B``, ``H``, or ``W``, and 583 + Where '<size>' is one of: ``B``, ``H``, or ``W``, and 589 584 'signed size' is one of: s8, s16, or s32. 590 585 591 586 Atomic operations