------- Comment From i...@de.ibm.com 2020-08-04 18:45 EDT-------
Hi,

I fixed the skydive header as follows:

--- a/ebpf/defs.h
+++ b/ebpf/defs.h
@@ -56,7 +56,7 @@ static __inline int discret_memcmp(char *s1, char *s2, int n)
/* helper marcro to define a map, socket, kprobe section in the
* eBPF elf file.
*/
-#define MAP(NAME) struct bpf_map_def __section("maps/" #NAME) NAME =
+#define MAP(NAME) struct bpf_map_def __section("maps") NAME =
#define SOCKET(NAME) __section("socket_" #NAME)
#define LICENSE __section("license")
and also tried to cherry-pick some of the older kernel patches I wrote, e.g.:

https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=88aa8939c96781089e5ace3492d818074c5c6fe9
https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=05a68e892e89c97df6650cd8cc55058002657cbc
https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=3f161e0ae863a0456d00e5a6c9c81098c62ab7fe

- the new ones I linked here fix samples and aren't relevant for skydive
- but then I found out that quite some common code is missing as well.
For example, on 20.04 LLVM 10 is default. It contains the following
commit:

commit fbb64aa69835c8e3e9efe0afc8a73058b5a0fb3c  # llvmorg-10.0.0
Author: Yonghong Song <y...@fb.com>
Date:   Tue Dec 17 16:24:23 2019 -0800

[BPF] extend BTF_KIND_FUNC to cover global, static and extern funcs

which makes clang produce non-backwards-compatible BTF. This leads to:

[14] FUNC bpf_flow_table type_id=12 vlen != 0
libbpf: Error loading .BTF into kernel: -22.

when loading. It's not that BPF devs did not think about this: in case
kernel cannot handle the new BTF_KIND_FUNC bits, they are supposed to be
sanitized by libbpf. However, Ubuntu 20.04 does not ship the newest
libbpf:

# /usr/sbin/bpftool --version
/usr/lib/linux-tools/5.4.0-42-generic/bpftool v5.4.44

whereas the commit that introduced sanitization is in v5.6:

commit 2d3eb67f64ec317bbfe340cfcc8325d40a6ff317  # v5.6
Author: Alexei Starovoitov <a...@kernel.org>
Date:   Thu Jan 9 22:41:19 2020 -0800

libbpf: Sanitize global functions

Since this now turns into quite an adventure w.r.t. backporting, can't
we try an easier path first? Namely: use clang-8, which is also
available in Ubuntu 20.04, but doesn't include any fancy stuff!

skydive# CLANG=clang-8 GOPATH=$HOME/go make -C ebpf
skydive# bpftool prog load ebpf/flow.o /sys/fs/bpf/flow ; echo $?
0
# bpftool prog load ebpf/flow-gre.o /sys/fs/bpf/flow-gre ; echo $?
0

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1888507

Title:
  [UBUNTU 18.04] BPF programs fail on Ubuntu s390x

Status in Ubuntu on IBM z Systems:
  In Progress
Status in linux package in Ubuntu:
  New
Status in linux source package in Bionic:
  In Progress

Bug description:
  We need to run BPF filters to analyse and monitor network traffic. The
  BPF filters are created by skydive (http://skydive.network). Currently
  skydive fails to install BPF filters on s390x (using Ubuntu 18.04
  currently, soon moving to Ubuntu 20.04).

  Because of these failures, we decided to try the BPF samples that come
  with the kernel first. These samples also fail on s390x while they
  work fine on Intel.

  shense@boe-build:~/bionic/samples/bpf$ uname -a
  Linux boe-build 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:40:36 UTC 
2020 s390x s390x s390x GNU/Linux

  Example instructions:

  sudo apt install -y dpkg-dev clang llvm libelf-dev
  sudo apt-get source linux-image-unsigned-$(uname -r)
  cd linux-4.15.0/
  make headers_install
  make samples/bpf/

  Errors:

  shense@boe-build:~/bionic/samples/bpf$ sudo ./test_map_in_map
  [sudo] password for shense:
  invalid relo for insn[4].code 0x85
  bpf_load_program() err=22
  0: (bf) r7 = r1
  1: (b7) r1 = 0
  2: (63) *(u32 *)(r10 -32) = r1
  3: (bf) r1 = r7
  4: (85) call unknown#-1
  BPF_CALL uses reserved fields
  0: (bf) r7 = r1
  1: (b7) r1 = 0
  2: (63) *(u32 *)(r10 -32) = r1
  3: (bf) r1 = r7
  4: (85) call unknown#-1
  BPF_CALL uses reserved fields

  
  shense@boe-build:~/bionic/samples/bpf$ sudo ./map_perf_test
  invalid relo for insn[22].code 0x85
  bpf_load_program() err=22
  0: (bf) r7 = r1
  1: (18) r1 = 0x207265743a25646e
  3: (7b) *(u64 *)(r10 -16) = r1
  4: (18) r1 = 0x705f616c6c6f632e
  6: (7b) *(u64 *)(r10 -24) = r1
  7: (18) r1 = 0x5f6c72755f686d61
  9: (7b) *(u64 *)(r10 -32) = r1
  10: (18) r1 = 0x7420737472657373
  12: (7b) *(u64 *)(r10 -40) = r1
  13: (18) r1 = 0x4661696c65642061
  15: (7b) *(u64 *)(r10 -48) = r1
  16: (b7) r1 = 0
  17: (73) *(u8 *)(r10 -8) = r1
  18: (b7) r2 = 1
  19: (7b) *(u64 *)(r10 -72) = r2
  20: (63) *(u32 *)(r10 -76) = r1
  21: (bf) r1 = r7
  22: (85) call unknown#-1
  BPF_CALL uses reserved fields
  0: (bf) r7 = r1
  1: (18) r1 = 0x207265743a25646e
  3: (7b) *(u64 *)(r10 -16) = r1
  4: (18) r1 = 0x705f616c6c6f632e
  6: (7b) *(u64 *)(r10 -24) = r1
  7: (18) r1 = 0x5f6c72755f686d61
  9: (7b) *(u64 *)(r10 -32) = r1
  10: (18) r1 = 0x7420737472657373
  12: (7b) *(u64 *)(r10 -40) = r1
  13: (18) r1 = 0x4661696c65642061
  15: (7b) *(u64 *)(r10 -48) = r1
  16: (b7) r1 = 0
  17: (73) *(u8 *)(r10 -8) = r1
  18: (b7) r2 = 1
  19: (7b) *(u64 *)(r10 -72) = r2
  20: (63) *(u32 *)(r10 -76) = r1
  21: (bf) r1 = r7
  22: (85) call unknown#-1
  BPF_CALL uses reserved fields

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-z-systems/+bug/1888507/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to