tools/testing/selftests/bpf/progs/verifier_align.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_align.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/verifier_align.c- Extension
.c- Size
- 16977 bytes
- Lines
- 582
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf.hbpf/bpf_helpers.hbpf_misc.h
Detected Declarations
function __log_levelfunction __log_levelfunction __log_levelfunction __log_levelfunction unknown_shiftfunction unknown_mulfunction packet_const_offsetfunction packet_variable_offsetfunction packet_variable_offset_2function dubious_pointer_arithmeticfunction variable_subtractionfunction pointer_variable_subtraction
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
/* Converted from tools/testing/selftests/bpf/prog_tests/align.c */
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"
/* Four tests of known constants. These aren't staggeringly
* interesting since we track exact values now.
*/
SEC("tc")
__success __log_level(2)
__flag(BPF_F_ANY_ALIGNMENT)
__msg("0: R1=ctx() R10=fp0")
__msg("0: {{.*}} R3=2")
__msg("1: {{.*}} R3=4")
__msg("2: {{.*}} R3=8")
__msg("3: {{.*}} R3=16")
__msg("4: {{.*}} R3=32")
__naked void mov(void)
{
asm volatile (" \
r3 = 2; \
r3 = 4; \
r3 = 8; \
r3 = 16; \
r3 = 32; \
r0 = 0; \
exit; \
" ::: __clobber_all);
}
SEC("tc")
__success __log_level(2)
__flag(BPF_F_ANY_ALIGNMENT)
__msg("0: R1=ctx() R10=fp0")
__msg("0: {{.*}}R3=1")
__msg("1: {{.*}}R3=2")
__msg("2: {{.*}}R3=4")
__msg("3: {{.*}}R3=8")
__msg("4: {{.*}}R3=16")
__msg("5: {{.*}}R3=1")
__msg("6: {{.*}}R4=32")
__msg("7: {{.*}}R4=16")
__msg("8: {{.*}}R4=8")
__msg("9: {{.*}}R4=4")
__msg("10: {{.*}}R4=2")
__naked void shift(void)
{
asm volatile (" \
r3 = 1; \
r3 <<= 1; \
r3 <<= 1; \
r3 <<= 1; \
r3 <<= 1; \
r3 >>= 4; \
r4 = 32; \
r4 >>= 1; \
r4 >>= 1; \
r4 >>= 1; \
r4 >>= 1; \
r0 = 0; \
exit; \
" ::: __clobber_all);
}
SEC("tc")
__success __log_level(2)
__flag(BPF_F_ANY_ALIGNMENT)
__msg("0: R1=ctx() R10=fp0")
__msg("0: {{.*}}R3=4")
__msg("1: {{.*}}R3=8")
__msg("2: {{.*}}R3=10")
__msg("3: {{.*}}R4=8")
__msg("4: {{.*}}R4=12")
__msg("5: {{.*}}R4=14")
__naked void addsub(void)
{
asm volatile (" \
r3 = 4; \
r3 += 4; \
r3 += 2; \
r4 = 8; \
r4 += 4; \
r4 += 2; \
r0 = 0; \
exit; \
" ::: __clobber_all);
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_helpers.h`, `bpf_misc.h`.
- Detected declarations: `function __log_level`, `function __log_level`, `function __log_level`, `function __log_level`, `function unknown_shift`, `function unknown_mul`, `function packet_const_offset`, `function packet_variable_offset`, `function packet_variable_offset_2`, `function dubious_pointer_arithmetic`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.