Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Pull in the latest bpf/for-next #186

Merged
merged 94 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
e874208
bpf: Mark bpf prog stack with kmsan_unposion_memory in interpreter mode
Mar 28, 2024
e5e1a3a
selftests/bpf: Use connect_fd_to_fd in bpf_tcp_ca
Mar 26, 2024
4266709
selftests/bpf: Drop settimeo in do_test
Mar 26, 2024
201874f
Merge branch 'Use start_server and connect_fd_to_fd'
Mar 29, 2024
59f2f84
bpf: Avoid kfree_rcu() under lock in bpf_lpm_trie.
Mar 29, 2024
623bdd5
selftests/bpf: make multi-uprobe tests work in RELEASE=1 mode
anakryiko Mar 29, 2024
f7b6854
bpftool: Use simpler indentation in source rST for documentation
rameezrehman408 Mar 31, 2024
ea379b3
bpftool: Remove useless emphasis on command description in man pages
rameezrehman408 Mar 31, 2024
a70f5d8
bpftool: Clean-up typos, punctuation, list formatting in docs
rameezrehman408 Mar 31, 2024
ca4ddc2
bpf: Fix typo in uapi doc comments
dlech Mar 29, 2024
9dc182c
bpf: Add a verbose message if map limit is reached
aspsk Apr 2, 2024
965c616
selftests/bpf: Using llvm may_goto inline asm for cond_break macro
Apr 2, 2024
2a24e24
bpftool: Use __typeof__() instead of typeof() in BPF skeleton
anakryiko Apr 1, 2024
c186ed1
selftests/bpf: Skip test when perf_event_open returns EOPNOTSUPP
Apr 2, 2024
ce09cbd
bpf: Improve program stats run-time calculation
jfernandez Apr 2, 2024
15ea39a
libbpf: Use local bpf_helpers.h include
aibor Apr 2, 2024
c07b4bc
selftests/bpf: Add pid limit for mptcpify prog
Apr 2, 2024
339af57
bpf: Add arm64 JIT support for PROBE_MEM32 pseudo instructions.
puranjaymohan Mar 25, 2024
4dd3124
bpf: Add arm64 JIT support for bpf_addr_space_cast instruction.
puranjaymohan Mar 25, 2024
49b73fa
Merge branch 'bpf-arm64-add-support-for-bpf-arena'
Apr 3, 2024
7effe3f
tools: Add ethtool.h header to tooling infra
tvyavaha Apr 2, 2024
c3bd015
selftests/xsk: Make batch size variable
tvyavaha Apr 2, 2024
90a695c
selftests/bpf: Implement get_hw_ring_size function to retrieve curren…
tvyavaha Apr 2, 2024
bee3a7b
selftests/bpf: Implement set_hw_ring_size function to configure inter…
tvyavaha Apr 2, 2024
776021e
selftests/xsk: Introduce set_ring_size function with a retry mechanis…
tvyavaha Apr 2, 2024
c4f9605
selftests/xsk: Test AF_XDP functionality under minimal ring configura…
tvyavaha Apr 2, 2024
c53908b
selftests/xsk: Add new test case for AF_XDP under max ring sizes
tvyavaha Apr 2, 2024
2e11424
bpf: Replace deprecated strncpy with strscpy
JustinStitt Apr 2, 2024
7bdbf74
bpf: add special internal-only MOV instruction to resolve per-CPU addrs
anakryiko Apr 2, 2024
1ae6921
bpf: inline bpf_get_smp_processor_id() helper
anakryiko Apr 2, 2024
db69718
bpf: inline bpf_map_lookup_elem() for PERCPU_ARRAY maps
anakryiko Apr 2, 2024
0b56e63
bpf: inline bpf_map_lookup_elem() helper for PERCPU_HASH map
anakryiko Apr 2, 2024
519e1de
Merge branch 'add-internal-only-bpf-per-cpu-instruction'
Apr 3, 2024
1e9e0b8
bpf: handle CONFIG_SMP=n configuration in x86 BPF JIT
anakryiko Apr 4, 2024
af682b7
bpf: Optimize emit_mov_imm64().
Apr 1, 2024
633a6e0
bpf, riscv: Implement PROBE_MEM32 pseudo instructions
puranjaymohan Apr 4, 2024
21ab0b6
bpf, riscv: Implement bpf_addr_space_cast instruction
puranjaymohan Apr 4, 2024
5e6a3c1
bpf: make bpf_get_branch_snapshot() architecture-agnostic
anakryiko Apr 4, 2024
314a536
bpf: inline bpf_get_branch_snapshot() helper
anakryiko Apr 4, 2024
d82c045
Merge branch 'inline-bpf_get_branch_snapshot-bpf-helper'
Apr 4, 2024
478a535
bpftool: Mount bpffs on provided dir instead of parent dir
valdaarhun Apr 4, 2024
f917170
bpf: Pack struct bpf_fib_lookup
aspsk Apr 3, 2024
1f2a74b
bpf: prevent r10 register from being marked as precise
anakryiko Apr 4, 2024
343ca81
selftests/bpf: add fp-leaking precise subprog result tests
anakryiko Apr 4, 2024
58babe2
bpf: fix perf_snapshot_branch_stack link failure
arndb Apr 5, 2024
0a52562
bpf: store both map ptr and state in bpf_insn_aux_data
Apr 5, 2024
9d482da
bpf: allow invoking bpf_for_each_map_elem with different maps
Apr 5, 2024
fecb159
selftests/bpf: add test for bpf_for_each_map_elem() with different maps
Apr 5, 2024
2709547
Merge branch 'bpf-allow-bpf_for_each_map_elem-helper-with-different-i…
Apr 5, 2024
ba0cbe2
selftests/bpf: Make sure libbpf doesn't enforce the signature of a fu…
ThinkerYzu1 Apr 4, 2024
00d5d22
bpf, docs: Editorial nits in instruction-set.rst
Apr 5, 2024
a8e03b6
bpf: Allow invoking kfuncs from BPF_PROG_TYPE_SYSCALL progs
Byte-Lab Apr 5, 2024
1bc724a
selftests/bpf: Verify calling core kfuncs from BPF_PROG_TYPE_SYCALL
Byte-Lab Apr 5, 2024
d564ffd
Merge branch 'bpf-allow-invoking-kfuncs-from-bpf_prog_type_syscall-pr…
anakryiko Apr 5, 2024
5bd2ed6
libbpf: Start v1.5 development cycle
Apr 6, 2024
13e8125
libbpf: ringbuf: Allow to consume up to a certain amount of items
Apr 6, 2024
4d22ea9
libbpf: Add ring__consume_n / ring_buffer__consume_n
Apr 6, 2024
50408d7
Merge branch 'libbpf-api-to-partially-consume-items-from-ringbuffer'
anakryiko Apr 6, 2024
bb761fc
selftests/bpf: eliminate warning of get_cgroup_id_from_path()
JasonXing Apr 6, 2024
d503a04
bpf: Add support for certain atomics in bpf_arena to x86 JIT
Apr 5, 2024
d0a2ba1
selftests/bpf: Add tests for atomics in bpf_arena.
Apr 5, 2024
699c23f
bpf: Add bpf_link support for sk_msg and sk_skb progs
Apr 10, 2024
849989a
libbpf: Add bpf_link support for BPF_PROG_TYPE_SOCKMAP
Apr 10, 2024
1f3e209
bpftool: Add link dump support for BPF_LINK_TYPE_SOCKMAP
Apr 10, 2024
a15d58b
selftests/bpf: Refactor out helper functions for a few tests
Apr 10, 2024
8ba218e
selftests/bpf: Add some tests with new bpf_program__attach_sockmap() …
Apr 10, 2024
ded8c00
Merge branch 'bpf-add-bpf_link-support-for-sk_msg-and-sk_skb-progs'
Apr 11, 2024
ffa6b26
selftests/bpf: Enable tests for atomics with cpuv4
Apr 10, 2024
d75142d
selftests/bpf: Fix umount cgroup2 error in test_sockmap
Apr 9, 2024
68acca6
selftests/bpf: Add struct send_recv_arg
Apr 11, 2024
dc34e44
selftests/bpf: Export send_recv_data helper
Apr 11, 2024
c53e853
Merge branch 'export send_recv_data'
Apr 11, 2024
23cc4fe
bpftool: Fix typo in error message
toblux Apr 11, 2024
4d4992f
selftests/bpf: Add read_trace_pipe_iter function
olsajiri Apr 10, 2024
fc5eb4a
btf: Avoid weak external references
ardbiesheuvel Apr 15, 2024
dac045f
bpf, tests: Fix typos in comments
cp0613 Apr 15, 2024
1f58661
bpf: Harden and/or/xor value tracking in verifier
harishankarv Apr 16, 2024
986e766
bpftool: Update documentation where progs/maps can be passed by name
qmonnet Apr 13, 2024
ad2d22b
bpftool: Address minor issues in bash completion
qmonnet Apr 13, 2024
9213e52
libbpf: Fix misaligned array closing bracket
qdeslandes Apr 13, 2024
e739e01
libbpf: Fix dump of subsequent char arrays
qdeslandes Apr 13, 2024
462e5e2
bpf: Fix JIT of is_mov_percpu_addr instruction.
Apr 17, 2024
9c598a8
selftests/bpf: Add start_server_addr helper
Apr 18, 2024
9851382
selftests/bpf: Use start_server_addr in cls_redirect
Apr 18, 2024
a2e4979
selftests/bpf: Use start_server_addr in sk_assign
Apr 18, 2024
db9994d
selftests/bpf: Update arguments of connect_to_addr
Apr 18, 2024
805b4d9
selftests/bpf: Use connect_to_addr in cls_redirect
Apr 18, 2024
63a5182
selftests/bpf: Use connect_to_addr in sk_assign
Apr 18, 2024
2ea0aa5
Merge branch 'use network helpers, part 1'
Apr 20, 2024
db50040
bpf, docs: Clarify helper ID and pointer terms in instruction-set.rst
Apr 19, 2024
735f5b8
bpf, docs: Fix formatting nit in instruction-set.rst
Apr 19, 2024
e1a7545
bpf: Fix typo in function save_aux_ptr_type
auyer Apr 17, 2024
a7de265
bpf: Fix typos in comments
auyer Apr 17, 2024
cc2764e
Merge branch 'bpf/for-next' into pull-bpf-for-next
htejun Apr 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 51 additions & 46 deletions Documentation/bpf/standardization/instruction-set.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ a type's signedness (`S`) and bit width (`N`), respectively.
===== =========

