summaryrefslogtreecommitdiff
path: root/Documentation/bpf
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-01-03 19:35:55 +0100
committerAlexei Starovoitov <ast@kernel.org>2022-01-05 13:11:26 -0800
commit9e533e22b5700097e84b8a841d9e1c251cc132c6 (patch)
tree77d5f3699cf9fcf276b994d8164c4f86008f36ef /Documentation/bpf
parent03c517ee9eedd95472c36c6291fc97368b48c9e4 (diff)
bpf, docs: Fully document the JMP opcodes
Add pseudo-code to document all the different BPF_JMP / BPF_JMP64 opcodes. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20220103183556.41040-6-hch@lst.de
Diffstat (limited to 'Documentation/bpf')
-rw-r--r--Documentation/bpf/instruction-set.rst34
1 files changed, 17 insertions, 17 deletions
diff --git a/Documentation/bpf/instruction-set.rst b/Documentation/bpf/instruction-set.rst
index efba4d193185..88e8d6a9195c 100644
--- a/Documentation/bpf/instruction-set.rst
+++ b/Documentation/bpf/instruction-set.rst
@@ -125,24 +125,24 @@ BPF_JMP32 uses 32-bit wide operands while BPF_JMP uses 64-bit wide operands for
otherwise identical operations.
The code field encodes the operation as below:
- ======== ===== =========================
- code value description
- ======== ===== =========================
- BPF_JA 0x00 BPF_JMP only
- BPF_JEQ 0x10
- BPF_JGT 0x20
- BPF_JGE 0x30
- BPF_JSET 0x40
- BPF_JNE 0x50 jump '!='
- BPF_JSGT 0x60 signed '>'
- BPF_JSGE 0x70 signed '>='
+ ======== ===== ========================= ============
+ code value description notes
+ ======== ===== ========================= ============
+ BPF_JA 0x00 PC += off BPF_JMP only
+ BPF_JEQ 0x10 PC += off if dst == src
+ BPF_JGT 0x20 PC += off if dst > src unsigned
+ BPF_JGE 0x30 PC += off if dst >= src unsigned
+ BPF_JSET 0x40 PC += off if dst & src
+ BPF_JNE 0x50 PC += off if dst != src
+ BPF_JSGT 0x60 PC += off if dst > src signed
+ BPF_JSGE 0x70 PC += off if dst >= src signed
BPF_CALL 0x80 function call
- BPF_EXIT 0x90 function return
- BPF_JLT 0xa0 unsigned '<'
- BPF_JLE 0xb0 unsigned '<='
- BPF_JSLT 0xc0 signed '<'
- BPF_JSLE 0xd0 signed '<='
- ======== ===== =========================
+ BPF_EXIT 0x90 function / program return BPF_JMP only
+ BPF_JLT 0xa0 PC += off if dst < src unsigned
+ BPF_JLE 0xb0 PC += off if dst <= src unsigned
+ BPF_JSLT 0xc0 PC += off if dst < src signed
+ BPF_JSLE 0xd0 PC += off if dst <= src signed
+ ======== ===== ========================= ============
The eBPF program needs to store the return value into register R0 before doing a
BPF_EXIT.