1. 02 Aug, 2023 4 commits
    • Alan Maguire's avatar
      selftests/bpf: fix static assert compilation issue for test_cls_*.c · 416c6d01
      Alan Maguire authored
      commit bdeeed34 ("libbpf: fix offsetof() and container_of() to work with CO-RE")
      
      ...was backported to stable trees such as 5.15. The problem is that with older
      LLVM/clang (14/15) - which is often used for older kernels - we see compilation
      failures in BPF selftests now:
      
      In file included from progs/test_cls_redirect_subprogs.c:2:
      progs/test_cls_redirect.c:90:2: error: static assertion expression is not an integral constant expression
              sizeof(flow_ports_t) !=
              ^~~~~~~~~~~~~~~~~~~~~~~
      progs/test_cls_redirect.c:91:3: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
                      offsetofend(struct bpf_sock_tuple, ipv4.dport) -
                      ^
      progs/test_cls_redirect.c:32:3: note: expanded from macro 'offsetofend'
              (offsetof(TYPE, MEMBER) + sizeof((((TYPE *)0)->MEMBER)))
               ^
      tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:86:33: note: expanded from macro 'offsetof'
                                       ^
      In file included from progs/test_cls_redirect_subprogs.c:2:
      progs/test_cls_redirect.c:95:2: error: static assertion expression is not an integral constant expression
              sizeof(flow_ports_t) !=
              ^~~~~~~~~~~~~~~~~~~~~~~
      progs/test_cls_redirect.c:96:3: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
                      offsetofend(struct bpf_sock_tuple, ipv6.dport) -
                      ^
      progs/test_cls_redirect.c:32:3: note: expanded from macro 'offsetofend'
              (offsetof(TYPE, MEMBER) + sizeof((((TYPE *)0)->MEMBER)))
               ^
      tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:86:33: note: expanded from macro 'offsetof'
                                       ^
      2 errors generated.
      make: *** [Makefile:594: tools/testing/selftests/bpf/test_cls_redirect_subprogs.bpf.o] Error 1
      
      The problem is the new offsetof() does not play nice with static asserts.
      Given that the context is a static assert (and CO-RE relocation is not
      needed at compile time), offsetof() usage can be replaced by restoring
      the original offsetof() definition as __builtin_offsetof().
      
      Fixes: bdeeed34 ("libbpf: fix offsetof() and container_of() to work with CO-RE")
      Reported-by: default avatarColm Harrington <colm.harrington@oracle.com>
      Signed-off-by: default avatarAlan Maguire <alan.maguire@oracle.com>
      Tested-by: default avatarYipeng Zou <zouyipeng@huawei.com>
      Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
      Link: https://lore.kernel.org/r/20230802073906.3197480-1-alan.maguire@oracle.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      416c6d01
    • Arnd Bergmann's avatar
      bpf: fix bpf_probe_read_kernel prototype mismatch · 6a5a148a
      Arnd Bergmann authored
      bpf_probe_read_kernel() has a __weak definition in core.c and another
      definition with an incompatible prototype in kernel/trace/bpf_trace.c,
      when CONFIG_BPF_EVENTS is enabled.
      
      Since the two are incompatible, there cannot be a shared declaration in
      a header file, but the lack of a prototype causes a W=1 warning:
      
      kernel/bpf/core.c:1638:12: error: no previous prototype for 'bpf_probe_read_kernel' [-Werror=missing-prototypes]
      
      On 32-bit architectures, the local prototype
      
      u64 __weak bpf_probe_read_kernel(void *dst, u32 size, const void *unsafe_ptr)
      
      passes arguments in other registers as the one in bpf_trace.c
      
      BPF_CALL_3(bpf_probe_read_kernel, void *, dst, u32, size,
                  const void *, unsafe_ptr)
      
      which uses 64-bit arguments in pairs of registers.
      
      As both versions of the function are fairly simple and only really
      differ in one line, just move them into a header file as an inline
      function that does not add any overhead for the bpf_trace.c callers
      and actually avoids a function call for the other one.
      
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/all/ac25cb0f-b804-1649-3afb-1dc6138c2716@iogearbox.net/Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
      Link: https://lore.kernel.org/r/20230801111449.185301-1-arnd@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      6a5a148a
    • Pu Lehui's avatar
      riscv, bpf: Adapt bpf trampoline to optimized riscv ftrace framework · 25ad1065
      Pu Lehui authored
      Commit 6724a76c ("riscv: ftrace: Reduce the detour code size to
      half") optimizes the detour code size of kernel functions to half with
      T0 register and the upcoming DYNAMIC_FTRACE_WITH_DIRECT_CALLS of riscv
      is based on this optimization, we need to adapt riscv bpf trampoline
      based on this. One thing to do is to reduce detour code size of bpf
      programs, and the second is to deal with the return address after the
      execution of bpf trampoline. Meanwhile, we need to construct the frame
      of parent function, otherwise we will miss one layer when unwinding.
      The related tests have passed.
      Signed-off-by: default avatarPu Lehui <pulehui@huawei.com>
      Tested-by: default avatarBjörn Töpel <bjorn@rivosinc.com>
      Link: https://lore.kernel.org/r/20230721100627.2630326-1-pulehui@huaweicloud.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      25ad1065
    • Randy Dunlap's avatar
      libbpf: fix typos in Makefile · 94e38c95
      Randy Dunlap authored
      Capitalize ABI (acronym) and fix spelling of "destination".
      
      Fixes: 70681949 ("libbpf: Improve usability of libbpf Makefile")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: bpf@vger.kernel.org
      Cc: Xin Liu <liuxin350@huawei.com>
      Link: https://lore.kernel.org/r/20230722065236.17010-1-rdunlap@infradead.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      94e38c95
  2. 01 Aug, 2023 6 commits
  3. 31 Jul, 2023 1 commit
  4. 30 Jul, 2023 1 commit
  5. 28 Jul, 2023 28 commits