Skip to content

Commit 6a28b44

Browse files
4astborkmann
authored andcommitted
selftests/bpf: adjust test_align expected output
since verifier started to print liveness state of the registers adjust expected output of test_align. Now this test checks for both proper alignment handling by verifier and correctness of liveness marks. Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 914cb78 commit 6a28b44

File tree

1 file changed

+78
-78
lines changed

1 file changed

+78
-78
lines changed

tools/testing/selftests/bpf/test_align.c

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ static struct bpf_align_test tests[] = {
6464
.matches = {
6565
{1, "R1=ctx(id=0,off=0,imm=0)"},
6666
{1, "R10=fp0"},
67-
{1, "R3=inv2"},
68-
{2, "R3=inv4"},
69-
{3, "R3=inv8"},
70-
{4, "R3=inv16"},
71-
{5, "R3=inv32"},
67+
{1, "R3_w=inv2"},
68+
{2, "R3_w=inv4"},
69+
{3, "R3_w=inv8"},
70+
{4, "R3_w=inv16"},
71+
{5, "R3_w=inv32"},
7272
},
7373
},
7474
{
@@ -92,17 +92,17 @@ static struct bpf_align_test tests[] = {
9292
.matches = {
9393
{1, "R1=ctx(id=0,off=0,imm=0)"},
9494
{1, "R10=fp0"},
95-
{1, "R3=inv1"},
96-
{2, "R3=inv2"},
97-
{3, "R3=inv4"},
98-
{4, "R3=inv8"},
99-
{5, "R3=inv16"},
100-
{6, "R3=inv1"},
101-
{7, "R4=inv32"},
102-
{8, "R4=inv16"},
103-
{9, "R4=inv8"},
104-
{10, "R4=inv4"},
105-
{11, "R4=inv2"},
95+
{1, "R3_w=inv1"},
96+
{2, "R3_w=inv2"},
97+
{3, "R3_w=inv4"},
98+
{4, "R3_w=inv8"},
99+
{5, "R3_w=inv16"},
100+
{6, "R3_w=inv1"},
101+
{7, "R4_w=inv32"},
102+
{8, "R4_w=inv16"},
103+
{9, "R4_w=inv8"},
104+
{10, "R4_w=inv4"},
105+
{11, "R4_w=inv2"},
106106
},
107107
},
108108
{
@@ -121,12 +121,12 @@ static struct bpf_align_test tests[] = {
121121
.matches = {
122122
{1, "R1=ctx(id=0,off=0,imm=0)"},
123123
{1, "R10=fp0"},
124-
{1, "R3=inv4"},
125-
{2, "R3=inv8"},
126-
{3, "R3=inv10"},
127-
{4, "R4=inv8"},
128-
{5, "R4=inv12"},
129-
{6, "R4=inv14"},
124+
{1, "R3_w=inv4"},
125+
{2, "R3_w=inv8"},
126+
{3, "R3_w=inv10"},
127+
{4, "R4_w=inv8"},
128+
{5, "R4_w=inv12"},
129+
{6, "R4_w=inv14"},
130130
},
131131
},
132132
{
@@ -143,10 +143,10 @@ static struct bpf_align_test tests[] = {
143143
.matches = {
144144
{1, "R1=ctx(id=0,off=0,imm=0)"},
145145
{1, "R10=fp0"},
146-
{1, "R3=inv7"},
147-
{2, "R3=inv7"},
148-
{3, "R3=inv14"},
149-
{4, "R3=inv56"},
146+
{1, "R3_w=inv7"},
147+
{2, "R3_w=inv7"},
148+
{3, "R3_w=inv14"},
149+
{4, "R3_w=inv56"},
150150
},
151151
},
152152

@@ -185,18 +185,18 @@ static struct bpf_align_test tests[] = {
185185
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
186186
.matches = {
187187
{7, "R0=pkt(id=0,off=8,r=8,imm=0)"},
188-
{7, "R3=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
189-
{8, "R3=inv(id=0,umax_value=510,var_off=(0x0; 0x1fe))"},
190-
{9, "R3=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
191-
{10, "R3=inv(id=0,umax_value=2040,var_off=(0x0; 0x7f8))"},
192-
{11, "R3=inv(id=0,umax_value=4080,var_off=(0x0; 0xff0))"},
188+
{7, "R3_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
189+
{8, "R3_w=inv(id=0,umax_value=510,var_off=(0x0; 0x1fe))"},
190+
{9, "R3_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
191+
{10, "R3_w=inv(id=0,umax_value=2040,var_off=(0x0; 0x7f8))"},
192+
{11, "R3_w=inv(id=0,umax_value=4080,var_off=(0x0; 0xff0))"},
193193
{18, "R3=pkt_end(id=0,off=0,imm=0)"},
194-
{18, "R4=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
195-
{19, "R4=inv(id=0,umax_value=8160,var_off=(0x0; 0x1fe0))"},
196-
{20, "R4=inv(id=0,umax_value=4080,var_off=(0x0; 0xff0))"},
197-
{21, "R4=inv(id=0,umax_value=2040,var_off=(0x0; 0x7f8))"},
198-
{22, "R4=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
199-
{23, "R4=inv(id=0,umax_value=510,var_off=(0x0; 0x1fe))"},
194+
{18, "R4_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
195+
{19, "R4_w=inv(id=0,umax_value=8160,var_off=(0x0; 0x1fe0))"},
196+
{20, "R4_w=inv(id=0,umax_value=4080,var_off=(0x0; 0xff0))"},
197+
{21, "R4_w=inv(id=0,umax_value=2040,var_off=(0x0; 0x7f8))"},
198+
{22, "R4_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
199+
{23, "R4_w=inv(id=0,umax_value=510,var_off=(0x0; 0x1fe))"},
200200
},
201201
},
202202
{
@@ -217,16 +217,16 @@ static struct bpf_align_test tests[] = {
217217
},
218218
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
219219
.matches = {
220-
{7, "R3=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
221-
{8, "R4=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
222-
{9, "R4=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
223-
{10, "R4=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
224-
{11, "R4=inv(id=0,umax_value=510,var_off=(0x0; 0x1fe))"},
225-
{12, "R4=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
226-
{13, "R4=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
227-
{14, "R4=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
228-
{15, "R4=inv(id=0,umax_value=2040,var_off=(0x0; 0x7f8))"},
229-
{16, "R4=inv(id=0,umax_value=4080,var_off=(0x0; 0xff0))"},
220+
{7, "R3_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
221+
{8, "R4_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
222+
{9, "R4_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
223+
{10, "R4_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
224+
{11, "R4_w=inv(id=0,umax_value=510,var_off=(0x0; 0x1fe))"},
225+
{12, "R4_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
226+
{13, "R4_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
227+
{14, "R4_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
228+
{15, "R4_w=inv(id=0,umax_value=2040,var_off=(0x0; 0x7f8))"},
229+
{16, "R4_w=inv(id=0,umax_value=4080,var_off=(0x0; 0xff0))"},
230230
},
231231
},
232232
{
@@ -257,14 +257,14 @@ static struct bpf_align_test tests[] = {
257257
},
258258
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
259259
.matches = {
260-
{4, "R5=pkt(id=0,off=0,r=0,imm=0)"},
261-
{5, "R5=pkt(id=0,off=14,r=0,imm=0)"},
262-
{6, "R4=pkt(id=0,off=14,r=0,imm=0)"},
260+
{4, "R5_w=pkt(id=0,off=0,r=0,imm=0)"},
261+
{5, "R5_w=pkt(id=0,off=14,r=0,imm=0)"},
262+
{6, "R4_w=pkt(id=0,off=14,r=0,imm=0)"},
263263
{10, "R2=pkt(id=0,off=0,r=18,imm=0)"},
264264
{10, "R5=pkt(id=0,off=14,r=18,imm=0)"},
265-
{10, "R4=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
266-
{14, "R4=inv(id=0,umax_value=65535,var_off=(0x0; 0xffff))"},
267-
{15, "R4=inv(id=0,umax_value=65535,var_off=(0x0; 0xffff))"},
265+
{10, "R4_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},
266+
{14, "R4_w=inv(id=0,umax_value=65535,var_off=(0x0; 0xffff))"},
267+
{15, "R4_w=inv(id=0,umax_value=65535,var_off=(0x0; 0xffff))"},
268268
},
269269
},
270270
{
@@ -320,11 +320,11 @@ static struct bpf_align_test tests[] = {
320320
* alignment of 4.
321321
*/
322322
{8, "R2=pkt(id=0,off=0,r=8,imm=0)"},
323-
{8, "R6=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
323+
{8, "R6_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
324324
/* Offset is added to packet pointer R5, resulting in
325325
* known fixed offset, and variable offset from R6.
326326
*/
327-
{11, "R5=pkt(id=1,off=14,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
327+
{11, "R5_w=pkt(id=1,off=14,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
328328
/* At the time the word size load is performed from R5,
329329
* it's total offset is NET_IP_ALIGN + reg->off (0) +
330330
* reg->aux_off (14) which is 16. Then the variable
@@ -336,11 +336,11 @@ static struct bpf_align_test tests[] = {
336336
/* Variable offset is added to R5 packet pointer,
337337
* resulting in auxiliary alignment of 4.
338338
*/
339-
{18, "R5=pkt(id=2,off=0,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
339+
{18, "R5_w=pkt(id=2,off=0,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
340340
/* Constant offset is added to R5, resulting in
341341
* reg->off of 14.
342342
*/
343-
{19, "R5=pkt(id=2,off=14,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
343+
{19, "R5_w=pkt(id=2,off=14,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
344344
/* At the time the word size load is performed from R5,
345345
* its total fixed offset is NET_IP_ALIGN + reg->off
346346
* (14) which is 16. Then the variable offset is 4-byte
@@ -352,18 +352,18 @@ static struct bpf_align_test tests[] = {
352352
/* Constant offset is added to R5 packet pointer,
353353
* resulting in reg->off value of 14.
354354
*/
355-
{26, "R5=pkt(id=0,off=14,r=8"},
355+
{26, "R5_w=pkt(id=0,off=14,r=8"},
356356
/* Variable offset is added to R5, resulting in a
357357
* variable offset of (4n).
358358
*/
359-
{27, "R5=pkt(id=3,off=14,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
359+
{27, "R5_w=pkt(id=3,off=14,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
360360
/* Constant is added to R5 again, setting reg->off to 18. */
361-
{28, "R5=pkt(id=3,off=18,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
361+
{28, "R5_w=pkt(id=3,off=18,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
362362
/* And once more we add a variable; resulting var_off
363363
* is still (4n), fixed offset is not changed.
364364
* Also, we create a new reg->id.
365365
*/
366-
{29, "R5=pkt(id=4,off=18,r=0,umax_value=2040,var_off=(0x0; 0x7fc))"},
366+
{29, "R5_w=pkt(id=4,off=18,r=0,umax_value=2040,var_off=(0x0; 0x7fc))"},
367367
/* At the time the word size load is performed from R5,
368368
* its total fixed offset is NET_IP_ALIGN + reg->off (18)
369369
* which is 20. Then the variable offset is (4n), so
@@ -410,11 +410,11 @@ static struct bpf_align_test tests[] = {
410410
* alignment of 4.
411411
*/
412412
{8, "R2=pkt(id=0,off=0,r=8,imm=0)"},
413-
{8, "R6=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
413+
{8, "R6_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
414414
/* Adding 14 makes R6 be (4n+2) */
415-
{9, "R6=inv(id=0,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc))"},
415+
{9, "R6_w=inv(id=0,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc))"},
416416
/* Packet pointer has (4n+2) offset */
417-
{11, "R5=pkt(id=1,off=0,r=0,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc))"},
417+
{11, "R5_w=pkt(id=1,off=0,r=0,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc))"},
418418
{13, "R4=pkt(id=1,off=4,r=0,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc))"},
419419
/* At the time the word size load is performed from R5,
420420
* its total fixed offset is NET_IP_ALIGN + reg->off (0)
@@ -426,11 +426,11 @@ static struct bpf_align_test tests[] = {
426426
/* Newly read value in R6 was shifted left by 2, so has
427427
* known alignment of 4.
428428
*/
429-
{18, "R6=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
429+
{18, "R6_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
430430
/* Added (4n) to packet pointer's (4n+2) var_off, giving
431431
* another (4n+2).
432432
*/
433-
{19, "R5=pkt(id=2,off=0,r=0,umin_value=14,umax_value=2054,var_off=(0x2; 0xffc))"},
433+
{19, "R5_w=pkt(id=2,off=0,r=0,umin_value=14,umax_value=2054,var_off=(0x2; 0xffc))"},
434434
{21, "R4=pkt(id=2,off=4,r=0,umin_value=14,umax_value=2054,var_off=(0x2; 0xffc))"},
435435
/* At the time the word size load is performed from R5,
436436
* its total fixed offset is NET_IP_ALIGN + reg->off (0)
@@ -473,19 +473,19 @@ static struct bpf_align_test tests[] = {
473473
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
474474
.result = REJECT,
475475
.matches = {
476-
{4, "R5=pkt(id=0,off=0,r=0,imm=0)"},
476+
{4, "R5_w=pkt(id=0,off=0,r=0,imm=0)"},
477477
/* ptr & 0x40 == either 0 or 0x40 */
478-
{5, "R5=inv(id=0,umax_value=64,var_off=(0x0; 0x40))"},
478+
{5, "R5_w=inv(id=0,umax_value=64,var_off=(0x0; 0x40))"},
479479
/* ptr << 2 == unknown, (4n) */
480-
{7, "R5=inv(id=0,smax_value=9223372036854775804,umax_value=18446744073709551612,var_off=(0x0; 0xfffffffffffffffc))"},
480+
{7, "R5_w=inv(id=0,smax_value=9223372036854775804,umax_value=18446744073709551612,var_off=(0x0; 0xfffffffffffffffc))"},
481481
/* (4n) + 14 == (4n+2). We blow our bounds, because
482482
* the add could overflow.
483483
*/
484484
{8, "R5=inv(id=0,var_off=(0x2; 0xfffffffffffffffc))"},
485485
/* Checked s>=0 */
486486
{10, "R5=inv(id=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc))"},
487487
/* packet pointer + nonnegative (4n+2) */
488-
{12, "R6=pkt(id=1,off=0,r=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc))"},
488+
{12, "R6_w=pkt(id=1,off=0,r=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc))"},
489489
{14, "R4=pkt(id=1,off=4,r=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc))"},
490490
/* NET_IP_ALIGN + (4n+2) == (4n), alignment is fine.
491491
* We checked the bounds, but it might have been able
@@ -530,11 +530,11 @@ static struct bpf_align_test tests[] = {
530530
* alignment of 4.
531531
*/
532532
{7, "R2=pkt(id=0,off=0,r=8,imm=0)"},
533-
{9, "R6=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
533+
{9, "R6_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
534534
/* Adding 14 makes R6 be (4n+2) */
535-
{10, "R6=inv(id=0,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc))"},
535+
{10, "R6_w=inv(id=0,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc))"},
536536
/* New unknown value in R7 is (4n) */
537-
{11, "R7=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
537+
{11, "R7_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},
538538
/* Subtracting it from R6 blows our unsigned bounds */
539539
{12, "R6=inv(id=0,smin_value=-1006,smax_value=1034,var_off=(0x2; 0xfffffffffffffffc))"},
540540
/* Checked s>= 0 */
@@ -583,15 +583,15 @@ static struct bpf_align_test tests[] = {
583583
* alignment of 4.
584584
*/
585585
{7, "R2=pkt(id=0,off=0,r=8,imm=0)"},
586-
{10, "R6=inv(id=0,umax_value=60,var_off=(0x0; 0x3c))"},
586+
{10, "R6_w=inv(id=0,umax_value=60,var_off=(0x0; 0x3c))"},
587587
/* Adding 14 makes R6 be (4n+2) */
588-
{11, "R6=inv(id=0,umin_value=14,umax_value=74,var_off=(0x2; 0x7c))"},
588+
{11, "R6_w=inv(id=0,umin_value=14,umax_value=74,var_off=(0x2; 0x7c))"},
589589
/* Subtracting from packet pointer overflows ubounds */
590-
{13, "R5=pkt(id=1,off=0,r=8,umin_value=18446744073709551542,umax_value=18446744073709551602,var_off=(0xffffffffffffff82; 0x7c))"},
590+
{13, "R5_w=pkt(id=1,off=0,r=8,umin_value=18446744073709551542,umax_value=18446744073709551602,var_off=(0xffffffffffffff82; 0x7c))"},
591591
/* New unknown value in R7 is (4n), >= 76 */
592-
{15, "R7=inv(id=0,umin_value=76,umax_value=1096,var_off=(0x0; 0x7fc))"},
592+
{15, "R7_w=inv(id=0,umin_value=76,umax_value=1096,var_off=(0x0; 0x7fc))"},
593593
/* Adding it to packet pointer gives nice bounds again */
594-
{16, "R5=pkt(id=2,off=0,r=0,umin_value=2,umax_value=1082,var_off=(0x2; 0x7fc))"},
594+
{16, "R5_w=pkt(id=2,off=0,r=0,umin_value=2,umax_value=1082,var_off=(0x2; 0x7fc))"},
595595
/* At the time the word size load is performed from R5,
596596
* its total fixed offset is NET_IP_ALIGN + reg->off (0)
597597
* which is 2. Then the variable offset is (4n+2), so

0 commit comments

Comments
 (0)