Skip to content

Commit 34ac823

Browse files
committed
WIP: selftests/bpf: Fix uprobe tests in attach_probe on arm 32-bit
With test_progs compiled with ARM THUMB insns, trigger_func*() used for testing uprobes have odd (LSB set) entry points due to interworking. This fails alignment check first, then due to uprobe unsupported for THUMB in prepare_uprobe() -> arch_uprobe_analyze_insn() -> arm_probes_decode_insn(). First fix by setting trigger_func*() as ARM insns and rely on interworking enabled by default. Doesn't work on Debian bookworm target because insn #1 of funcs patched to 'UDF torvalds#25' which causes "Illegal instruction". Patched by dynamic loader? Kernel somehow? __attribute__((target("arm"))) Works to compile all test_progs with gcc -marm, or just attach_probe.c. Change Makefile to compile prog_tests/attach_probe.c with '-marm' to avoid using THUMB insns, with expected tests passing: torvalds#8/1 attach_probe/manual-default:OK torvalds#8/2 attach_probe/manual-legacy:OK torvalds#8/3 attach_probe/manual-perf:OK torvalds#8/4 attach_probe/manual-link:OK torvalds#8/5 attach_probe/auto:OK torvalds#8/6 attach_probe/kprobe-sleepable:OK torvalds#8/8 attach_probe/uprobe-sleepable:OK torvalds#8/9 attach_probe/uprobe-ref_ctr:OK torvalds#8/10 attach_probe/uprobe-long_name:OK torvalds#8/11 attach_probe/kprobe-long_name:OK torvalds#8 attach_probe:OK Note that attach_probe/uprobe-lib will still fail since it tries to attach a uprobe to the system libc.so, which is compiled for THUMB: test_attach_probe:PASS:skel_open 0 nsec test_attach_probe:PASS:skel_load 0 nsec test_attach_probe:PASS:check_bss 0 nsec test_attach_probe:PASS:uprobe_ref_ctr_cleanup 0 nsec libbpf: prog 'handle_uprobe_byname2': failed to create uprobe '/lib/arm-linux-gnueabihf/libc.so.6:0x528e1' perf event: -EINVAL test_uprobe_lib:FAIL:attach_uprobe_byname2 unexpected error: -22 torvalds#8/7 attach_probe/uprobe-lib:FAIL torvalds#8 attach_probe:FAIL Also compile other sources and binary with same issue using "-marm": bpf_cookie.c fill_link_info.c task_pt_regs.test.c uprobe_autoattach.c (also tries libc.so attach) usdt.c uprobe_multi Similar problem with some perf tests, which try to set HW breakpoint on a userspace THUMB func but fail when LSB set in insn addr (treated as misaligned). Also use "-marm" to work around. perf_skip.test.o Finally, try adding general 'CFLAG += -marm' if SRCARCH=arm rather than cherry-picking files, and waiting for later breakage. Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com>
1 parent f7ab9f9 commit 34ac823

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/testing/selftests/bpf/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ PCAP_LIBS := $(shell $(PKG_CONFIG) --libs libpcap 2>/dev/null)
5858
LDLIBS += $(PCAP_LIBS)
5959
CFLAGS += $(PCAP_CFLAGS)
6060

61+
# Avoid uprobe and perf event issues with THUMB userspace binaries
62+
CFLAGS += $(if $(filter arm, $(SRCARCH)),-marm)
63+
6164
# Some utility functions use LLVM libraries
6265
jit_disasm_helpers.c-CFLAGS = $(LLVM_CFLAGS)
6366

@@ -888,6 +891,16 @@ $(OUTPUT)/uprobe_multi: uprobe_multi.c uprobe_multi.ld
888891
$(Q)$(CC) $(CFLAGS) -Wl,-T,uprobe_multi.ld -O0 $(LDFLAGS) \
889892
$(filter-out %.ld,$^) $(LDLIBS) -o $@
890893

894+
# Avoid THUMB insns in uprobe or perf testing since not supported
895+
$(OUTPUT)/attach_probe.test.o \
896+
$(OUTPUT)/bpf_cookie.test.o \
897+
$(OUTPUT)/fill_link_info.test.o \
898+
$(OUTPUT)/perf_skip.test.o \
899+
$(OUTPUT)/task_pt_regs.test.o \
900+
$(OUTPUT)/uprobe_autoattach.test.o \
901+
$(OUTPUT)/usdt.test.o \
902+
$(OUTPUT)/uprobe_multi: CFLAGS += $(if $(filter arm, $(ARCH)),-marm)
903+
891904
EXTRA_CLEAN := $(SCRATCH_DIR) $(HOST_SCRATCH_DIR) \
892905
prog_tests/tests.h map_tests/tests.h verifier/tests.h \
893906
feature bpftool $(TEST_KMOD_TARGETS) \

0 commit comments

Comments
 (0)