]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Fix build of task_pt_regs test for arm64
authorJean-Philippe Brucker <jean-philippe@linaro.org>
Mon, 6 Sep 2021 16:36:38 +0000 (17:36 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 7 Sep 2021 15:23:19 +0000 (17:23 +0200)
commita6b3d1d6c63449765e497aad4fdd96451aa72d2c
tree148c398b99ac7f954aa7a3b19bc402e9e48c1424
parent03d6971501cd271b4dc6e3e8265dacf06fb5cf24
selftests/bpf: Fix build of task_pt_regs test for arm64

struct pt_regs is not exported to userspace on all archs. arm64 and s390
export "user_pt_regs" instead, which causes build failure at the moment:

  progs/test_task_pt_regs.c:8:16: error: variable has incomplete type 'struct pt_regs'
  struct pt_regs current_regs = {};

Instead of using pt_regs from ptrace.h, use the larger kernel struct
from vmlinux.h directly. Since the test runner task_pt_regs.c does not
have access to the kernel struct definition, copy it into a char array.

Fixes: 0a31b01959f1 ("bpf: selftests: Add bpf_task_pt_regs() selftest")
Suggested-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Link: https://lore.kernel.org/bpf/20210906163635.302307-1-jean-philippe@linaro.org
tools/testing/selftests/bpf/prog_tests/task_pt_regs.c
tools/testing/selftests/bpf/progs/test_task_pt_regs.c