Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpf: Add bpf_jit_supports_fsession()

The added fsession does not prevent running on those architectures, that
haven't added fsession support.

For example, try to run fsession tests on arm64:

test_fsession_basic:PASS:fsession_test__open_and_load 0 nsec
test_fsession_basic:PASS:fsession_attach 0 nsec
check_result:FAIL:test_run_opts err unexpected error: -14 (errno 14)

In order to prevent such errors, add bpf_jit_supports_fsession() to guard
those architectures.

Fixes: 2d419c44658f ("bpf: add fsession support")
Acked-by: Puranjay Mohan <puranjay@kernel.org>
Tested-by: Puranjay Mohan <puranjay@kernel.org>
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Link: https://lore.kernel.org/r/20260131144950.16294-2-leon.hwang@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Leon Hwang and committed by
Alexei Starovoitov
8798902f f0b5b3d6

+40 -8
+5
arch/x86/net/bpf_jit_comp.c
··· 4112 4112 { 4113 4113 return true; 4114 4114 } 4115 + 4116 + bool bpf_jit_supports_fsession(void) 4117 + { 4118 + return true; 4119 + }
+1
include/linux/filter.h
··· 1167 1167 bool bpf_jit_supports_insn(struct bpf_insn *insn, bool in_arena); 1168 1168 bool bpf_jit_supports_private_stack(void); 1169 1169 bool bpf_jit_supports_timed_may_goto(void); 1170 + bool bpf_jit_supports_fsession(void); 1170 1171 u64 bpf_arch_uaddress_limit(void); 1171 1172 void arch_bpf_stack_walk(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp), void *cookie); 1172 1173 u64 arch_bpf_timed_may_goto(void);
+5
kernel/bpf/core.c
··· 3144 3144 return false; 3145 3145 } 3146 3146 3147 + bool __weak bpf_jit_supports_fsession(void) 3148 + { 3149 + return false; 3150 + } 3151 + 3147 3152 u64 __weak bpf_arch_uaddress_limit(void) 3148 3153 { 3149 3154 #if defined(CONFIG_64BIT) && defined(CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE)
+5
kernel/bpf/verifier.c
··· 24828 24828 case BPF_TRACE_FENTRY: 24829 24829 case BPF_TRACE_FEXIT: 24830 24830 case BPF_TRACE_FSESSION: 24831 + if (prog->expected_attach_type == BPF_TRACE_FSESSION && 24832 + !bpf_jit_supports_fsession()) { 24833 + bpf_log(log, "JIT does not support fsession\n"); 24834 + return -EOPNOTSUPP; 24835 + } 24831 24836 if (!btf_type_is_func(t)) { 24832 24837 bpf_log(log, "attach_btf_id %u is not a function\n", 24833 24838 btf_id);
+24 -8
tools/testing/selftests/bpf/prog_tests/fsession_test.c
··· 29 29 struct fsession_test *skel = NULL; 30 30 int err; 31 31 32 - skel = fsession_test__open_and_load(); 33 - if (!ASSERT_OK_PTR(skel, "fsession_test__open_and_load")) 32 + skel = fsession_test__open(); 33 + if (!ASSERT_OK_PTR(skel, "fsession_test__open")) 34 + return; 35 + 36 + err = fsession_test__load(skel); 37 + if (err == -EOPNOTSUPP) { 38 + test__skip(); 39 + goto cleanup; 40 + } 41 + if (!ASSERT_OK(err, "fsession_test__load")) 34 42 goto cleanup; 35 43 36 44 err = fsession_test__attach(skel); ··· 55 47 struct fsession_test *skel = NULL; 56 48 int err; 57 49 58 - skel = fsession_test__open_and_load(); 59 - if (!ASSERT_OK_PTR(skel, "fsession_test__open_and_load")) 50 + skel = fsession_test__open(); 51 + if (!ASSERT_OK_PTR(skel, "fsession_test__open")) 52 + return; 53 + 54 + err = fsession_test__load(skel); 55 + if (err == -EOPNOTSUPP) { 56 + test__skip(); 57 + goto cleanup; 58 + } 59 + if (!ASSERT_OK(err, "fsession_test__load")) 60 60 goto cleanup; 61 61 62 62 /* first attach */ ··· 110 94 bpf_program__set_autoload(skel->progs.test6, false); 111 95 112 96 err = fsession_test__load(skel); 97 + if (err == -EOPNOTSUPP) { 98 + test__skip(); 99 + goto cleanup; 100 + } 113 101 if (!ASSERT_OK(err, "fsession_test__load")) 114 102 goto cleanup; 115 103 ··· 131 111 132 112 void test_fsession_test(void) 133 113 { 134 - #if !defined(__x86_64__) 135 - test__skip(); 136 - return; 137 - #endif 138 114 if (test__start_subtest("fsession_test")) 139 115 test_fsession_basic(); 140 116 if (test__start_subtest("fsession_reattach"))