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: Fix tailcall cases in test_bpf

Since f663a03c8e35 ("bpf, x64: Remove tail call detection"),
tail_call_reachable won't be detected in x86 JIT. And, tail_call_reachable
is provided by verifier.

Therefore, in test_bpf, the tail_call_reachable must be provided in test
cases before running.

Fix and test:

[ 174.828662] test_bpf: #0 Tail call leaf jited:1 170 PASS
[ 174.829574] test_bpf: #1 Tail call 2 jited:1 244 PASS
[ 174.830363] test_bpf: #2 Tail call 3 jited:1 296 PASS
[ 174.830924] test_bpf: #3 Tail call 4 jited:1 719 PASS
[ 174.831863] test_bpf: #4 Tail call load/store leaf jited:1 197 PASS
[ 174.832240] test_bpf: #5 Tail call load/store jited:1 326 PASS
[ 174.832240] test_bpf: #6 Tail call error path, max count reached jited:1 2214 PASS
[ 174.835713] test_bpf: #7 Tail call count preserved across function calls jited:1 609751 PASS
[ 175.446098] test_bpf: #8 Tail call error path, NULL target jited:1 472 PASS
[ 175.447597] test_bpf: #9 Tail call error path, index out of range jited:1 206 PASS
[ 175.448833] test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]

Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202406251415.c51865bc-oliver.sang@intel.com
Fixes: f663a03c8e35 ("bpf, x64: Remove tail call detection")
Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
Link: https://lore.kernel.org/r/20240625145351.40072-1-hffilwlqm@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Leon Hwang and committed by
Alexei Starovoitov
d65f3767 c73a9683

+10
+10
lib/test_bpf.c
··· 15198 15198 int flags; 15199 15199 int result; 15200 15200 int stack_depth; 15201 + bool has_tail_call; 15201 15202 }; 15202 15203 15203 15204 /* Flags that can be passed to tail call test cases */ ··· 15274 15273 BPF_EXIT_INSN(), 15275 15274 }, 15276 15275 .result = 3, 15276 + .has_tail_call = true, 15277 15277 }, 15278 15278 { 15279 15279 "Tail call 3", ··· 15285 15283 BPF_EXIT_INSN(), 15286 15284 }, 15287 15285 .result = 6, 15286 + .has_tail_call = true, 15288 15287 }, 15289 15288 { 15290 15289 "Tail call 4", ··· 15296 15293 BPF_EXIT_INSN(), 15297 15294 }, 15298 15295 .result = 10, 15296 + .has_tail_call = true, 15299 15297 }, 15300 15298 { 15301 15299 "Tail call load/store leaf", ··· 15327 15323 }, 15328 15324 .result = 0, 15329 15325 .stack_depth = 16, 15326 + .has_tail_call = true, 15330 15327 }, 15331 15328 { 15332 15329 "Tail call error path, max count reached", ··· 15340 15335 }, 15341 15336 .flags = FLAG_NEED_STATE | FLAG_RESULT_IN_STATE, 15342 15337 .result = (MAX_TAIL_CALL_CNT + 1) * MAX_TESTRUNS, 15338 + .has_tail_call = true, 15343 15339 }, 15344 15340 { 15345 15341 "Tail call count preserved across function calls", ··· 15363 15357 .stack_depth = 8, 15364 15358 .flags = FLAG_NEED_STATE | FLAG_RESULT_IN_STATE, 15365 15359 .result = (MAX_TAIL_CALL_CNT + 1) * MAX_TESTRUNS, 15360 + .has_tail_call = true, 15366 15361 }, 15367 15362 { 15368 15363 "Tail call error path, NULL target", ··· 15376 15369 }, 15377 15370 .flags = FLAG_NEED_STATE | FLAG_RESULT_IN_STATE, 15378 15371 .result = MAX_TESTRUNS, 15372 + .has_tail_call = true, 15379 15373 }, 15380 15374 { 15381 15375 "Tail call error path, index out of range", ··· 15389 15381 }, 15390 15382 .flags = FLAG_NEED_STATE | FLAG_RESULT_IN_STATE, 15391 15383 .result = MAX_TESTRUNS, 15384 + .has_tail_call = true, 15392 15385 }, 15393 15386 }; 15394 15387 ··· 15439 15430 fp->len = len; 15440 15431 fp->type = BPF_PROG_TYPE_SOCKET_FILTER; 15441 15432 fp->aux->stack_depth = test->stack_depth; 15433 + fp->aux->tail_call_reachable = test->has_tail_call; 15442 15434 memcpy(fp->insnsi, test->insns, len * sizeof(struct bpf_insn)); 15443 15435 15444 15436 /* Relocate runtime tail call offsets and addresses */