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
cpufreq selftests: create cpufreq kconfig fragments 2017-04-27 08:42:18 -06:00
drivers/gpu
efivarfs
exec
filesystems
firmware
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
intel_pstate selftests: intel_pstate: add .gitignore 2017-06-30 10:06:24 -06:00
ipc
kcmp
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
media_tests
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
mqueue
net selftest/net/Makefile: Specify output with $(OUTPUT) 2017-06-23 13:35:15 -06:00
networking/timestamping
nsfs
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
pstore
ptp
ptrace
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
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
vDSO
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
.gitignore selftests: add gpio generated files to .gitignore 2017-04-25 09:49:38 -06:00
Makefile selftests/Makefile: Add missed PHONY targets 2017-04-21 11:24:58 -06:00
gen_kselftest_tar.sh
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
lib.mk selftests: lib.mk: define CLEAN macro to allow Makefiles to override clean 2017-04-25 09:46:45 -06:00