For example, `u32` is a type whose valid values are all the 32-bit unsigned
numbers and `s16` is a types whose valid values are all the 16-bit signed
numbers and `s16` is a type whose valid values are all the 16-bit signed
numbers.

Functions
Expand Down Expand Up @@ -108,7 +108,7 @@ conformance group means it must support all instructions in that conformance
group.

The use of named conformance groups enables interoperability between a runtime
that executes instructions, and tools as such compilers that generate
that executes instructions, and tools such as compilers that generate
instructions for the runtime. Thus, capability discovery in terms of
conformance groups might be done manually by users or automatically by tools.

Expand Down Expand Up @@ -181,10 +181,13 @@ A basic instruction is encoded as follows::
(`64-bit immediate instructions`_ reuse this field for other purposes)

**dst_reg**
destination register number (0-10)
destination register number (0-10), unless otherwise specified
(future instructions might reuse this field for other purposes)

**offset**
signed integer offset used with pointer arithmetic
signed integer offset used with pointer arithmetic, except where
otherwise specified (some arithmetic instructions reuse this field
for other purposes)

**imm**
signed integer immediate value
Expand Down Expand Up @@ -228,10 +231,12 @@ This is depicted in the following figure::
operation to perform, encoded as explained above

**regs**
The source and destination register numbers, encoded as explained above
The source and destination register numbers (unless otherwise
specified), encoded as explained above

