tools/testing/selftests/bpf/progs/compute_live_registers.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/compute_live_registers.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/compute_live_registers.c- Extension
.c- Size
- 10424 bytes
- Lines
- 482
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
Dependency Surface
linux/bpf.hbpf/bpf_helpers.h../../../include/linux/filter.hbpf_arena_common.hbpf_misc.h
Detected Declarations
function assign_chainfunction arithmeticsfunction storefunction loadfunction endianfunction atomicfunction atomic_load_acq_store_relfunction regular_callfunction if1function if2function if3_jset_bugfunction loopfunction gotolfunction may_gotofunction ldimm64function ldabsfunction addr_space_castfunction aux1function subprog1function gotoxfunction kfunc_root
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include "../../../include/linux/filter.h"
#include <bpf_arena_common.h>
#include "bpf_misc.h"
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1);
__type(key, __u32);
__type(value, __u64);
} test_map SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_ARENA);
__uint(map_flags, BPF_F_MMAPABLE);
__uint(max_entries, 1);
} arena SEC(".maps");
SEC("socket")
__log_level(2)
__msg(" 0: .......... (b7) r0 = 42")
__msg(" 1: 0......... (bf) r1 = r0")
__msg(" 2: .1........ (bf) r2 = r1")
__msg(" 3: ..2....... (bf) r3 = r2")
__msg(" 4: ...3...... (bf) r4 = r3")
__msg(" 5: ....4..... (bf) r5 = r4")
__msg(" 6: .....5.... (bf) r6 = r5")
__msg(" 7: ......6... (bf) r7 = r6")
__msg(" 8: .......7.. (bf) r8 = r7")
__msg(" 9: ........8. (bf) r9 = r8")
__msg("10: .........9 (bf) r0 = r9")
__msg("11: 0......... (95) exit")
__naked void assign_chain(void)
{
asm volatile (
"r0 = 42;"
"r1 = r0;"
"r2 = r1;"
"r3 = r2;"
"r4 = r3;"
"r5 = r4;"
"r6 = r5;"
"r7 = r6;"
"r8 = r7;"
"r9 = r8;"
"r0 = r9;"
"exit;"
::: __clobber_all);
}
SEC("socket")
__log_level(2)
__msg("0: .......... (b7) r1 = 7")
__msg("1: .1........ (07) r1 += 7")
__msg("2: .......... (b7) r2 = 7")
__msg("3: ..2....... (b7) r3 = 42")
__msg("4: ..23...... (0f) r2 += r3")
__msg("5: .......... (b7) r0 = 0")
__msg("6: 0......... (95) exit")
__naked void arithmetics(void)
{
asm volatile (
"r1 = 7;"
"r1 += 7;"
"r2 = 7;"
"r3 = 42;"
"r2 += r3;"
"r0 = 0;"
"exit;"
::: __clobber_all);
}
#ifdef CAN_USE_BPF_ST
SEC("socket")
__log_level(2)
__msg(" 1: .1........ (07) r1 += -8")
__msg(" 2: .1........ (7a) *(u64 *)(r1 +0) = 7")
__msg(" 3: .1........ (b7) r2 = 42")
__msg(" 4: .12....... (7b) *(u64 *)(r1 +0) = r2")
__msg(" 5: .12....... (7b) *(u64 *)(r1 +0) = r2")
__msg(" 6: .......... (b7) r0 = 0")
__naked void store(void)
{
asm volatile (
"r1 = r10;"
"r1 += -8;"
"*(u64 *)(r1 +0) = 7;"
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_helpers.h`, `../../../include/linux/filter.h`, `bpf_arena_common.h`, `bpf_misc.h`.
- Detected declarations: `function assign_chain`, `function arithmetics`, `function store`, `function load`, `function endian`, `function atomic`, `function atomic_load_acq_store_rel`, `function regular_call`, `function if1`, `function if2`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.