Skip to content

Commit d65f376

Browse files
AsphalttAlexei Starovoitov
authored andcommitted
bpf: Fix tailcall cases in test_bpf
Since f663a03 ("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 <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Fixes: f663a03 ("bpf, x64: Remove tail call detection") Signed-off-by: Leon Hwang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent c73a968 commit d65f376

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/test_bpf.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15198,6 +15198,7 @@ struct tail_call_test {
1519815198
int flags;
1519915199
int result;
1520015200
int stack_depth;
15201+
bool has_tail_call;
1520115202
};
1520215203

1520315204
/* Flags that can be passed to tail call test cases */
@@ -15273,6 +15274,7 @@ static struct tail_call_test tail_call_tests[] = {
1527315274
BPF_EXIT_INSN(),
1527415275
},
1527515276
.result = 3,
15277+
.has_tail_call = true,
1527615278
},
1527715279
{
1527815280
"Tail call 3",
@@ -15283,6 +15285,7 @@ static struct tail_call_test tail_call_tests[] = {
1528315285
BPF_EXIT_INSN(),
1528415286
},
1528515287
.result = 6,
15288+
.has_tail_call = true,
1528615289
},
1528715290
{
1528815291
"Tail call 4",
@@ -15293,6 +15296,7 @@ static struct tail_call_test tail_call_tests[] = {
1529315296
BPF_EXIT_INSN(),
1529415297
},
1529515298
.result = 10,
15299+
.has_tail_call = true,
1529615300
},
1529715301
{
1529815302
"Tail call load/store leaf",
@@ -15323,6 +15327,7 @@ static struct tail_call_test tail_call_tests[] = {
1532315327
},
1532415328
.result = 0,
1532515329
.stack_depth = 16,
15330+
.has_tail_call = true,
1532615331
},
1532715332
{
1532815333
"Tail call error path, max count reached",
@@ -15335,6 +15340,7 @@ static struct tail_call_test tail_call_tests[] = {
1533515340
},
1533615341
.flags = FLAG_NEED_STATE | FLAG_RESULT_IN_STATE,
1533715342
.result = (MAX_TAIL_CALL_CNT + 1) * MAX_TESTRUNS,
15343+
.has_tail_call = true,
1533815344
},
1533915345
{
1534015346
"Tail call count preserved across function calls",
@@ -15357,6 +15363,7 @@ static struct tail_call_test tail_call_tests[] = {
1535715363
.stack_depth = 8,
1535815364
.flags = FLAG_NEED_STATE | FLAG_RESULT_IN_STATE,
1535915365
.result = (MAX_TAIL_CALL_CNT + 1) * MAX_TESTRUNS,
15366+
.has_tail_call = true,
1536015367
},
1536115368
{
1536215369
"Tail call error path, NULL target",
@@ -15369,6 +15376,7 @@ static struct tail_call_test tail_call_tests[] = {
1536915376
},
1537015377
.flags = FLAG_NEED_STATE | FLAG_RESULT_IN_STATE,
1537115378
.result = MAX_TESTRUNS,
15379+
.has_tail_call = true,
1537215380
},
1537315381
{
1537415382
"Tail call error path, index out of range",
@@ -15381,6 +15389,7 @@ static struct tail_call_test tail_call_tests[] = {
1538115389
},
1538215390
.flags = FLAG_NEED_STATE | FLAG_RESULT_IN_STATE,
1538315391
.result = MAX_TESTRUNS,
15392+
.has_tail_call = true,
1538415393
},
1538515394
};
1538615395

@@ -15430,6 +15439,7 @@ static __init int prepare_tail_call_tests(struct bpf_array **pprogs)
1543015439
fp->len = len;
1543115440
fp->type = BPF_PROG_TYPE_SOCKET_FILTER;
1543215441
fp->aux->stack_depth = test->stack_depth;
15442+
fp->aux->tail_call_reachable = test->has_tail_call;
1543315443
memcpy(fp->insnsi, test->insns, len * sizeof(struct bpf_insn));
1543415444

1543515445
/* Relocate runtime tail call offsets and addresses */

0 commit comments

Comments
 (0)