1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Facebook
4 #include <linux/ptrace.h>
6 #include <bpf/bpf_helpers.h>
12 * if the struct's size is multiple of 16, compiler will put it into
13 * .rodata.cst16 section, which is not recognized by libbpf; work
14 * around this by ensuring we don't have 16-aligned struct
17 } rdonly_values = { .a = {2, 3, 4, 5} };
25 SEC("raw_tracepoint/sys_enter:skip_loop")
26 int skip_loop(struct pt_regs *ctx)
28 /* prevent compiler to optimize everything out */
29 unsigned * volatile p = (void *)&rdonly_values.a;
30 unsigned iters = 0, sum = 0;
32 /* we should never enter this loop */
44 SEC("raw_tracepoint/sys_enter:part_loop")
45 int part_loop(struct pt_regs *ctx)
47 /* prevent compiler to optimize everything out */
48 unsigned * volatile p = (void *)&rdonly_values.a;
49 unsigned iters = 0, sum = 0;
51 /* validate verifier can derive loop termination */
63 SEC("raw_tracepoint/sys_enter:full_loop")
64 int full_loop(struct pt_regs *ctx)
66 /* prevent compiler to optimize everything out */
67 unsigned * volatile p = (void *)&rdonly_values.a;
68 int i = ARRAY_SIZE(rdonly_values.a);
69 unsigned iters = 0, sum = 0;
71 /* validate verifier can allow full loop as well */
84 char _license[] SEC("license") = "GPL";