BPF List
 help / color / mirror / Atom feed
* [PATCH] update the consistency issue in documentation
@ 2024-01-04  3:12 Aoyang Fang (SSE, 222010547)
  2024-01-04  3:12 ` [Bpf] " Aoyang Fang (SSE, 222010547)
  2024-01-04 19:12 ` dthaler1968
  0 siblings, 2 replies; 7+ messages in thread
From: Aoyang Fang (SSE, 222010547) @ 2024-01-04  3:12 UTC (permalink / raw)
  To: bpf@vger.kernel.org, bpf@ietf.org; +Cc: void@manifault.com

From fa9f3f47ddeb3e9a615c17aea57d2ecd53a7d201 Mon Sep 17 00:00:00 2001
From: lincyawer <53161583+Lincyaw@users.noreply.github.com>
Date: Thu, 4 Jan 2024 10:51:36 +0800
Subject: [PATCH] The original documentation of BPF_JMP instructions is somehow
misleading. The code part of instruction, e.g., BPF_JEQ's value is noted as
0x1, however, in `include/uapi/linux/bpf.h`, the value of BPF_JEQ is 0x10. At
the same time, the description convention is inconsistent with the BPF_ALU,
whose code are also 4bit, but the value of BPF_ADD is 0x00

Signed-off-by: lincyawer <53161583+Lincyaw@users.noreply.github.com>
---
.../bpf/standardization/instruction-set.rst | 34 +++++++++----------
1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/Documentation/bpf/standardization/instruction-set.rst b/Documentation/bpf/standardization/instruction-set.rst
index 245b6defc..dee3b1fa8 100644
--- a/Documentation/bpf/standardization/instruction-set.rst
+++ b/Documentation/bpf/standardization/instruction-set.rst
@@ -355,23 +355,23 @@ The 'code' field encodes the operation as below:
======== ===== === =========================================== =========================================
code value src description notes
======== ===== === =========================================== =========================================
-BPF_JA 0x0 0x0 PC += offset BPF_JMP class
-BPF_JA 0x0 0x0 PC += imm BPF_JMP32 class
-BPF_JEQ 0x1 any PC += offset if dst == src
-BPF_JGT 0x2 any PC += offset if dst > src unsigned
-BPF_JGE 0x3 any PC += offset if dst >= src unsigned
-BPF_JSET 0x4 any PC += offset if dst & src
-BPF_JNE 0x5 any PC += offset if dst != src
-BPF_JSGT 0x6 any PC += offset if dst > src signed
-BPF_JSGE 0x7 any PC += offset if dst >= src signed
-BPF_CALL 0x8 0x0 call helper function by address see `Helper functions`_
-BPF_CALL 0x8 0x1 call PC += imm see `Program-local functions`_
-BPF_CALL 0x8 0x2 call helper function by BTF ID see `Helper functions`_
-BPF_EXIT 0x9 0x0 return BPF_JMP only
-BPF_JLT 0xa any PC += offset if dst < src unsigned
-BPF_JLE 0xb any PC += offset if dst <= src unsigned
-BPF_JSLT 0xc any PC += offset if dst < src signed
-BPF_JSLE 0xd any PC += offset if dst <= src signed
+BPF_JA 0x00 0x0 PC += offset BPF_JMP class
+BPF_JA 0x00 0x0 PC += imm BPF_JMP32 class
+BPF_JEQ 0x10 any PC += offset if dst == src
+BPF_JGT 0x20 any PC += offset if dst > src unsigned
+BPF_JGE 0x30 any PC += offset if dst >= src unsigned
+BPF_JSET 0x40 any PC += offset if dst & src
+BPF_JNE 0x50 any PC += offset if dst != src
+BPF_JSGT 0x60 any PC += offset if dst > src signed
+BPF_JSGE 0x70 any PC += offset if dst >= src signed
+BPF_CALL 0x80 0x0 call helper function by address see `Helper functions`_
+BPF_CALL 0x80 0x1 call PC += imm see `Program-local functions`_
+BPF_CALL 0x80 0x2 call helper function by BTF ID see `Helper functions`_
+BPF_EXIT 0x90 0x0 return BPF_JMP only
+BPF_JLT 0xa0 any PC += offset if dst < src unsigned
+BPF_JLE 0xb0 any PC += offset if dst <= src unsigned
+BPF_JSLT 0xc0 any PC += offset if dst < src signed
+BPF_JSLE 0xd0 any PC += offset if dst <= src signed
======== ===== === =========================================== =========================================
The BPF program needs to store the return value into register R0 before doing a
-- 
2.42.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread
[parent not found: <F349E672-63EB-4DA3-84F8-45E360E02594@link.cuhk.edu.cn>]

end of thread, other threads:[~2024-01-05  1:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-04  3:12 [PATCH] update the consistency issue in documentation Aoyang Fang (SSE, 222010547)
2024-01-04  3:12 ` [Bpf] " Aoyang Fang (SSE, 222010547)
2024-01-04 19:12 ` dthaler1968
2024-01-04 19:12   ` [Bpf] " dthaler1968=40googlemail.com
     [not found]   ` <20654405-C500-4A24-B09E-A28B25DF32AC@link.cuhk.edu.cn>
2024-01-05  1:31     ` dthaler1968
2024-01-05  1:31       ` [Bpf] " dthaler1968=40googlemail.com
     [not found] <F349E672-63EB-4DA3-84F8-45E360E02594@link.cuhk.edu.cn>
2024-01-04  3:39 ` David Vernet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox