]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/bpf: Fix build error with llvm 19
authorAlexei Starovoitov <ast@kernel.org>
Sat, 16 Nov 2024 18:56:17 +0000 (10:56 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 10:14:10 +0000 (12:14 +0200)
commit 608e99f7869e3a6e028c7cba14a896c7797e8746 upstream.

llvm 19 fails to compile arena self test:
CLNG-BPF [test_progs] verifier_arena_large.bpf.o
progs/verifier_arena_large.c:90:24: error: unsupported signed division, please convert to unsigned div/mod.
   90 |                 pg_idx = (pg - base) / PAGE_SIZE;

Though llvm <= 18 and llvm >= 20 don't have this issue,
fix the test to avoid the build error.

Reported-by: Jiri Olsa <olsajiri@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Yifei Liu <yifei.l.liu@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/testing/selftests/bpf/progs/verifier_arena_large.c

index f318675814c664bf21e5bc9e743e8a5e21360fe0..758b09a5eb88b95884f32b0608b3e0ad492de524 100644 (file)
@@ -87,7 +87,7 @@ __noinline int alloc_pages(int page_cnt, int pages_atonce, bool first_pass,
                                           NUMA_NO_NODE, 0);
                if (!pg)
                        return step;
-               pg_idx = (pg - base) / PAGE_SIZE;
+               pg_idx = (unsigned long) (pg - base) / PAGE_SIZE;
                if (first_pass) {
                        /* Pages must be allocated sequentially */
                        if (pg_idx != i)