diff options
author | Dave Thaler <dthaler@microsoft.com> | 2023-02-20 22:37:42 +0000 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-02-22 14:04:55 -0800 |
commit | 746ce767128598711a00d8df5713d4c3b3d9e9a7 (patch) | |
tree | e58d8d27f2548a33540dedfd67050a0f890ba993 /Documentation/bpf | |
parent | 9fa02892857ae2b3b699630e5ede28f72106e7e7 (diff) | |
download | lwn-746ce767128598711a00d8df5713d4c3b3d9e9a7.tar.gz lwn-746ce767128598711a00d8df5713d4c3b3d9e9a7.zip |
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 <dthaler@microsoft.com>
Acked-by: David Vernet <void@manifault.com>
Link: https://lore.kernel.org/r/20230220223742.1347-1-dthaler1968@googlemail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'Documentation/bpf')
-rw-r--r-- | Documentation/bpf/instruction-set.rst | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Documentation/bpf/instruction-set.rst b/Documentation/bpf/instruction-set.rst index af515de5fc38..01802ed9b29b 100644 --- a/Documentation/bpf/instruction-set.rst +++ b/Documentation/bpf/instruction-set.rst @@ -38,8 +38,9 @@ eBPF has two instruction encodings: * the wide instruction encoding, which appends a second 64-bit immediate (i.e., constant) value after the basic instruction for a total of 128 bits. -The basic instruction encoding is as follows, where MSB and LSB mean the most significant -bits and least significant bits, respectively: +The basic instruction encoding looks as follows for a little-endian processor, +where MSB and LSB mean the most significant bits and least significant bits, +respectively: ============= ======= ======= ======= ============ 32 bits (MSB) 16 bits 4 bits 4 bits 8 bits (LSB) @@ -63,6 +64,17 @@ imm offset src_reg dst_reg opcode **opcode** operation to perform +and as follows for a big-endian processor: + +============= ======= ======= ======= ============ +32 bits (MSB) 16 bits 4 bits 4 bits 8 bits (LSB) +============= ======= ======= ======= ============ +imm offset dst_reg src_reg opcode +============= ======= ======= ======= ============ + +Multi-byte fields ('imm' and 'offset') are similarly stored in +the byte order of the processor. + Note that most instructions do not use all of the fields. Unused fields shall be cleared to zero. |