**offset**
signed integer offset used with pointer arithmetic
signed integer offset used with pointer arithmetic, unless
otherwise specified

**imm**
signed integer immediate value
Expand Down Expand Up @@ -342,8 +347,8 @@ where '(u32)' indicates that the upper 32 bits are zeroed.

dst = dst ^ imm

Note that most instructions have instruction offset of 0. Only three instructions
(``SDIV``, ``SMOD``, ``MOVSX``) have a non-zero offset.
Note that most arithmetic instructions have 'offset' set to 0. Only three instructions
(``SDIV``, ``SMOD``, ``MOVSX``) have a non-zero 'offset'.

Division, multiplication, and modulo operations for ``ALU`` are part
of the "divmul32" conformance group, and division, multiplication, and
Expand All @@ -365,15 +370,15 @@ Note that there are varying definitions of the signed modulo operation
when the dividend or divisor are negative, where implementations often
vary by language such that Python, Ruby, etc. differ from C, Go, Java,
etc. This specification requires that signed modulo use truncated division
(where -13 % 3 == -1) as implemented in C, Go, etc.:
(where -13 % 3 == -1) as implemented in C, Go, etc.::

a % n = a - n * trunc(a / n)

The ``MOVSX`` instruction does a move operation with sign extension.
``{MOVSX, X, ALU}`` :term:`sign extends<Sign Extend>` 8-bit and 16-bit operands into 32
bit operands, and zeroes the remaining upper 32 bits.
``{MOVSX, X, ALU}`` :term:`sign extends<Sign Extend>` 8-bit and 16-bit operands into
32-bit operands, and zeroes the remaining upper 32 bits.
``{MOVSX, X, ALU64}`` :term:`sign extends<Sign Extend>` 8-bit, 16-bit, and 32-bit
operands into 64 bit operands. Unlike other arithmetic instructions,
operands into 64-bit operands. Unlike other arithmetic instructions,
``MOVSX`` is only defined for register source operands (``X``).

