4 General instructions on running selftests can be found in
5 `Documentation/bpf/bpf_devel_QA.rst`__.
7 __ /Documentation/bpf/bpf_devel_QA.rst#q-how-to-run-bpf-selftests
10 Additional information about selftest failures are
13 profiler[23] test failures with clang/llvm <12.0.0
14 ==================================================
16 With clang/llvm <12.0.0, the profiler[23] test may fail.
17 The symptom looks like
21 // r9 is a pointer to map_value
23 17: bf 96 00 00 00 00 00 00 r6 = r9
24 18: 0f 76 00 00 00 00 00 00 r6 += r7
25 math between map_value pointer and register with unbounded min value is not allowed
27 // the instructions below will not be seen in the verifier log
28 19: a5 07 01 00 01 01 00 00 if r7 < 257 goto +1
29 20: bf 96 00 00 00 00 00 00 r6 = r9
32 The verifier will reject such code with above error.
33 At insn 18 the r7 is indeed unbounded. The later insn 19 checks the bounds and
34 the insn 20 undoes map_value addition. It is currently impossible for the
35 verifier to understand such speculative pointer arithmetic.
36 Hence `this patch`__ addresses it on the compiler side. It was committed on llvm 12.
38 __ https://reviews.llvm.org/D85570
40 The corresponding C code
44 for (int i = 0; i < MAX_CGROUPS_PATH_DEPTH; i++) {
45 filepart_length = bpf_probe_read_str(payload, ...);
46 if (filepart_length <= MAX_PATH) {
47 barrier_var(filepart_length); // workaround
48 payload += filepart_length;
52 bpf_iter test failures with clang/llvm 10.0.0
53 =============================================
55 With clang/llvm 10.0.0, the following two bpf_iter tests failed:
56 * ``bpf_iter/ipv6_route``
57 * ``bpf_iter/netlink``
59 The symptom for ``bpf_iter/ipv6_route`` looks like
63 2: (79) r8 = *(u64 *)(r1 +8)
67 ; BPF_SEQ_PRINTF(seq, "%pi6 %02x ", &rt->fib6_dst.addr, rt->fib6_dst.plen);
68 16: (7b) *(u64 *)(r8 +64) = r2
69 only read is supported
71 The symptom for ``bpf_iter/netlink`` looks like
75 ; struct netlink_sock *nlk = ctx->sk;
76 2: (79) r7 = *(u64 *)(r1 +8)
80 ; BPF_SEQ_PRINTF(seq, "%pK %-3d ", s, s->sk_protocol);
81 17: (7b) *(u64 *)(r7 +0) = r2
82 only read is supported
84 This is due to a llvm BPF backend bug. `The fix`__
85 has been pushed to llvm 10.x release branch and will be
86 available in 10.0.1. The patch is available in llvm 11.0.0 trunk.
88 __ https://reviews.llvm.org/D78466
90 BPF CO-RE-based tests and Clang version
91 =======================================
93 A set of selftests use BPF target-specific built-ins, which might require
94 bleeding-edge Clang versions (Clang 12 nightly at this time).
96 Few sub-tests of core_reloc test suit (part of test_progs test runner) require
97 the following built-ins, listed with corresponding Clang diffs introducing
98 them to Clang/LLVM. These sub-tests are going to be skipped if Clang is too
99 old to support them, they shouldn't cause build failures or runtime test
102 - __builtin_btf_type_id() [0_, 1_, 2_];
103 - __builtin_preserve_type_info(), __builtin_preserve_enum_value() [3_, 4_].
105 .. _0: https://reviews.llvm.org/D74572
106 .. _1: https://reviews.llvm.org/D74668
107 .. _2: https://reviews.llvm.org/D85174
108 .. _3: https://reviews.llvm.org/D83878
109 .. _4: https://reviews.llvm.org/D83242