Skip to content

Commit 746ce76

Browse files
dthalerAlexei Starovoitov
authored andcommitted
bpf, docs: Add explanation of endianness
Document the discussion from the email thread on the IETF bpf list, where it was explained that the raw format varies by endianness of the processor. Signed-off-by: Dave Thaler <[email protected]> Acked-by: David Vernet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 9fa0289 commit 746ce76

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Documentation/bpf/instruction-set.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ eBPF has two instruction encodings:
3838
* the wide instruction encoding, which appends a second 64-bit immediate (i.e.,
3939
constant) value after the basic instruction for a total of 128 bits.
4040

41-
The basic instruction encoding is as follows, where MSB and LSB mean the most significant
42-
bits and least significant bits, respectively:
41+
The basic instruction encoding looks as follows for a little-endian processor,
42+
where MSB and LSB mean the most significant bits and least significant bits,
43+
respectively:
4344

4445
============= ======= ======= ======= ============
4546
32 bits (MSB) 16 bits 4 bits 4 bits 8 bits (LSB)
@@ -63,6 +64,17 @@ imm offset src_reg dst_reg opcode
6364
**opcode**
6465
operation to perform
6566

67+
and as follows for a big-endian processor:
68+
69+
============= ======= ======= ======= ============
70+
32 bits (MSB) 16 bits 4 bits 4 bits 8 bits (LSB)
71+
============= ======= ======= ======= ============
72+
imm offset dst_reg src_reg opcode
73+
============= ======= ======= ======= ============
74+
75+
Multi-byte fields ('imm' and 'offset') are similarly stored in
76+
the byte order of the processor.
77+
6678
Note that most instructions do not use all of the fields.
6779
Unused fields shall be cleared to zero.
6880

0 commit comments

Comments
 (0)