tools/testing/selftests/bpf/progs/exceptions.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/exceptions.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/exceptions.c- Extension
.c- Size
- 9678 bytes
- Lines
- 497
- 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
vmlinux.hbpf/bpf_tracing.hbpf/bpf_helpers.hbpf/bpf_core_read.hbpf/bpf_endian.hbpf_misc.hbpf_experimental.h
Detected Declarations
function static_funcfunction global2static_simplefunction global2staticfunction static2globalfunction exception_throw_always_1function exception_throw_always_2function exception_throw_unwind_1function exception_throw_unwind_2function exception_throw_defaultfunction exception_throw_default_valuefunction exception_tail_call_targetfunction exception_tail_call_subprogfunction exception_tail_callfunction throw_11function exception_throw_from_void_globalfunction exception_ext_globalfunction exception_ext_staticfunction exception_extfunction exception_cb_mod_globalfunction exception_cb_modfunction exception_ext_mod_cb_runtimefunction subprogfunction throwing_subprogfunction global_subprogfunction throwing_global_subprogfunction exception_throw_subprogfunction assert_nz_gfuncfunction assert_zero_gfuncfunction assert_neg_gfuncfunction assert_pos_gfuncfunction assert_negeq_gfuncfunction assert_poseq_gfuncfunction assert_nz_gfunc_withfunction assert_zero_gfunc_withfunction assert_neg_gfunc_withfunction assert_pos_gfunc_withfunction assert_negeq_gfunc_withfunction assert_poseq_gfunc_withfunction exception_assert_rangefunction exception_assert_range_withfunction exception_bad_assert_rangefunction exception_bad_assert_range_withfunction throwing_many_argsfunction exception_cb_safunction exception_throw_stack_argfunction no_throw_many_argsfunction exception_throw_after_stack_argfunction subprog_throw_sa
Annotated Snippet
int exception_tail_call(struct __sk_buff *ctx) {
volatile int ret = 0;
ret = exception_tail_call_subprog(ctx);
return ret + 8;
}
__weak
void throw_11(void)
{
bpf_throw(11);
}
SEC("tc")
int exception_throw_from_void_global(struct __sk_buff *ctx)
{
throw_11();
return 0;
}
__noinline int exception_ext_global(struct __sk_buff *ctx)
{
volatile int ret = 0;
return ret;
}
static __noinline int exception_ext_static(struct __sk_buff *ctx)
{
return exception_ext_global(ctx);
}
SEC("tc")
int exception_ext(struct __sk_buff *ctx)
{
return exception_ext_static(ctx);
}
__noinline int exception_cb_mod_global(u64 cookie)
{
volatile int ret = 0;
return ret;
}
/* Example of how the exception callback supplied during verification can still
* introduce extensions by calling to dummy global functions, and alter runtime
* behavior.
*
* Right now we don't allow freplace attachment to exception callback itself,
* but if the need arises this restriction is technically feasible to relax in
* the future.
*/
__noinline int exception_cb_mod(u64 cookie)
{
return exception_cb_mod_global(cookie) + cookie + 10;
}
SEC("tc")
__exception_cb(exception_cb_mod)
int exception_ext_mod_cb_runtime(struct __sk_buff *ctx)
{
bpf_throw(25);
return 0;
}
__noinline static int subprog(struct __sk_buff *ctx)
{
return bpf_ktime_get_ns();
}
__noinline static int throwing_subprog(struct __sk_buff *ctx)
{
if (ctx->tstamp)
bpf_throw(0);
return bpf_ktime_get_ns();
}
__noinline int global_subprog(struct __sk_buff *ctx)
{
return bpf_ktime_get_ns();
}
__noinline int throwing_global_subprog(struct __sk_buff *ctx)
{
if (ctx->tstamp)
bpf_throw(0);
return bpf_ktime_get_ns();
}
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_tracing.h`, `bpf/bpf_helpers.h`, `bpf/bpf_core_read.h`, `bpf/bpf_endian.h`, `bpf_misc.h`, `bpf_experimental.h`.
- Detected declarations: `function static_func`, `function global2static_simple`, `function global2static`, `function static2global`, `function exception_throw_always_1`, `function exception_throw_always_2`, `function exception_throw_unwind_1`, `function exception_throw_unwind_2`, `function exception_throw_default`, `function exception_throw_default_value`.
- 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.