Skip to content

Commit

Permalink
bpf, docs: Add signed comparison example
Browse files Browse the repository at this point in the history
Improve clarity by adding an example of a signed comparison instruction

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Acked-by: David Vernet <void@manifault.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/r/20230310233814.4641-1-dthaler1968@googlemail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Dave Thaler authored and Alexei Starovoitov committed Mar 14, 2023
1 parent ab4c15f commit b9fe8e8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Documentation/bpf/instruction-set.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Documentation conventions
=========================

For brevity, this document uses the type notion "u64", "u32", etc.
to mean an unsigned integer whose width is the specified number of bits.
to mean an unsigned integer whose width is the specified number of bits,
and "s32", etc. to mean a signed integer of the specified number of bits.

Registers and calling convention
================================
Expand Down Expand Up @@ -264,6 +265,14 @@ BPF_JSLE 0xd0 PC += off if dst <= src signed
The eBPF program needs to store the return value into register R0 before doing a
BPF_EXIT.

Example:

``BPF_JSGE | BPF_X | BPF_JMP32`` (0x7e) means::

if (s32)dst s>= (s32)src goto +offset

where 's>=' indicates a signed '>=' comparison.

Helper functions
~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit b9fe8e8

Please sign in to comment.