The ``NEG`` instruction is only defined when the source bit is clear
Expand Down Expand Up @@ -411,19 +416,19 @@ conformance group.

Examples:

``{END, TO_LE, ALU}`` with imm = 16/32/64 means::
``{END, TO_LE, ALU}`` with 'imm' = 16/32/64 means::

dst = htole16(dst)
dst = htole32(dst)
dst = htole64(dst)

``{END, TO_BE, ALU}`` with imm = 16/32/64 means::
``{END, TO_BE, ALU}`` with 'imm' = 16/32/64 means::

dst = htobe16(dst)
dst = htobe32(dst)
dst = htobe64(dst)

``{END, TO_LE, ALU64}`` with imm = 16/32/64 means::
``{END, TO_LE, ALU64}`` with 'imm' = 16/32/64 means::

dst = bswap16(dst)
dst = bswap32(dst)
Expand All @@ -438,27 +443,27 @@ otherwise identical operations, and indicates the base64 conformance
group unless otherwise specified.
The 'code' field encodes the operation as below:

======== ===== ======= =============================== ===================================================
code value src_reg description notes
======== ===== ======= =============================== ===================================================
JA 0x0 0x0 PC += offset {JA, K, JMP} only
JA 0x0 0x0 PC += imm {JA, K, JMP32} only
======== ===== ======= ================================= ===================================================
code value src_reg description notes
======== ===== ======= ================================= ===================================================
JA 0x0 0x0 PC += offset {JA, K, JMP} only
JA 0x0 0x0 PC += imm {JA, K, JMP32} only
JEQ 0x1 any PC += offset if dst == src
JGT 0x2 any PC += offset if dst > src unsigned
JGE 0x3 any PC += offset if dst >= src unsigned
JGT 0x2 any PC += offset if dst > src unsigned
JGE 0x3 any PC += offset if dst >= src unsigned
JSET 0x4 any PC += offset if dst & src
JNE 0x5 any PC += offset if dst != src
JSGT 0x6 any PC += offset if dst > src signed
JSGE 0x7 any PC += offset if dst >= src signed
CALL 0x8 0x0 call helper function by address {CALL, K, JMP} only, see `Helper functions`_
CALL 0x8 0x1 call PC += imm {CALL, K, JMP} only, see `Program-local functions`_
CALL 0x8 0x2 call helper function by BTF ID {CALL, K, JMP} only, see `Helper functions`_
EXIT 0x9 0x0 return {CALL, K, JMP} only
JLT 0xa any PC += offset if dst < src unsigned
JLE 0xb any PC += offset if dst <= src unsigned
JSLT 0xc any PC += offset if dst < src signed
JSLE 0xd any PC += offset if dst <= src signed
======== ===== ======= =============================== ===================================================
JSGT 0x6 any PC += offset if dst > src signed
JSGE 0x7 any PC += offset if dst >= src signed
CALL 0x8 0x0 call helper function by static ID {CALL, K, JMP} only, see `Helper functions`_
CALL 0x8 0x1 call PC += imm {CALL, K, JMP} only, see `Program-local functions`_
CALL 0x8 0x2 call helper function by BTF ID {CALL, K, JMP} only, see `Helper functions`_
EXIT 0x9 0x0 return {CALL, K, JMP} only
JLT 0xa any PC += offset if dst < src unsigned
JLE 0xb any PC += offset if dst <= src unsigned
JSLT 0xc any PC += offset if dst < src signed
JSLE 0xd any PC += offset if dst <= src signed
======== ===== ======= ================================= ===================================================

