~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/README.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/bpf/README.rst (Architecture sparc64) and /tools/testing/selftests/bpf/README.rst (Architecture mips)


  1 ==================                                  1 ==================
  2 BPF Selftest Notes                                  2 BPF Selftest Notes
  3 ==================                                  3 ==================
  4 General instructions on running selftests can       4 General instructions on running selftests can be found in
  5 `Documentation/bpf/bpf_devel_QA.rst`__.             5 `Documentation/bpf/bpf_devel_QA.rst`__.
  6                                                     6 
  7 __ /Documentation/bpf/bpf_devel_QA.rst#q-how-t      7 __ /Documentation/bpf/bpf_devel_QA.rst#q-how-to-run-bpf-selftests
  8                                                     8 
  9 =============                                       9 =============
 10 BPF CI System                                      10 BPF CI System
 11 =============                                      11 =============
 12                                                    12 
 13 BPF employs a continuous integration (CI) syst     13 BPF employs a continuous integration (CI) system to check patch submission in an
 14 automated fashion. The system runs selftests f     14 automated fashion. The system runs selftests for each patch in a series. Results
 15 are propagated to patchwork, where failures ar     15 are propagated to patchwork, where failures are highlighted similar to
 16 violations of other checks (such as additional     16 violations of other checks (such as additional warnings being emitted or a
 17 ``scripts/checkpatch.pl`` reported deficiency)     17 ``scripts/checkpatch.pl`` reported deficiency):
 18                                                    18 
 19   https://patchwork.kernel.org/project/netdevb     19   https://patchwork.kernel.org/project/netdevbpf/list/?delegate=121173
 20                                                    20 
 21 The CI system executes tests on multiple archi     21 The CI system executes tests on multiple architectures. It uses a kernel
 22 configuration derived from both the generic an     22 configuration derived from both the generic and architecture specific config
 23 file fragments below ``tools/testing/selftests     23 file fragments below ``tools/testing/selftests/bpf/`` (e.g., ``config`` and
 24 ``config.x86_64``).                                24 ``config.x86_64``).
 25                                                    25 
 26 Denylisting Tests                                  26 Denylisting Tests
 27 =================                                  27 =================
 28                                                    28 
 29 It is possible for some architectures to not h     29 It is possible for some architectures to not have support for all BPF features.
 30 In such a case tests in CI may fail. An exampl     30 In such a case tests in CI may fail. An example of such a shortcoming is BPF
 31 trampoline support on IBM's s390x architecture     31 trampoline support on IBM's s390x architecture. For cases like this, an in-tree
 32 deny list file, located at ``tools/testing/sel     32 deny list file, located at ``tools/testing/selftests/bpf/DENYLIST.<arch>``, can
 33 be used to prevent the test from running on su     33 be used to prevent the test from running on such an architecture.
 34                                                    34 
 35 In addition to that, the generic ``tools/testi     35 In addition to that, the generic ``tools/testing/selftests/bpf/DENYLIST`` is
 36 honored on every architecture running tests.       36 honored on every architecture running tests.
 37                                                    37 
 38 These files are organized in three columns. Th     38 These files are organized in three columns. The first column lists the test in
 39 question. This can be the name of a test suite     39 question. This can be the name of a test suite or of an individual test. The
 40 remaining two columns provide additional meta      40 remaining two columns provide additional meta data that helps identify and
 41 classify the entry: column two is a copy and p     41 classify the entry: column two is a copy and paste of the error being reported
 42 when running the test in the setting in questi     42 when running the test in the setting in question. The third column, if
 43 available, summarizes the underlying problem.      43 available, summarizes the underlying problem. A value of ``trampoline``, for
 44 example, indicates that lack of trampoline sup     44 example, indicates that lack of trampoline support is causing the test to fail.
 45 This last entry helps identify tests that can      45 This last entry helps identify tests that can be re-enabled once such support is
 46 added.                                             46 added.
 47                                                    47 
 48 =========================                          48 =========================
 49 Running Selftests in a VM                          49 Running Selftests in a VM
 50 =========================                          50 =========================
 51                                                    51 
 52 It's now possible to run the selftests using `     52 It's now possible to run the selftests using ``tools/testing/selftests/bpf/vmtest.sh``.
 53 The script tries to ensure that the tests are      53 The script tries to ensure that the tests are run with the same environment as they
 54 would be run post-submit in the CI used by the     54 would be run post-submit in the CI used by the Maintainers, with the exception
 55 that deny lists are not automatically honored.     55 that deny lists are not automatically honored.
 56                                                    56 
 57 This script uses the in-tree kernel configurat     57 This script uses the in-tree kernel configuration and downloads a VM userspace
 58 image from the system used by the CI. It build     58 image from the system used by the CI. It builds the kernel (without overwriting
 59 your existing Kconfig), recompiles the bpf sel     59 your existing Kconfig), recompiles the bpf selftests, runs them (by default
 60 ``tools/testing/selftests/bpf/test_progs``) an     60 ``tools/testing/selftests/bpf/test_progs``) and saves the resulting output (by
 61 default in ``~/.bpf_selftests``).                  61 default in ``~/.bpf_selftests``).
 62                                                    62 
 63 Script dependencies:                               63 Script dependencies:
 64 - clang (preferably built from sources, https:     64 - clang (preferably built from sources, https://github.com/llvm/llvm-project);
 65 - pahole (preferably built from sources, https     65 - pahole (preferably built from sources, https://git.kernel.org/pub/scm/devel/pahole/pahole.git/);
 66 - qemu;                                            66 - qemu;
 67 - docutils (for ``rst2man``);                      67 - docutils (for ``rst2man``);
 68 - libcap-devel.                                    68 - libcap-devel.
 69                                                    69 
 70 For more information about using the script, r     70 For more information about using the script, run:
 71                                                    71 
 72 .. code-block:: console                            72 .. code-block:: console
 73                                                    73 
 74   $ tools/testing/selftests/bpf/vmtest.sh -h       74   $ tools/testing/selftests/bpf/vmtest.sh -h
 75                                                    75 
 76 In case of linker errors when running selftest     76 In case of linker errors when running selftests, try using static linking:
 77                                                    77 
 78 .. code-block:: console                            78 .. code-block:: console
 79                                                    79 
 80   $ LDLIBS=-static PKG_CONFIG='pkg-config --st     80   $ LDLIBS=-static PKG_CONFIG='pkg-config --static' vmtest.sh
 81                                                    81 
 82 .. note:: Some distros may not support static      82 .. note:: Some distros may not support static linking.
 83                                                    83 
 84 .. note:: The script uses pahole and clang bas     84 .. note:: The script uses pahole and clang based on host environment setting.
 85           If you want to change pahole and llv     85           If you want to change pahole and llvm, you can change `PATH` environment
 86           variable in the beginning of script.     86           variable in the beginning of script.
 87                                                    87 
 88 Running vmtest on RV64                             88 Running vmtest on RV64
 89 ======================                             89 ======================
 90 To speed up testing and avoid various dependen     90 To speed up testing and avoid various dependency issues, it is recommended to
 91 run vmtest in a Docker container. Before runni     91 run vmtest in a Docker container. Before running vmtest, we need to prepare
 92 Docker container and local rootfs image. The o     92 Docker container and local rootfs image. The overall steps are as follows:
 93                                                    93 
 94 1. Create Docker container as shown in link [0     94 1. Create Docker container as shown in link [0].
 95                                                    95 
 96 2. Use mkrootfs_debian.sh script [1] to build      96 2. Use mkrootfs_debian.sh script [1] to build local rootfs image:
 97                                                    97 
 98 .. code-block:: console                            98 .. code-block:: console
 99                                                    99 
100   $ sudo ./mkrootfs_debian.sh --arch riscv64 -    100   $ sudo ./mkrootfs_debian.sh --arch riscv64 --distro noble
101                                                   101 
102 3. Start Docker container [0] and run vmtest i    102 3. Start Docker container [0] and run vmtest in the container:
103                                                   103 
104 .. code-block:: console                           104 .. code-block:: console
105                                                   105 
106   $ PLATFORM=riscv64 CROSS_COMPILE=riscv64-lin    106   $ PLATFORM=riscv64 CROSS_COMPILE=riscv64-linux-gnu- \
107     tools/testing/selftests/bpf/vmtest.sh \       107     tools/testing/selftests/bpf/vmtest.sh \
108     -l <path of local rootfs image> -- \          108     -l <path of local rootfs image> -- \
109     ./test_progs -d \                             109     ./test_progs -d \
110         \"$(cat tools/testing/selftests/bpf/DE    110         \"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \
111             | cut -d'#' -f1 \                     111             | cut -d'#' -f1 \
112             | sed -e 's/^[[:space:]]*//' \        112             | sed -e 's/^[[:space:]]*//' \
113                   -e 's/[[:space:]]*$//' \        113                   -e 's/[[:space:]]*$//' \
114             | tr -s '\n' ',' \                    114             | tr -s '\n' ',' \
115         )\"                                       115         )\"
116                                                   116 
117 Link: https://github.com/pulehui/riscv-bpf-vmt    117 Link: https://github.com/pulehui/riscv-bpf-vmtest.git [0]
118 Link: https://github.com/libbpf/ci/blob/main/r    118 Link: https://github.com/libbpf/ci/blob/main/rootfs/mkrootfs_debian.sh [1]
119                                                   119 
120 Additional information about selftest failures    120 Additional information about selftest failures are
121 documented here.                                  121 documented here.
122                                                   122 
123 profiler[23] test failures with clang/llvm <12    123 profiler[23] test failures with clang/llvm <12.0.0
124 ==============================================    124 ==================================================
125                                                   125 
126 With clang/llvm <12.0.0, the profiler[23] test    126 With clang/llvm <12.0.0, the profiler[23] test may fail.
127 The symptom looks like                            127 The symptom looks like
128                                                   128 
129 .. code-block:: c                                 129 .. code-block:: c
130                                                   130 
131   // r9 is a pointer to map_value                 131   // r9 is a pointer to map_value
132   // r7 is a scalar                               132   // r7 is a scalar
133   17:       bf 96 00 00 00 00 00 00 r6 = r9       133   17:       bf 96 00 00 00 00 00 00 r6 = r9
134   18:       0f 76 00 00 00 00 00 00 r6 += r7      134   18:       0f 76 00 00 00 00 00 00 r6 += r7
135   math between map_value pointer and register     135   math between map_value pointer and register with unbounded min value is not allowed
136                                                   136 
137   // the instructions below will not be seen i    137   // the instructions below will not be seen in the verifier log
138   19:       a5 07 01 00 01 01 00 00 if r7 < 25    138   19:       a5 07 01 00 01 01 00 00 if r7 < 257 goto +1
139   20:       bf 96 00 00 00 00 00 00 r6 = r9       139   20:       bf 96 00 00 00 00 00 00 r6 = r9
140   // r6 is used here                              140   // r6 is used here
141                                                   141 
142 The verifier will reject such code with above     142 The verifier will reject such code with above error.
143 At insn 18 the r7 is indeed unbounded. The lat    143 At insn 18 the r7 is indeed unbounded. The later insn 19 checks the bounds and
144 the insn 20 undoes map_value addition. It is c    144 the insn 20 undoes map_value addition. It is currently impossible for the
145 verifier to understand such speculative pointe    145 verifier to understand such speculative pointer arithmetic.
146 Hence `this patch`__ addresses it on the compi    146 Hence `this patch`__ addresses it on the compiler side. It was committed on llvm 12.
147                                                   147 
148 __ https://github.com/llvm/llvm-project/commit    148 __ https://github.com/llvm/llvm-project/commit/ddf1864ace484035e3cde5e83b3a31ac81e059c6
149                                                   149 
150 The corresponding C code                          150 The corresponding C code
151                                                   151 
152 .. code-block:: c                                 152 .. code-block:: c
153                                                   153 
154   for (int i = 0; i < MAX_CGROUPS_PATH_DEPTH;     154   for (int i = 0; i < MAX_CGROUPS_PATH_DEPTH; i++) {
155           filepart_length = bpf_probe_read_str    155           filepart_length = bpf_probe_read_str(payload, ...);
156           if (filepart_length <= MAX_PATH) {      156           if (filepart_length <= MAX_PATH) {
157                   barrier_var(filepart_length)    157                   barrier_var(filepart_length); // workaround
158                   payload += filepart_length;     158                   payload += filepart_length;
159           }                                       159           }
160   }                                               160   }
161                                                   161 
162 bpf_iter test failures with clang/llvm 10.0.0     162 bpf_iter test failures with clang/llvm 10.0.0
163 =============================================     163 =============================================
164                                                   164 
165 With clang/llvm 10.0.0, the following two bpf_    165 With clang/llvm 10.0.0, the following two bpf_iter tests failed:
166   * ``bpf_iter/ipv6_route``                       166   * ``bpf_iter/ipv6_route``
167   * ``bpf_iter/netlink``                          167   * ``bpf_iter/netlink``
168                                                   168 
169 The symptom for ``bpf_iter/ipv6_route`` looks     169 The symptom for ``bpf_iter/ipv6_route`` looks like
170                                                   170 
171 .. code-block:: c                                 171 .. code-block:: c
172                                                   172 
173   2: (79) r8 = *(u64 *)(r1 +8)                    173   2: (79) r8 = *(u64 *)(r1 +8)
174   ...                                             174   ...
175   14: (bf) r2 = r8                                175   14: (bf) r2 = r8
176   15: (0f) r2 += r1                               176   15: (0f) r2 += r1
177   ; BPF_SEQ_PRINTF(seq, "%pi6 %02x ", &rt->fib    177   ; BPF_SEQ_PRINTF(seq, "%pi6 %02x ", &rt->fib6_dst.addr, rt->fib6_dst.plen);
178   16: (7b) *(u64 *)(r8 +64) = r2                  178   16: (7b) *(u64 *)(r8 +64) = r2
179   only read is supported                          179   only read is supported
180                                                   180 
181 The symptom for ``bpf_iter/netlink`` looks lik    181 The symptom for ``bpf_iter/netlink`` looks like
182                                                   182 
183 .. code-block:: c                                 183 .. code-block:: c
184                                                   184 
185   ; struct netlink_sock *nlk = ctx->sk;           185   ; struct netlink_sock *nlk = ctx->sk;
186   2: (79) r7 = *(u64 *)(r1 +8)                    186   2: (79) r7 = *(u64 *)(r1 +8)
187   ...                                             187   ...
188   15: (bf) r2 = r7                                188   15: (bf) r2 = r7
189   16: (0f) r2 += r1                               189   16: (0f) r2 += r1
190   ; BPF_SEQ_PRINTF(seq, "%pK %-3d ", s, s->sk_    190   ; BPF_SEQ_PRINTF(seq, "%pK %-3d ", s, s->sk_protocol);
191   17: (7b) *(u64 *)(r7 +0) = r2                   191   17: (7b) *(u64 *)(r7 +0) = r2
192   only read is supported                          192   only read is supported
193                                                   193 
194 This is due to a llvm BPF backend bug. `The fi    194 This is due to a llvm BPF backend bug. `The fix`__
195 has been pushed to llvm 10.x release branch an    195 has been pushed to llvm 10.x release branch and will be
196 available in 10.0.1. The patch is available in    196 available in 10.0.1. The patch is available in llvm 11.0.0 trunk.
197                                                   197 
198 __  https://github.com/llvm/llvm-project/commi    198 __  https://github.com/llvm/llvm-project/commit/3cb7e7bf959dcd3b8080986c62e10a75c7af43f0
199                                                   199 
200 bpf_verif_scale/loop6.bpf.o test failure with     200 bpf_verif_scale/loop6.bpf.o test failure with Clang 12
201 ==============================================    201 ======================================================
202                                                   202 
203 With Clang 12, the following bpf_verif_scale t    203 With Clang 12, the following bpf_verif_scale test failed:
204   * ``bpf_verif_scale/loop6.bpf.o``               204   * ``bpf_verif_scale/loop6.bpf.o``
205                                                   205 
206 The verifier output looks like                    206 The verifier output looks like
207                                                   207 
208 .. code-block:: c                                 208 .. code-block:: c
209                                                   209 
210   R1 type=ctx expected=fp                         210   R1 type=ctx expected=fp
211   The sequence of 8193 jumps is too complex.      211   The sequence of 8193 jumps is too complex.
212                                                   212 
213 The reason is compiler generating the followin    213 The reason is compiler generating the following code
214                                                   214 
215 .. code-block:: c                                 215 .. code-block:: c
216                                                   216 
217   ;       for (i = 0; (i < VIRTIO_MAX_SGS) &&     217   ;       for (i = 0; (i < VIRTIO_MAX_SGS) && (i < num); i++) {
218       14:       16 05 40 00 00 00 00 00 if w5     218       14:       16 05 40 00 00 00 00 00 if w5 == 0 goto +64 <LBB0_6>
219       15:       bc 51 00 00 00 00 00 00 w1 = w    219       15:       bc 51 00 00 00 00 00 00 w1 = w5
220       16:       04 01 00 00 ff ff ff ff w1 +=     220       16:       04 01 00 00 ff ff ff ff w1 += -1
221       17:       67 05 00 00 20 00 00 00 r5 <<=    221       17:       67 05 00 00 20 00 00 00 r5 <<= 32
222       18:       77 05 00 00 20 00 00 00 r5 >>=    222       18:       77 05 00 00 20 00 00 00 r5 >>= 32
223       19:       a6 01 01 00 05 00 00 00 if w1     223       19:       a6 01 01 00 05 00 00 00 if w1 < 5 goto +1 <LBB0_4>
224       20:       b7 05 00 00 06 00 00 00 r5 = 6    224       20:       b7 05 00 00 06 00 00 00 r5 = 6
225   00000000000000a8 <LBB0_4>:                      225   00000000000000a8 <LBB0_4>:
226       21:       b7 02 00 00 00 00 00 00 r2 = 0    226       21:       b7 02 00 00 00 00 00 00 r2 = 0
227       22:       b7 01 00 00 00 00 00 00 r1 = 0    227       22:       b7 01 00 00 00 00 00 00 r1 = 0
228   ;       for (i = 0; (i < VIRTIO_MAX_SGS) &&     228   ;       for (i = 0; (i < VIRTIO_MAX_SGS) && (i < num); i++) {
229       23:       7b 1a e0 ff 00 00 00 00 *(u64     229       23:       7b 1a e0 ff 00 00 00 00 *(u64 *)(r10 - 32) = r1
230       24:       7b 5a c0 ff 00 00 00 00 *(u64     230       24:       7b 5a c0 ff 00 00 00 00 *(u64 *)(r10 - 64) = r5
231                                                   231 
232 Note that insn #15 has w1 = w5 and w1 is refin    232 Note that insn #15 has w1 = w5 and w1 is refined later but
233 r5(w5) is eventually saved on stack at insn #2    233 r5(w5) is eventually saved on stack at insn #24 for later use.
234 This cause later verifier failure. The bug has    234 This cause later verifier failure. The bug has been `fixed`__ in
235 Clang 13.                                         235 Clang 13.
236                                                   236 
237 __  https://github.com/llvm/llvm-project/commi    237 __  https://github.com/llvm/llvm-project/commit/1959ead525b8830cc8a345f45e1c3ef9902d3229
238                                                   238 
239 BPF CO-RE-based tests and Clang version           239 BPF CO-RE-based tests and Clang version
240 =======================================           240 =======================================
241                                                   241 
242 A set of selftests use BPF target-specific bui    242 A set of selftests use BPF target-specific built-ins, which might require
243 bleeding-edge Clang versions (Clang 12 nightly    243 bleeding-edge Clang versions (Clang 12 nightly at this time).
244                                                   244 
245 Few sub-tests of core_reloc test suit (part of    245 Few sub-tests of core_reloc test suit (part of test_progs test runner) require
246 the following built-ins, listed with correspon    246 the following built-ins, listed with corresponding Clang diffs introducing
247 them to Clang/LLVM. These sub-tests are going     247 them to Clang/LLVM. These sub-tests are going to be skipped if Clang is too
248 old to support them, they shouldn't cause buil    248 old to support them, they shouldn't cause build failures or runtime test
249 failures:                                         249 failures:
250                                                   250 
251 - __builtin_btf_type_id() [0_, 1_, 2_];           251 - __builtin_btf_type_id() [0_, 1_, 2_];
252 - __builtin_preserve_type_info(), __builtin_pr    252 - __builtin_preserve_type_info(), __builtin_preserve_enum_value() [3_, 4_].
253                                                   253 
254 .. _0: https://github.com/llvm/llvm-project/co    254 .. _0: https://github.com/llvm/llvm-project/commit/6b01b465388b204d543da3cf49efd6080db094a9
255 .. _1: https://github.com/llvm/llvm-project/co    255 .. _1: https://github.com/llvm/llvm-project/commit/072cde03aaa13a2c57acf62d79876bf79aa1919f
256 .. _2: https://github.com/llvm/llvm-project/co    256 .. _2: https://github.com/llvm/llvm-project/commit/00602ee7ef0bf6c68d690a2bd729c12b95c95c99
257 .. _3: https://github.com/llvm/llvm-project/co    257 .. _3: https://github.com/llvm/llvm-project/commit/6d218b4adb093ff2e9764febbbc89f429412006c
258 .. _4: https://github.com/llvm/llvm-project/co    258 .. _4: https://github.com/llvm/llvm-project/commit/6d6750696400e7ce988d66a1a00e1d0cb32815f8
259                                                   259 
260 Floating-point tests and Clang version            260 Floating-point tests and Clang version
261 ======================================            261 ======================================
262                                                   262 
263 Certain selftests, e.g. core_reloc, require su    263 Certain selftests, e.g. core_reloc, require support for the floating-point
264 types, which was introduced in `Clang 13`__. T    264 types, which was introduced in `Clang 13`__. The older Clang versions will
265 either crash when compiling these tests, or ge    265 either crash when compiling these tests, or generate an incorrect BTF.
266                                                   266 
267 __  https://github.com/llvm/llvm-project/commi    267 __  https://github.com/llvm/llvm-project/commit/a7137b238a07d9399d3ae96c0b461571bd5aa8b2
268                                                   268 
269 Kernel function call test and Clang version       269 Kernel function call test and Clang version
270 ===========================================       270 ===========================================
271                                                   271 
272 Some selftests (e.g. kfunc_call and bpf_tcp_ca    272 Some selftests (e.g. kfunc_call and bpf_tcp_ca) require a LLVM support
273 to generate extern function in BTF.  It was in    273 to generate extern function in BTF.  It was introduced in `Clang 13`__.
274                                                   274 
275 Without it, the error from compiling bpf selft    275 Without it, the error from compiling bpf selftests looks like:
276                                                   276 
277 .. code-block:: console                           277 .. code-block:: console
278                                                   278 
279   libbpf: failed to find BTF for extern 'tcp_s    279   libbpf: failed to find BTF for extern 'tcp_slow_start' [25] section: -2
280                                                   280 
281 __ https://github.com/llvm/llvm-project/commit    281 __ https://github.com/llvm/llvm-project/commit/886f9ff53155075bd5f1e994f17b85d1e1b7470c
282                                                   282 
283 btf_tag test and Clang version                    283 btf_tag test and Clang version
284 ==============================                    284 ==============================
285                                                   285 
286 The btf_tag selftest requires LLVM support to     286 The btf_tag selftest requires LLVM support to recognize the btf_decl_tag and
287 btf_type_tag attributes. They are introduced i    287 btf_type_tag attributes. They are introduced in `Clang 14` [0_, 1_].
288 The subtests ``btf_type_tag_user_{mod1, mod2,     288 The subtests ``btf_type_tag_user_{mod1, mod2, vmlinux}`` also requires
289 pahole version ``1.23``.                          289 pahole version ``1.23``.
290                                                   290 
291 Without them, the btf_tag selftest will be ski    291 Without them, the btf_tag selftest will be skipped and you will observe:
292                                                   292 
293 .. code-block:: console                           293 .. code-block:: console
294                                                   294 
295   #<test_num> btf_tag:SKIP                        295   #<test_num> btf_tag:SKIP
296                                                   296 
297 .. _0: https://github.com/llvm/llvm-project/co    297 .. _0: https://github.com/llvm/llvm-project/commit/a162b67c98066218d0d00aa13b99afb95d9bb5e6
298 .. _1: https://github.com/llvm/llvm-project/co    298 .. _1: https://github.com/llvm/llvm-project/commit/3466e00716e12e32fdb100e3fcfca5c2b3e8d784
299                                                   299 
300 Clang dependencies for static linking tests       300 Clang dependencies for static linking tests
301 ===========================================       301 ===========================================
302                                                   302 
303 linked_vars, linked_maps, and linked_funcs tes    303 linked_vars, linked_maps, and linked_funcs tests depend on `Clang fix`__ to
304 generate valid BTF information for weak variab    304 generate valid BTF information for weak variables. Please make sure you use
305 Clang that contains the fix.                      305 Clang that contains the fix.
306                                                   306 
307 __ https://github.com/llvm/llvm-project/commit    307 __ https://github.com/llvm/llvm-project/commit/968292cb93198442138128d850fd54dc7edc0035
308                                                   308 
309 Clang relocation changes                          309 Clang relocation changes
310 ========================                          310 ========================
311                                                   311 
312 Clang 13 patch `clang reloc patch`_  made some    312 Clang 13 patch `clang reloc patch`_  made some changes on relocations such
313 that existing relocation types are broken into    313 that existing relocation types are broken into more types and
314 each new type corresponds to only one way to r    314 each new type corresponds to only one way to resolve relocation.
315 See `kernel llvm reloc`_ for more explanation     315 See `kernel llvm reloc`_ for more explanation and some examples.
316 Using clang 13 to compile old libbpf which has    316 Using clang 13 to compile old libbpf which has static linker support,
317 there will be a compilation failure::             317 there will be a compilation failure::
318                                                   318 
319   libbpf: ELF relo #0 in section #6 has unexpe    319   libbpf: ELF relo #0 in section #6 has unexpected type 2 in .../bpf_tcp_nogpl.bpf.o
320                                                   320 
321 Here, ``type 2`` refers to new relocation type    321 Here, ``type 2`` refers to new relocation type ``R_BPF_64_ABS64``.
322 To fix this issue, user newer libbpf.             322 To fix this issue, user newer libbpf.
323                                                   323 
324 .. Links                                          324 .. Links
325 .. _clang reloc patch: https://github.com/llvm    325 .. _clang reloc patch: https://github.com/llvm/llvm-project/commit/6a2ea84600ba4bd3b2733bd8f08f5115eb32164b
326 .. _kernel llvm reloc: /Documentation/bpf/llvm    326 .. _kernel llvm reloc: /Documentation/bpf/llvm_reloc.rst
327                                                   327 
328 Clang dependencies for the u32 spill test (xdp    328 Clang dependencies for the u32 spill test (xdpwall)
329 ==============================================    329 ===================================================
330 The xdpwall selftest requires a change in `Cla    330 The xdpwall selftest requires a change in `Clang 14`__.
331                                                   331 
332 Without it, the xdpwall selftest will fail and    332 Without it, the xdpwall selftest will fail and the error message
333 from running test_progs will look like:           333 from running test_progs will look like:
334                                                   334 
335 .. code-block:: console                           335 .. code-block:: console
336                                                   336 
337   test_xdpwall:FAIL:Does LLVM have https://git    337   test_xdpwall:FAIL:Does LLVM have https://github.com/llvm/llvm-project/commit/ea72b0319d7b0f0c2fcf41d121afa5d031b319d5? unexpected error: -4007
338                                                   338 
339 __ https://github.com/llvm/llvm-project/commit    339 __ https://github.com/llvm/llvm-project/commit/ea72b0319d7b0f0c2fcf41d121afa5d031b319d5
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php