mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:02:20 +00:00
bpf, docs: Explain helper functions
Add brief text about existence of helper functions, with details to go in separate psABI text. Note that text about runtime functions (kfuncs) is part of a separate patch, not this one. Signed-off-by: Dave Thaler <dthaler@microsoft.com> Link: https://lore.kernel.org/r/20230308205303.1308-1-dthaler1968@googlemail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
74843b57ec
commit
c1f9e14e3b
@ -20,6 +20,12 @@ Arithmetic instructions
|
|||||||
For CPU versions prior to 3, Clang v7.0 and later can enable ``BPF_ALU`` support with
|
For CPU versions prior to 3, Clang v7.0 and later can enable ``BPF_ALU`` support with
|
||||||
``-Xclang -target-feature -Xclang +alu32``. In CPU version 3, support is automatically included.
|
``-Xclang -target-feature -Xclang +alu32``. In CPU version 3, support is automatically included.
|
||||||
|
|
||||||
|
Jump instructions
|
||||||
|
=================
|
||||||
|
|
||||||
|
If ``-O0`` is used, Clang will generate the ``BPF_CALL | BPF_X | BPF_JMP`` (0x8d)
|
||||||
|
instruction, which is not supported by the Linux kernel verifier.
|
||||||
|
|
||||||
Atomic operations
|
Atomic operations
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ BPF_JSET 0x40 PC += off if dst & src
|
|||||||
BPF_JNE 0x50 PC += off if dst != src
|
BPF_JNE 0x50 PC += off if dst != src
|
||||||
BPF_JSGT 0x60 PC += off if dst > src signed
|
BPF_JSGT 0x60 PC += off if dst > src signed
|
||||||
BPF_JSGE 0x70 PC += off if dst >= src signed
|
BPF_JSGE 0x70 PC += off if dst >= src signed
|
||||||
BPF_CALL 0x80 function call
|
BPF_CALL 0x80 function call see `Helper functions`_
|
||||||
BPF_EXIT 0x90 function / program return BPF_JMP only
|
BPF_EXIT 0x90 function / program return BPF_JMP only
|
||||||
BPF_JLT 0xa0 PC += off if dst < src unsigned
|
BPF_JLT 0xa0 PC += off if dst < src unsigned
|
||||||
BPF_JLE 0xb0 PC += off if dst <= src unsigned
|
BPF_JLE 0xb0 PC += off if dst <= src unsigned
|
||||||
@ -264,6 +264,13 @@ BPF_JSLE 0xd0 PC += off if dst <= src signed
|
|||||||
The eBPF program needs to store the return value into register R0 before doing a
|
The eBPF program needs to store the return value into register R0 before doing a
|
||||||
BPF_EXIT.
|
BPF_EXIT.
|
||||||
|
|
||||||
|
Helper functions
|
||||||
|
~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Helper functions are a concept whereby BPF programs can call into a
|
||||||
|
set of function calls exposed by the runtime. Each helper
|
||||||
|
function is identified by an integer used in a ``BPF_CALL`` instruction.
|
||||||
|
The available helper functions may differ for each program type.
|
||||||
|
|
||||||
Load and store instructions
|
Load and store instructions
|
||||||
===========================
|
===========================
|
||||||
|
@ -12,6 +12,14 @@ Byte swap instructions
|
|||||||
|
|
||||||
``BPF_FROM_LE`` and ``BPF_FROM_BE`` exist as aliases for ``BPF_TO_LE`` and ``BPF_TO_BE`` respectively.
|
``BPF_FROM_LE`` and ``BPF_FROM_BE`` exist as aliases for ``BPF_TO_LE`` and ``BPF_TO_BE`` respectively.
|
||||||
|
|
||||||
|
Jump instructions
|
||||||
|
=================
|
||||||
|
|
||||||
|
``BPF_CALL | BPF_X | BPF_JMP`` (0x8d), where the helper function
|
||||||
|
integer would be read from a specified register, is not currently supported
|
||||||
|
by the verifier. Any programs with this instruction will fail to load
|
||||||
|
until such support is added.
|
||||||
|
|
||||||
Legacy BPF Packet access instructions
|
Legacy BPF Packet access instructions
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user