diff mbox series

[PATH,bpf-next,01/13] bpf: encoding description and macros for JMP32

Message ID 1545259460-13376-2-git-send-email-jiong.wang@netronome.com
State Changes Requested, archived
Delegated to: BPF Maintainers
Headers show
Series bpf: propose new jmp32 instructions | expand

Commit Message

Jiong Wang Dec. 19, 2018, 10:44 p.m. UTC
This patch update kernel BPF documents for JMP32 encoding.

Two macros are added for JMP32 to easy programming.

Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
---
 Documentation/networking/filter.txt | 10 ++++++++++
 include/uapi/linux/bpf.h            |  4 ++++
 tools/include/uapi/linux/bpf.h      |  4 ++++
 3 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/Documentation/networking/filter.txt b/Documentation/networking/filter.txt
index 2196b82..5f6fafa 100644
--- a/Documentation/networking/filter.txt
+++ b/Documentation/networking/filter.txt
@@ -939,6 +939,16 @@  in eBPF means function exit only. The eBPF program needs to store return
 value into register R0 before doing a BPF_EXIT. Class 6 in eBPF is currently
 unused and reserved for future use.
 
+And BPF_JMP has sub-opcode. When BPF_SRC(code) == BPF_X, the encoding is at
+insn->imm, starting from LSB. When BPF_SRC(code) == BPF_K, the encoding is at
+insn->src_reg, starting from LSB as well. Only one bit is used for sub-opcode at
+the moment, all other bits in imm and src_reg are still reserved and should be
+zeroed. The BPF_JMP sub-opcode is:
+
+  BPF_JMP_SUBOP_32BIT	0x1
+
+It means jump insn use 32-bit sub-register when doing comparison.
+
 For load and store instructions the 8-bit 'code' field is divided as:
 
   +--------+--------+-------------------+
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index e7d57e89..f30d646 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -42,6 +42,10 @@ 
 #define BPF_CALL	0x80	/* function call */
 #define BPF_EXIT	0x90	/* function return */
 
+/* jmp has sub-opcode */
+#define BPF_JMP_SUBOP_MASK	0x1
+#define BPF_JMP_SUBOP_32BIT	0x1
+
 /* Register numbers */
 enum {
 	BPF_REG_0 = 0,
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index e7d57e89..f30d646 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -42,6 +42,10 @@ 
 #define BPF_CALL	0x80	/* function call */
 #define BPF_EXIT	0x90	/* function return */
 
+/* jmp has sub-opcode */
+#define BPF_JMP_SUBOP_MASK	0x1
+#define BPF_JMP_SUBOP_32BIT	0x1
+
 /* Register numbers */
 enum {
 	BPF_REG_0 = 0,