remarkable-linux/tools/testing/selftests
Thomas Richter f9ea3225dd bpf: fix selftest/bpf/test_pkt_md_access on s390x
Commit 18f3d6be6b ("selftests/bpf: Add test cases to test narrower ctx field loads")
introduced new eBPF test cases. One of them (test_pkt_md_access.c)
fails on s390x. The BPF verifier error message is:

[root@s8360046 bpf]# ./test_progs
test_pkt_access:PASS:ipv4 349 nsec
test_pkt_access:PASS:ipv6 212 nsec
[....]
libbpf: load bpf program failed: Permission denied
libbpf: -- BEGIN DUMP LOG ---
libbpf:
0: (71) r2 = *(u8 *)(r1 +0)
invalid bpf_context access off=0 size=1

libbpf: -- END LOG --
libbpf: failed to load program 'test1'
libbpf: failed to load object './test_pkt_md_access.o'
Summary: 29 PASSED, 1 FAILED
[root@s8360046 bpf]#

This is caused by a byte endianness issue. S390x is a big endian
architecture.  Pointer access to the lowest byte or halfword of a
four byte value need to add an offset.
On little endian architectures this offset is not needed.

Fix this and use the same approach as the originator used for other files
(for example test_verifier.c) in his original commit.

With this fix the test program test_progs succeeds on s390x:
[root@s8360046 bpf]# ./test_progs
test_pkt_access:PASS:ipv4 236 nsec
test_pkt_access:PASS:ipv6 217 nsec
test_xdp:PASS:ipv4 3624 nsec
test_xdp:PASS:ipv6 1722 nsec
test_l4lb:PASS:ipv4 926 nsec
test_l4lb:PASS:ipv6 1322 nsec
test_tcp_estats:PASS: 0 nsec
test_bpf_obj_id:PASS:get-fd-by-notexist-prog-id 0 nsec
test_bpf_obj_id:PASS:get-fd-by-notexist-map-id 0 nsec
test_bpf_obj_id:PASS:get-prog-info(fd) 0 nsec
test_bpf_obj_id:PASS:get-map-info(fd) 0 nsec
test_bpf_obj_id:PASS:get-prog-info(fd) 0 nsec
test_bpf_obj_id:PASS:get-map-info(fd) 0 nsec
test_bpf_obj_id:PASS:get-prog-fd(next_id) 0 nsec
test_bpf_obj_id:PASS:get-prog-info(next_id->fd) 0 nsec
test_bpf_obj_id:PASS:get-prog-fd(next_id) 0 nsec
test_bpf_obj_id:PASS:get-prog-info(next_id->fd) 0 nsec
test_bpf_obj_id:PASS:check total prog id found by get_next_id 0 nsec
test_bpf_obj_id:PASS:get-map-fd(next_id) 0 nsec
test_bpf_obj_id:PASS:get-map-fd(next_id) 0 nsec
test_bpf_obj_id:PASS:get-map-fd(next_id) 0 nsec
test_bpf_obj_id:PASS:get-map-fd(next_id) 0 nsec
test_bpf_obj_id:PASS:get-map-fd(next_id) 0 nsec
test_bpf_obj_id:PASS:get-map-fd(next_id) 0 nsec
test_bpf_obj_id:PASS:get-map-fd(next_id) 0 nsec
test_bpf_obj_id:PASS:check get-map-info(next_id->fd) 0 nsec
test_bpf_obj_id:PASS:get-map-fd(next_id) 0 nsec
test_bpf_obj_id:PASS:check get-map-info(next_id->fd) 0 nsec
test_bpf_obj_id:PASS:check total map id found by get_next_id 0 nsec
test_pkt_md_access:PASS: 277 nsec
Summary: 30 PASSED, 0 FAILED
[root@s8360046 bpf]#

