Skip to content

Commit

Permalink
bpf, docs: Add a setion to explain the basic instruction encoding
Browse files Browse the repository at this point in the history
The eBPF instruction set document does not currently document the basic
instruction encoding.  Add a section to do that.

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
Christoph Hellwig authored and Alexei Starovoitov committed Jan 5, 2022
1 parent ca796fe commit 62e4683
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Documentation/bpf/instruction-set.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,22 @@ The eBPF calling convention is defined as:
R0 - R5 are scratch registers and eBPF programs needs to spill/fill them if
necessary across calls.

Instruction encoding
====================

eBPF uses 64-bit instructions with the following encoding:

============= ======= =============== ==================== ============
32 bits (MSB) 16 bits 4 bits 4 bits 8 bits (LSB)
============= ======= =============== ==================== ============
immediate offset source register destination register opcode
============= ======= =============== ==================== ============

Note that most instructions do not use all of the fields.
Unused fields shall be cleared to zero.

Instruction classes
===================
-------------------

The three LSB bits of the 'opcode' field store the instruction class:

Expand Down

0 comments on commit 62e4683

Please sign in to comment.