The BPF program needs to store the return value into register R0 before doing an
``EXIT``.
Expand All @@ -475,7 +480,7 @@ where 's>=' indicates a signed '>=' comparison.

gotol +imm

where 'imm' means the branch offset comes from insn 'imm' field.
where 'imm' means the branch offset comes from the 'imm' field.

Note that there are two flavors of ``JA`` instructions. The
``JMP`` class permits a 16-bit jump offset specified by the 'offset'
Expand All @@ -493,26 +498,26 @@ Helper functions
Helper functions are a concept whereby BPF programs can call into a
set of function calls exposed by the underlying platform.

Historically, each helper function was identified by an address
encoded in the imm field. The available helper functions may differ
for each program type, but address values are unique across all program types.
Historically, each helper function was identified by a static ID
encoded in the 'imm' field. The available helper functions may differ
for each program type, but static IDs are unique across all program types.

Platforms that support the BPF Type Format (BTF) support identifying
a helper function by a BTF ID encoded in the imm field, where the BTF ID
a helper function by a BTF ID encoded in the 'imm' field, where the BTF ID
identifies the helper name and type.

Program-local functions
~~~~~~~~~~~~~~~~~~~~~~~
Program-local functions are functions exposed by the same BPF program as the
caller, and are referenced by offset from the call instruction, similar to
``JA``. The offset is encoded in the imm field of the call instruction.
A ``EXIT`` within the program-local function will return to the caller.
``JA``. The offset is encoded in the 'imm' field of the call instruction.
An ``EXIT`` within the program-local function will return to the caller.

Load and store instructions
===========================

For load and store instructions (``LD``, ``LDX``, ``ST``, and ``STX``), the
8-bit 'opcode' field is divided as::
8-bit 'opcode' field is divided as follows::

+-+-+-+-+-+-+-+-+
|mode |sz |class|
Expand Down Expand Up @@ -580,7 +585,7 @@ instructions that transfer data between a register and memory.

dst = *(signed size *) (src + offset)

Where size is one of: ``B``, ``H``, or ``W``, and
Where '<size>' is one of: ``B``, ``H``, or ``W``, and
'signed size' is one of: s8, s16, or s32.

Atomic operations
Expand Down Expand Up @@ -662,11 +667,11 @@ src_reg pseudocode imm type dst type
======= ========================================= =========== ==============
0x0 dst = (next_imm << 32) | imm integer integer
0x1 dst = map_by_fd(imm) map fd map
0x2 dst = map_val(map_by_fd(imm)) + next_imm map fd data pointer
0x3 dst = var_addr(imm) variable id data pointer
0x4 dst = code_addr(imm) integer code pointer
0x2 dst = map_val(map_by_fd(imm)) + next_imm map fd data address
0x3 dst = var_addr(imm) variable id data address
0x4 dst = code_addr(imm) integer code address
0x5 dst = map_by_idx(imm) map index map
0x6 dst = map_val(map_by_idx(imm)) + next_imm map index data pointer
0x6 dst = map_val(map_by_idx(imm)) + next_imm map index data address
======= ========================================= =========== ==============

where
Expand Down
Loading