Fixes: 18f3d6be6b ("selftests/bpf: Add test cases to test narrower ctx field loads")
Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-08-07 10:06:27 -07:00
..
bpf bpf: fix selftest/bpf/test_pkt_md_access on s390x 2017-08-07 10:06:27 -07:00
breakpoints selftests: breakpoints: breakpoint_test_arm64: convert test to use TAP13 2017-06-30 16:16:17 -06:00
capabilities selftests/capabilities: Fix the test_execve test 2017-06-30 10:06:24 -06:00
cpu-hotplug selftests: create test-specific kconfig fragments 2016-02-25 09:47:52 -07:00
cpufreq selftests: create cpufreq kconfig fragments 2017-04-27 08:42:18 -06:00
drivers/gpu drm/i915: Provide a hook for selftests 2017-02-13 20:45:21 +00:00
efivarfs selftests: remove duplicated all and clean target 2017-01-05 13:41:35 -07:00
exec selftests: enable O and KBUILD_OUTPUT 2017-01-05 13:42:22 -07:00
filesystems selftests: move dnotify_test from Documentation/filesystems 2016-09-20 09:09:00 -06:00
firmware driver core patches for 4.11-rc1 2017-02-22 11:44:32 -08:00
ftrace A few more minor updates: 2017-07-13 13:17:19 -07:00
futex selftests: futex: print testcase-name and PASS/FAIL/ERROR status 2017-06-07 10:07:21 -06:00
gpio selftests: gpio: fix clean target to remove all generated files and dirs 2017-04-25 09:49:50 -06:00
ia64 selftests: move ia64 tests from Documentation/ia64 2016-09-20 09:58:12 -06:00
intel_pstate selftests: intel_pstate: add .gitignore 2017-06-30 10:06:24 -06:00
ipc selftests: ipc add missing generated file to .gitignore 2017-01-11 09:51:03 -07:00
kcmp selftests: enable O and KBUILD_OUTPUT 2017-01-05 13:42:22 -07:00
kmod kmod: throttle kmod thread limit 2017-07-14 15:05:13 -07:00
lib selftests: lib: Skip tests on missing test modules 2017-06-23 09:41:53 -06:00
locking locking/ww_mutex: Add ww_mutex to tools/testing/selftests 2017-01-14 11:37:17 +01:00
media_tests selftests: media_tests add a new video device test 2016-07-26 09:59:30 -06:00
membarrier selftests: membarrier: use ksft_* var arg msg api 2017-06-30 16:16:23 -06:00
memfd selftest/memfd/Makefile: Fix build error 2017-06-23 13:35:00 -06:00
memory-hotplug selftests: fix memory-hotplug test 2017-06-30 10:06:23 -06:00
mount selftests: add default rules for c source file 2017-01-05 13:42:01 -07:00
mqueue selftests: remove duplicated all and clean target 2017-01-05 13:41:35 -07:00
net selftest/net/Makefile: Specify output with $(OUTPUT) 2017-06-23 13:35:15 -06:00
networking/timestamping selftests: Move networking/timestamping from Documentation 2016-09-20 09:59:50 -06:00
nsfs selftests: remove duplicated all and clean target 2017-01-05 13:41:35 -07:00
ntb NTB: ntb_test: add parameter for doorbell bitmask 2017-07-06 11:30:06 -04:00
powerpc selftests/powerpc: context_switch use private futexes with threads 2017-06-05 16:55:01 +10:00
prctl selftests: move prctl tests from Documentation/prctl 2016-09-20 09:09:09 -06:00
pstore selftests: add EXTRA_CLEAN for clean target 2017-01-05 13:42:17 -07:00
ptp selftests: move ptp tests from Documentation/ptp 2016-09-20 09:54:38 -06:00
ptrace selftests: remove duplicated all and clean target 2017-01-05 13:41:35 -07:00
rcutorture rcu: Remove RCU CPU stall warnings from Tiny RCU 2017-06-08 18:52:45 -07:00
seccomp linux-kselftest-4.13-rc1-update 2017-07-07 14:04:47 -07:00
sigaltstack tools/testing/selftests/sigaltstack/sas.c: improve output of sigaltstack testcase 2017-02-27 18:43:45 -08:00
size kselftest: convert get_size to use stricter TAP13 format 2017-06-14 18:23:27 -06:00
splice selftests: splice: override clean in lib.mk to fix warnings 2017-04-27 08:05:04 -06:00
static_keys selftests: create test-specific kconfig fragments 2016-02-25 09:47:52 -07:00
sync selftests: sync: Skip the test if kernel support is not found 2017-06-07 10:07:21 -06:00
sysctl test_sysctl: test against int proc_dointvec() array support 2017-07-12 16:26:00 -07:00
tc-testing selftests: Introduce tc testsuite 2017-06-20 13:15:10 -04:00
timers RTC for 4.13 2017-07-13 12:15:06 -07:00
user selftests: create test-specific kconfig fragments 2016-02-25 09:47:52 -07:00
vDSO selftests: move vDSO tests from Documentation/vDSO 2016-09-20 09:58:04 -06:00
vm selftests/vm: Fix test for virtual address range mapping for arm64 2017-06-07 10:07:21 -06:00
watchdog selftests: watchdog: accept multiple params on command line 2017-05-02 10:48:24 -06:00
x86 linux-kselftest-4.12-rc1 2017-05-08 20:43:30 -07:00
zram selftests: add EXTRA_CLEAN for clean target 2017-01-05 13:42:17 -07:00
.gitignore selftests: add gpio generated files to .gitignore 2017-04-25 09:49:38 -06:00
gen_kselftest_tar.sh selftests: Add tool to generate kselftest tar archive 2015-03-24 08:43:19 -06:00
kselftest.h kselftest: add ksft_print_msg() function to output general information 2017-06-30 16:15:04 -06:00
kselftest_harness.h Documentation/dev-tools: Add kselftest_harness documentation 2017-06-07 10:07:22 -06:00
kselftest_install.sh selftests: Add kselftest install tool 2015-03-24 08:43:05 -06:00
lib.mk selftests: lib.mk: define CLEAN macro to allow Makefiles to override clean 2017-04-25 09:46:45 -06:00
Makefile selftests/Makefile: Add missed PHONY targets 2017-04-21 11:24:58 -06:00