Skip to content

selftests/bpf: fix compiling loop{1,2,3}.c on s390

Ilya Leoshkevich bpf netdev 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 8 repliesIn review
  2. v34 patches 5 repliesSuperseded
  3. v24 patches 0 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v11 patch5 repliesSuperseded

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4selftests/bpf: compile progs with -D__TARGET_ARCH_$(SRCARCH)tools/testing/selftests/bpf/Makefile+3 -13 replies
2/4selftests/bpf: fix s930 -> s390 typotools/testing/selftests/bpf/bpf_helpers.h+5 -51 reply
3/4selftests/bpf: make PT_REGS_* work in userspacetools/testing/selftests/bpf/bpf_helpers.h+55 -201 reply
4/4selftests/bpf: fix compiling loop{1,2,3}.c on s390tools/testing/selftests/bpf/progs/loop1.c tools/testing/selftests/bpf/progs/loop2.c tools/testing/selftests/bpf/progs/loop3.c+3 -30 replies

Reviews trailers per patch

2 of 4 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchStanislav FomichevAndrii Nakryiko
SeriesR-b
1/4
2/4A-b
3/4A-b
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 bpf-next 0/4] selftests/bpf: fix compiling loop{1,2,3}.c on s390

Use PT_REGS_RC(ctx) instead of ctx->rax, which is not present on s390.

This patch series consists of three preparatory commits, which make it possible to use PT_REGS_RC in BPF selftests, followed by the actual fix.

Quoted 3 lines
Quoted 1 line

Will this also work for 32-bit x86?

Thanks, this is a good catch: this builds, but makes 64-bit accesses, as if it used the 64-bit variant of pt_regs. I will fix this.

I found four problems in this area:

1. Selftest tracing progs are built with -target bpf, leading to struct pt_regs and friends being interpreted incorrectly.
2. When the Makefile is adjusted to build them without -target bpf, it still lacks -m32/-m64, leading to a similar issue.
3. There is no __i386__ define, leading to incorrect userspace struct pt_regs variant being chosen for x86.
4. Finally, there is an issue in my patch: when 1-3 are fixed, it fails to build, since i386 defines yet another set of field names.

I will send fixes for problems 1-3 separately, I believe for this patch series to be correct, it's enough to fix #4 (which I did by adding another #ifdef).

I've also changed ARCH to SRCARCH in patch #1, since while ARCH can be e.g. "i386", SRCARCH always corresponds to directory names under arch/.

v1->v2: Split into multiple patches.
v2->v3: Added arm64 support.
v3->v4: Added i386 support, use SRCARCH instead of ARCH.