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

selftests/bpf: Add bpf_testmod_fentry_* functions

Adding 3 bpf_testmod_fentry_* functions to have a way to test
kprobe multi link on kernel module. They follow bpf_fentry_test*
functions prototypes/code.

Adding equivalent functions to all bpf_fentry_test* does not
seems necessary at the moment, could be added later.

Acked-by: Song Liu <song@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20221025134148.3300700-7-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Jiri Olsa and committed by
Alexei Starovoitov
fee356ed 10705b2b

+24
+24
tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
··· 128 128 } 129 129 } 130 130 131 + noinline int bpf_testmod_fentry_test1(int a) 132 + { 133 + return a + 1; 134 + } 135 + 136 + noinline int bpf_testmod_fentry_test2(int a, u64 b) 137 + { 138 + return a + b; 139 + } 140 + 141 + noinline int bpf_testmod_fentry_test3(char a, int b, u64 c) 142 + { 143 + return a + b + c; 144 + } 145 + 146 + int bpf_testmod_fentry_ok; 147 + 131 148 noinline ssize_t 132 149 bpf_testmod_test_read(struct file *file, struct kobject *kobj, 133 150 struct bin_attribute *bin_attr, ··· 184 167 return snprintf(buf, len, "%d\n", writable.val); 185 168 } 186 169 170 + if (bpf_testmod_fentry_test1(1) != 2 || 171 + bpf_testmod_fentry_test2(2, 3) != 5 || 172 + bpf_testmod_fentry_test3(4, 5, 6) != 15) 173 + goto out; 174 + 175 + bpf_testmod_fentry_ok = 1; 176 + out: 187 177 return -EIO; /* always fail */ 188 178 } 189 179 EXPORT_SYMBOL(bpf_testmod_test_read);