Skip to content
Snippets Groups Projects
  1. Mar 04, 2021
  2. Feb 26, 2021
  3. Feb 09, 2021
  4. Feb 03, 2021
  5. Feb 02, 2021
    • Tiezhu Yang's avatar
      samples/bpf: Add include dir for MIPS Loongson64 to fix build errors · 058107ab
      Tiezhu Yang authored
      
      There exists many build errors when make M=samples/bpf on the Loongson
      platform. This issue is MIPS related, x86 compiles just fine.
      
      Here are some errors:
      
        CLANG-bpf  samples/bpf/sockex2_kern.o
      In file included from samples/bpf/sockex2_kern.c:2:
      In file included from ./include/uapi/linux/in.h:24:
      In file included from ./include/linux/socket.h:8:
      In file included from ./include/linux/uio.h:8:
      In file included from ./include/linux/kernel.h:11:
      In file included from ./include/linux/bitops.h:32:
      In file included from ./arch/mips/include/asm/bitops.h:19:
      In file included from ./arch/mips/include/asm/barrier.h:11:
      ./arch/mips/include/asm/addrspace.h:13:10: fatal error: 'spaces.h' file not found
               ^~~~~~~~~~
      1 error generated.
      
        CLANG-bpf  samples/bpf/sockex2_kern.o
      In file included from samples/bpf/sockex2_kern.c:2:
      In file included from ./include/uapi/linux/in.h:24:
      In file included from ./include/linux/socket.h:8:
      In file included from ./include/linux/uio.h:8:
      In file included from ./include/linux/kernel.h:11:
      In file included from ./include/linux/bitops.h:32:
      In file included from ./arch/mips/include/asm/bitops.h:22:
      In file included from ./arch/mips/include/asm/cpu-features.h:13:
      In file included from ./arch/mips/include/asm/cpu-info.h:15:
      In file included from ./include/linux/cache.h:6:
      ./arch/mips/include/asm/cache.h:12:10: fatal error: 'kmalloc.h' file not found
               ^~~~~~~~~~~
      1 error generated.
      
        CLANG-bpf  samples/bpf/sockex2_kern.o
      In file included from samples/bpf/sockex2_kern.c:2:
      In file included from ./include/uapi/linux/in.h:24:
      In file included from ./include/linux/socket.h:8:
      In file included from ./include/linux/uio.h:8:
      In file included from ./include/linux/kernel.h:11:
      In file included from ./include/linux/bitops.h:32:
      In file included from ./arch/mips/include/asm/bitops.h:22:
      ./arch/mips/include/asm/cpu-features.h:15:10: fatal error: 'cpu-feature-overrides.h' file not found
               ^~~~~~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      
      $ find arch/mips/include/asm -name spaces.h | sort
      arch/mips/include/asm/mach-ar7/spaces.h
      ...
      arch/mips/include/asm/mach-generic/spaces.h
      ...
      arch/mips/include/asm/mach-loongson64/spaces.h
      ...
      arch/mips/include/asm/mach-tx49xx/spaces.h
      
      $ find arch/mips/include/asm -name kmalloc.h | sort
      arch/mips/include/asm/mach-generic/kmalloc.h
      arch/mips/include/asm/mach-ip32/kmalloc.h
      arch/mips/include/asm/mach-tx49xx/kmalloc.h
      
      $ find arch/mips/include/asm -name cpu-feature-overrides.h | sort
      arch/mips/include/asm/mach-ath25/cpu-feature-overrides.h
      ...
      arch/mips/include/asm/mach-generic/cpu-feature-overrides.h
      ...
      arch/mips/include/asm/mach-loongson64/cpu-feature-overrides.h
      ...
      arch/mips/include/asm/mach-tx49xx/cpu-feature-overrides.h
      
      In the arch/mips/Makefile, there exists the following board-dependent
      options:
      
      include arch/mips/Kbuild.platforms
      cflags-y += -I$(srctree)/arch/mips/include/asm/mach-generic
      
      So we can do the similar things in samples/bpf/Makefile, just add
      platform specific and generic include dir for MIPS Loongson64 to
      fix the build errors.
      
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/1611669925-25315-1-git-send-email-yangtiezhu@loongson.cn
      058107ab
  6. Jan 25, 2021
    • Tiezhu Yang's avatar
      samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings · 190d1c92
      Tiezhu Yang authored
      
      There exists many build warnings when make M=samples/bpf on the Loongson
      platform, this issue is MIPS related, x86 compiles just fine.
      
      Here are some warnings:
      
        CC  samples/bpf/ibumad_user.o
      samples/bpf/ibumad_user.c: In function ‘dump_counts’:
      samples/bpf/ibumad_user.c:46:24: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
          printf("0x%02x : %llu\n", key, value);
                           ~~~^          ~~~~~
                           %lu
        CC  samples/bpf/offwaketime_user.o
      samples/bpf/offwaketime_user.c: In function ‘print_ksym’:
      samples/bpf/offwaketime_user.c:34:17: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
         printf("%s/%llx;", sym->name, addr);
                    ~~~^               ~~~~
                    %lx
      samples/bpf/offwaketime_user.c: In function ‘print_stack’:
      samples/bpf/offwaketime_user.c:68:17: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
        printf(";%s %lld\n", key->waker, count);
                    ~~~^                 ~~~~~
                    %ld
      
      MIPS needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
      'int-ll64.h' in arch/mips/include/uapi/asm/types.h, then it can avoid
      build warnings when printing __u64 with %llu, %llx or %lld.
      
      The header tools/include/linux/types.h defines __SANE_USERSPACE_TYPES__,
      it seems that we can include <linux/types.h> in the source files which
      have build warnings, but it has no effect due to actually it includes
      usr/include/linux/types.h instead of tools/include/linux/types.h, the
      problem is that "usr/include" is preferred first than "tools/include"
      in samples/bpf/Makefile, that sounds like a ugly hack to -Itools/include
      before -Iusr/include.
      
      So define __SANE_USERSPACE_TYPES__ for MIPS in samples/bpf/Makefile
      is proper, if add "TPROGS_CFLAGS += -D__SANE_USERSPACE_TYPES__" in
      samples/bpf/Makefile, it appears the following error:
      
      Auto-detecting system features:
      ...                        libelf: [ on  ]
      ...                          zlib: [ on  ]
      ...                           bpf: [ OFF ]
      
      BPF API too old
      make[3]: *** [Makefile:293: bpfdep] Error 1
      make[2]: *** [Makefile:156: all] Error 2
      
      With #ifndef __SANE_USERSPACE_TYPES__  in tools/include/linux/types.h,
      the above error has gone and this ifndef change does not hurt other
      compilations.
      
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/1611551146-14052-1-git-send-email-yangtiezhu@loongson.cn
      190d1c92
  7. Jan 22, 2021
  8. Jan 21, 2021
  9. Jan 20, 2021
  10. Jan 18, 2021
  11. Jan 15, 2021
  12. Jan 11, 2021
  13. Dec 10, 2020
  14. Dec 03, 2020
  15. Dec 01, 2020
  16. Nov 30, 2020
  17. Nov 27, 2020
  18. Nov 24, 2020
  19. Nov 17, 2020
  20. Nov 10, 2020
  21. Nov 09, 2020
  22. Oct 28, 2020
  23. Oct 27, 2020
  24. Oct 21, 2020
    • Daniel Borkmann's avatar
      bpf, libbpf: Guard bpf inline asm from bpf_tail_call_static · 3652c9a1
      Daniel Borkmann authored
      
      Yaniv reported a compilation error after pulling latest libbpf:
      
        [...]
        ../libbpf/src/root/usr/include/bpf/bpf_helpers.h:99:10: error:
        unknown register name 'r0' in asm
                           : "r0", "r1", "r2", "r3", "r4", "r5");
        [...]
      
      The issue got triggered given Yaniv was compiling tracing programs with native
      target (e.g. x86) instead of BPF target, hence no BTF generated vmlinux.h nor
      CO-RE used, and later llc with -march=bpf was invoked to compile from LLVM IR
      to BPF object file. Given that clang was expecting x86 inline asm and not BPF
      one the error complained that these regs don't exist on the former.
      
      Guard bpf_tail_call_static() with defined(__bpf__) where BPF inline asm is valid
      to use. BPF tracing programs on more modern kernels use BPF target anyway and
      thus the bpf_tail_call_static() function will be available for them. BPF inline
      asm is supported since clang 7 (clang <= 6 otherwise throws same above error),
      and __bpf_unreachable() since clang 8, therefore include the latter condition
      in order to prevent compilation errors for older clang versions. Given even an
      old Ubuntu 18.04 LTS has official LLVM packages all the way up to llvm-10, I did
      not bother to special case the __bpf_unreachable() inside bpf_tail_call_static()
      further.
      
      Also, undo the sockex3_kern's use of bpf_tail_call_static() sample given they
      still have the old hacky way to even compile networking progs with native instead
      of BPF target so bpf_tail_call_static() won't be defined there anymore.
      
      Fixes: 0e9f6841 ("bpf, libbpf: Add bpf_tail_call_static helper for bpf programs")
      Reported-by: default avatarYaniv Agman <yanivagman@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Tested-by: default avatarYaniv Agman <yanivagman@gmail.com>
      Link: https://lore.kernel.org/bpf/CAMy7=ZUk08w5Gc2Z-EKi4JFtuUCaZYmE4yzhJjrExXpYKR4L8w@mail.gmail.com
      Link: https://lore.kernel.org/bpf/20201021203257.26223-1-daniel@iogearbox.net
      3652c9a1
  25. Oct 14, 2020
    • Hui Su's avatar
      mm,kmemleak-test.c: move kmemleak-test.c to samples dir · 1abbef4f
      Hui Su authored
      
      kmemleak-test.c is just a kmemleak test module, which also can not be used
      as a built-in kernel module.  Thus, i think it may should not be in mm
      dir, and move the kmemleak-test.c to samples/kmemleak/kmemleak-test.c.
      Fix the spelling of built-in by the way.
      
      Signed-off-by: default avatarHui Su <sh_def@163.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Divya Indi <divya.indi@oracle.com>
      Cc: Tomas Winkler <tomas.winkler@intel.com>
      Cc: David Howells <dhowells@redhat.com>
      Link: https://lkml.kernel.org/r/20200925183729.GA172837@rlk
      
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1abbef4f
  26. Oct 11, 2020
Loading