Commit d405c740 authored by Jiong Wang's avatar Jiong Wang Committed by Alexei Starovoitov
Browse files

bpf: allocate 0x06 to new eBPF instruction class JMP32



The new eBPF instruction class JMP32 uses the reserved class number 0x6.
Kernel BPF ISA documentation updated accordingly.

Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarJiong Wang <jiong.wang@netronome.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent dbbd79ae
Loading
Loading
Loading
Loading
+8 −7
Original line number Original line Diff line number Diff line
@@ -865,7 +865,7 @@ Three LSB bits store instruction class which is one of:
  BPF_STX   0x03          BPF_STX   0x03
  BPF_STX   0x03          BPF_STX   0x03
  BPF_ALU   0x04          BPF_ALU   0x04
  BPF_ALU   0x04          BPF_ALU   0x04
  BPF_JMP   0x05          BPF_JMP   0x05
  BPF_JMP   0x05          BPF_JMP   0x05
  BPF_RET   0x06          [ class 6 unused, for future if needed ]
  BPF_RET   0x06          BPF_JMP32 0x06
  BPF_MISC  0x07          BPF_ALU64 0x07
  BPF_MISC  0x07          BPF_ALU64 0x07


When BPF_CLASS(code) == BPF_ALU or BPF_JMP, 4th bit encodes source operand ...
When BPF_CLASS(code) == BPF_ALU or BPF_JMP, 4th bit encodes source operand ...
@@ -902,9 +902,9 @@ If BPF_CLASS(code) == BPF_ALU or BPF_ALU64 [ in eBPF ], BPF_OP(code) is one of:
  BPF_ARSH  0xc0  /* eBPF only: sign extending shift right */
  BPF_ARSH  0xc0  /* eBPF only: sign extending shift right */
  BPF_END   0xd0  /* eBPF only: endianness conversion */
  BPF_END   0xd0  /* eBPF only: endianness conversion */


If BPF_CLASS(code) == BPF_JMP, BPF_OP(code) is one of:
If BPF_CLASS(code) == BPF_JMP or BPF_JMP32 [ in eBPF ], BPF_OP(code) is one of:


  BPF_JA    0x00
  BPF_JA    0x00  /* BPF_JMP only */
  BPF_JEQ   0x10
  BPF_JEQ   0x10
  BPF_JGT   0x20
  BPF_JGT   0x20
  BPF_JGE   0x30
  BPF_JGE   0x30
@@ -912,8 +912,8 @@ If BPF_CLASS(code) == BPF_JMP, BPF_OP(code) is one of:
  BPF_JNE   0x50  /* eBPF only: jump != */
  BPF_JNE   0x50  /* eBPF only: jump != */
  BPF_JSGT  0x60  /* eBPF only: signed '>' */
  BPF_JSGT  0x60  /* eBPF only: signed '>' */
  BPF_JSGE  0x70  /* eBPF only: signed '>=' */
  BPF_JSGE  0x70  /* eBPF only: signed '>=' */
  BPF_CALL  0x80  /* eBPF only: function call */
  BPF_CALL  0x80  /* eBPF BPF_JMP only: function call */
  BPF_EXIT  0x90  /* eBPF only: function return */
  BPF_EXIT  0x90  /* eBPF BPF_JMP only: function return */
  BPF_JLT   0xa0  /* eBPF only: unsigned '<' */
  BPF_JLT   0xa0  /* eBPF only: unsigned '<' */
  BPF_JLE   0xb0  /* eBPF only: unsigned '<=' */
  BPF_JLE   0xb0  /* eBPF only: unsigned '<=' */
  BPF_JSLT  0xc0  /* eBPF only: signed '<' */
  BPF_JSLT  0xc0  /* eBPF only: signed '<' */
@@ -936,8 +936,9 @@ Classic BPF wastes the whole BPF_RET class to represent a single 'ret'
operation. Classic BPF_RET | BPF_K means copy imm32 into return register
operation. Classic BPF_RET | BPF_K means copy imm32 into return register
and perform function exit. eBPF is modeled to match CPU, so BPF_JMP | BPF_EXIT
and perform function exit. eBPF is modeled to match CPU, so BPF_JMP | BPF_EXIT
in eBPF means function exit only. The eBPF program needs to store return
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
value into register R0 before doing a BPF_EXIT. Class 6 in eBPF is used as
unused and reserved for future use.
BPF_JMP32 to mean exactly the same operations as BPF_JMP, but with 32-bit wide
operands for the comparisons instead.


For load and store instructions the 8-bit 'code' field is divided as:
For load and store instructions the 8-bit 'code' field is divided as:


+1 −0
Original line number Original line Diff line number Diff line
@@ -14,6 +14,7 @@
/* Extended instruction set based on top of classic BPF */
/* Extended instruction set based on top of classic BPF */


/* instruction classes */
/* instruction classes */
#define BPF_JMP32	0x06	/* jmp mode in word width */
#define BPF_ALU64	0x07	/* alu mode in double word width */
#define BPF_ALU64	0x07	/* alu mode in double word width */


/* ld/ldx fields */
/* ld/ldx fields */
+1 −0
Original line number Original line Diff line number Diff line
@@ -14,6 +14,7 @@
/* Extended instruction set based on top of classic BPF */
/* Extended instruction set based on top of classic BPF */


/* instruction classes */
/* instruction classes */
#define BPF_JMP32	0x06	/* jmp mode in word width */
#define BPF_ALU64	0x07	/* alu mode in double word width */
#define BPF_ALU64	0x07	/* alu mode in double word width */


/* ld/ldx fields */
/* ld/ldx fields */