1 // SPDX-License-Identifier: GPL-2.0
4 #include <bpf/bpf_helpers.h>
8 __description("check w reg equal if r reg upper32 bits 0")
10 __naked void subreg_equality_1(void)
13 call %[bpf_ktime_get_ns]; \
14 *(u64 *)(r10 - 8) = r0; \
15 r2 = *(u32 *)(r10 - 8); \
16 /* At this point upper 4-bytes of r2 are 0, \
17 * thus insn w3 = w2 should propagate reg id, \
18 * and w2 < 9 comparison would also propagate \
22 if w2 < 9 goto l0_%=; \
24 l0_%=: if r3 < 9 goto l1_%=; \
25 /* r1 read is illegal at this point */ \
29 : __imm(bpf_ktime_get_ns)
34 __description("check w reg not equal if r reg upper32 bits not 0")
35 __failure __msg("R1 !read_ok")
36 __naked void subreg_equality_2(void)
39 call %[bpf_ktime_get_ns]; \
41 /* Upper 4-bytes of r2 may not be 0, thus insn \
42 * w3 = w2 should not propagate reg id, and \
43 * w2 < 9 comparison should not propagate \
44 * the range for r3 either. \
47 if w2 < 9 goto l0_%=; \
49 l0_%=: if r3 < 9 goto l1_%=; \
50 /* r1 read is illegal at this point */ \
54 : __imm(bpf_ktime_get_ns)
58 char _license[] SEC("license") = "GPL";