1 /* 2 * Testsuite for BPF interpreter and BPF JIT compiler 3 * 4 * Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of version 2 of the GNU General Public 8 * License as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * General Public License for more details. 14 */ 15 16 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17 18 #include <linux/init.h> 19 #include <linux/module.h> 20 #include <linux/filter.h> 21 #include <linux/skbuff.h> 22 #include <linux/netdevice.h> 23 #include <linux/if_vlan.h> 24 #include <linux/random.h> 25 26 /* General test specific settings */ 27 #define MAX_SUBTESTS 3 28 #define MAX_TESTRUNS 10000 29 #define MAX_DATA 128 30 #define MAX_INSNS 512 31 #define MAX_K 0xffffFFFF 32 33 /* Few constants used to init test 'skb' */ 34 #define SKB_TYPE 3 35 #define SKB_MARK 0x1234aaaa 36 #define SKB_HASH 0x1234aaab 37 #define SKB_QUEUE_MAP 123 38 #define SKB_VLAN_TCI 0xffff 39 #define SKB_DEV_IFINDEX 577 40 #define SKB_DEV_TYPE 588 41 42 /* Redefine REGs to make tests less verbose */ 43 #define R0 BPF_REG_0 44 #define R1 BPF_REG_1 45 #define R2 BPF_REG_2 46 #define R3 BPF_REG_3 47 #define R4 BPF_REG_4 48 #define R5 BPF_REG_5 49 #define R6 BPF_REG_6 50 #define R7 BPF_REG_7 51 #define R8 BPF_REG_8 52 #define R9 BPF_REG_9 53 #define R10 BPF_REG_10 54 55 /* Flags that can be passed to test cases */ 56 #define FLAG_NO_DATA BIT(0) 57 #define FLAG_EXPECTED_FAIL BIT(1) 58 59 enum { 60 CLASSIC = BIT(6), /* Old BPF instructions only. */ 61 INTERNAL = BIT(7), /* Extended instruction set. */ 62 }; 63 64 #define TEST_TYPE_MASK (CLASSIC | INTERNAL) 65 66 struct bpf_test { 67 const char *descr; 68 union { 69 struct sock_filter insns[MAX_INSNS]; 70 struct bpf_insn insns_int[MAX_INSNS]; 71 struct { 72 void *insns; 73 unsigned int len; 74 } ptr; 75 } u; 76 __u8 aux; 77 __u8 data[MAX_DATA]; 78 struct { 79 int data_size; 80 __u32 result; 81 } test[MAX_SUBTESTS]; 82 int (*fill_helper)(struct bpf_test *self); 83 }; 84 85 /* Large test cases need separate allocation and fill handler. */ 86 87 static int bpf_fill_maxinsns1(struct bpf_test *self) 88 { 89 unsigned int len = BPF_MAXINSNS; 90 struct sock_filter *insn; 91 __u32 k = ~0; 92 int i; 93 94 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); 95 if (!insn) 96 return -ENOMEM; 97 98 for (i = 0; i < len; i++, k--) 99 insn[i] = __BPF_STMT(BPF_RET | BPF_K, k); 100 101 self->u.ptr.insns = insn; 102 self->u.ptr.len = len; 103 104 return 0; 105 } 106 107 static int bpf_fill_maxinsns2(struct bpf_test *self) 108 { 109 unsigned int len = BPF_MAXINSNS; 110 struct sock_filter *insn; 111 int i; 112 113 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); 114 if (!insn) 115 return -ENOMEM; 116 117 for (i = 0; i < len; i++) 118 insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe); 119 120 self->u.ptr.insns = insn; 121 self->u.ptr.len = len; 122 123 return 0; 124 } 125 126 static int bpf_fill_maxinsns3(struct bpf_test *self) 127 { 128 unsigned int len = BPF_MAXINSNS; 129 struct sock_filter *insn; 130 struct rnd_state rnd; 131 int i; 132 133 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); 134 if (!insn) 135 return -ENOMEM; 136 137 prandom_seed_state(&rnd, 3141592653589793238ULL); 138 139 for (i = 0; i < len - 1; i++) { 140 __u32 k = prandom_u32_state(&rnd); 141 142 insn[i] = __BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, k); 143 } 144 145 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); 146 147 self->u.ptr.insns = insn; 148 self->u.ptr.len = len; 149 150 return 0; 151 } 152 153 static int bpf_fill_maxinsns4(struct bpf_test *self) 154 { 155 unsigned int len = BPF_MAXINSNS + 1; 156 struct sock_filter *insn; 157 int i; 158 159 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); 160 if (!insn) 161 return -ENOMEM; 162 163 for (i = 0; i < len; i++) 164 insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe); 165 166 self->u.ptr.insns = insn; 167 self->u.ptr.len = len; 168 169 return 0; 170 } 171 172 static int bpf_fill_maxinsns5(struct bpf_test *self) 173 { 174 unsigned int len = BPF_MAXINSNS; 175 struct sock_filter *insn; 176 int i; 177 178 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); 179 if (!insn) 180 return -ENOMEM; 181 182 insn[0] = __BPF_JUMP(BPF_JMP | BPF_JA, len - 2, 0, 0); 183 184 for (i = 1; i < len - 1; i++) 185 insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe); 186 187 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xabababab); 188 189 self->u.ptr.insns = insn; 190 self->u.ptr.len = len; 191 192 return 0; 193 } 194 195 static int bpf_fill_maxinsns6(struct bpf_test *self) 196 { 197 unsigned int len = BPF_MAXINSNS; 198 struct sock_filter *insn; 199 int i; 200 201 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); 202 if (!insn) 203 return -ENOMEM; 204 205 for (i = 0; i < len - 1; i++) 206 insn[i] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF + 207 SKF_AD_VLAN_TAG_PRESENT); 208 209 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); 210 211 self->u.ptr.insns = insn; 212 self->u.ptr.len = len; 213 214 return 0; 215 } 216 217 static int bpf_fill_maxinsns7(struct bpf_test *self) 218 { 219 unsigned int len = BPF_MAXINSNS; 220 struct sock_filter *insn; 221 int i; 222 223 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); 224 if (!insn) 225 return -ENOMEM; 226 227 for (i = 0; i < len - 4; i++) 228 insn[i] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF + 229 SKF_AD_CPU); 230 231 insn[len - 4] = __BPF_STMT(BPF_MISC | BPF_TAX, 0); 232 insn[len - 3] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF + 233 SKF_AD_CPU); 234 insn[len - 2] = __BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0); 235 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); 236 237 self->u.ptr.insns = insn; 238 self->u.ptr.len = len; 239 240 return 0; 241 } 242 243 static int bpf_fill_maxinsns8(struct bpf_test *self) 244 { 245 unsigned int len = BPF_MAXINSNS; 246 struct sock_filter *insn; 247 int i, jmp_off = len - 3; 248 249 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); 250 if (!insn) 251 return -ENOMEM; 252 253 insn[0] = __BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff); 254 255 for (i = 1; i < len - 1; i++) 256 insn[i] = __BPF_JUMP(BPF_JMP | BPF_JGT, 0xffffffff, jmp_off--, 0); 257 258 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0); 259 260 self->u.ptr.insns = insn; 261 self->u.ptr.len = len; 262 263 return 0; 264 } 265 266 static int bpf_fill_maxinsns9(struct bpf_test *self) 267 { 268 unsigned int len = BPF_MAXINSNS; 269 struct bpf_insn *insn; 270 int i; 271 272 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); 273 if (!insn) 274 return -ENOMEM; 275 276 insn[0] = BPF_JMP_IMM(BPF_JA, 0, 0, len - 2); 277 insn[1] = BPF_ALU32_IMM(BPF_MOV, R0, 0xcbababab); 278 insn[2] = BPF_EXIT_INSN(); 279 280 for (i = 3; i < len - 2; i++) 281 insn[i] = BPF_ALU32_IMM(BPF_MOV, R0, 0xfefefefe); 282 283 insn[len - 2] = BPF_EXIT_INSN(); 284 insn[len - 1] = BPF_JMP_IMM(BPF_JA, 0, 0, -(len - 1)); 285 286 self->u.ptr.insns = insn; 287 self->u.ptr.len = len; 288 289 return 0; 290 } 291 292 static int bpf_fill_maxinsns10(struct bpf_test *self) 293 { 294 unsigned int len = BPF_MAXINSNS, hlen = len - 2; 295 struct bpf_insn *insn; 296 int i; 297 298 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL); 299 if (!insn) 300 return -ENOMEM; 301 302 for (i = 0; i < hlen / 2; i++) 303 insn[i] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen - 2 - 2 * i); 304 for (i = hlen - 1; i > hlen / 2; i--) 305 insn[i] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen - 1 - 2 * i); 306 307 insn[hlen / 2] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen / 2 - 1); 308 insn[hlen] = BPF_ALU32_IMM(BPF_MOV, R0, 0xabababac); 309 insn[hlen + 1] = BPF_EXIT_INSN(); 310 311 self->u.ptr.insns = insn; 312 self->u.ptr.len = len; 313 314 return 0; 315 } 316 317 static struct bpf_test tests[] = { 318 { 319 "TAX", 320 .u.insns = { 321 BPF_STMT(BPF_LD | BPF_IMM, 1), 322 BPF_STMT(BPF_MISC | BPF_TAX, 0), 323 BPF_STMT(BPF_LD | BPF_IMM, 2), 324 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 325 BPF_STMT(BPF_ALU | BPF_NEG, 0), /* A == -3 */ 326 BPF_STMT(BPF_MISC | BPF_TAX, 0), 327 BPF_STMT(BPF_LD | BPF_LEN, 0), 328 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 329 BPF_STMT(BPF_MISC | BPF_TAX, 0), /* X == len - 3 */ 330 BPF_STMT(BPF_LD | BPF_B | BPF_IND, 1), 331 BPF_STMT(BPF_RET | BPF_A, 0) 332 }, 333 CLASSIC, 334 { 10, 20, 30, 40, 50 }, 335 { { 2, 10 }, { 3, 20 }, { 4, 30 } }, 336 }, 337 { 338 "TXA", 339 .u.insns = { 340 BPF_STMT(BPF_LDX | BPF_LEN, 0), 341 BPF_STMT(BPF_MISC | BPF_TXA, 0), 342 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 343 BPF_STMT(BPF_RET | BPF_A, 0) /* A == len * 2 */ 344 }, 345 CLASSIC, 346 { 10, 20, 30, 40, 50 }, 347 { { 1, 2 }, { 3, 6 }, { 4, 8 } }, 348 }, 349 { 350 "ADD_SUB_MUL_K", 351 .u.insns = { 352 BPF_STMT(BPF_LD | BPF_IMM, 1), 353 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 2), 354 BPF_STMT(BPF_LDX | BPF_IMM, 3), 355 BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0), 356 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 0xffffffff), 357 BPF_STMT(BPF_ALU | BPF_MUL | BPF_K, 3), 358 BPF_STMT(BPF_RET | BPF_A, 0) 359 }, 360 CLASSIC | FLAG_NO_DATA, 361 { }, 362 { { 0, 0xfffffffd } } 363 }, 364 { 365 "DIV_MOD_KX", 366 .u.insns = { 367 BPF_STMT(BPF_LD | BPF_IMM, 8), 368 BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 2), 369 BPF_STMT(BPF_MISC | BPF_TAX, 0), 370 BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), 371 BPF_STMT(BPF_ALU | BPF_DIV | BPF_X, 0), 372 BPF_STMT(BPF_MISC | BPF_TAX, 0), 373 BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), 374 BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0x70000000), 375 BPF_STMT(BPF_MISC | BPF_TAX, 0), 376 BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), 377 BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0), 378 BPF_STMT(BPF_MISC | BPF_TAX, 0), 379 BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff), 380 BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x70000000), 381 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 382 BPF_STMT(BPF_RET | BPF_A, 0) 383 }, 384 CLASSIC | FLAG_NO_DATA, 385 { }, 386 { { 0, 0x20000000 } } 387 }, 388 { 389 "AND_OR_LSH_K", 390 .u.insns = { 391 BPF_STMT(BPF_LD | BPF_IMM, 0xff), 392 BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0), 393 BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 27), 394 BPF_STMT(BPF_MISC | BPF_TAX, 0), 395 BPF_STMT(BPF_LD | BPF_IMM, 0xf), 396 BPF_STMT(BPF_ALU | BPF_OR | BPF_K, 0xf0), 397 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 398 BPF_STMT(BPF_RET | BPF_A, 0) 399 }, 400 CLASSIC | FLAG_NO_DATA, 401 { }, 402 { { 0, 0x800000ff }, { 1, 0x800000ff } }, 403 }, 404 { 405 "LD_IMM_0", 406 .u.insns = { 407 BPF_STMT(BPF_LD | BPF_IMM, 0), /* ld #0 */ 408 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 1, 0), 409 BPF_STMT(BPF_RET | BPF_K, 0), 410 BPF_STMT(BPF_RET | BPF_K, 1), 411 }, 412 CLASSIC, 413 { }, 414 { { 1, 1 } }, 415 }, 416 { 417 "LD_IND", 418 .u.insns = { 419 BPF_STMT(BPF_LDX | BPF_LEN, 0), 420 BPF_STMT(BPF_LD | BPF_H | BPF_IND, MAX_K), 421 BPF_STMT(BPF_RET | BPF_K, 1) 422 }, 423 CLASSIC, 424 { }, 425 { { 1, 0 }, { 10, 0 }, { 60, 0 } }, 426 }, 427 { 428 "LD_ABS", 429 .u.insns = { 430 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 1000), 431 BPF_STMT(BPF_RET | BPF_K, 1) 432 }, 433 CLASSIC, 434 { }, 435 { { 1, 0 }, { 10, 0 }, { 60, 0 } }, 436 }, 437 { 438 "LD_ABS_LL", 439 .u.insns = { 440 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF), 441 BPF_STMT(BPF_MISC | BPF_TAX, 0), 442 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF + 1), 443 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 444 BPF_STMT(BPF_RET | BPF_A, 0) 445 }, 446 CLASSIC, 447 { 1, 2, 3 }, 448 { { 1, 0 }, { 2, 3 } }, 449 }, 450 { 451 "LD_IND_LL", 452 .u.insns = { 453 BPF_STMT(BPF_LD | BPF_IMM, SKF_LL_OFF - 1), 454 BPF_STMT(BPF_LDX | BPF_LEN, 0), 455 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 456 BPF_STMT(BPF_MISC | BPF_TAX, 0), 457 BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0), 458 BPF_STMT(BPF_RET | BPF_A, 0) 459 }, 460 CLASSIC, 461 { 1, 2, 3, 0xff }, 462 { { 1, 1 }, { 3, 3 }, { 4, 0xff } }, 463 }, 464 { 465 "LD_ABS_NET", 466 .u.insns = { 467 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF), 468 BPF_STMT(BPF_MISC | BPF_TAX, 0), 469 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF + 1), 470 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 471 BPF_STMT(BPF_RET | BPF_A, 0) 472 }, 473 CLASSIC, 474 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 }, 475 { { 15, 0 }, { 16, 3 } }, 476 }, 477 { 478 "LD_IND_NET", 479 .u.insns = { 480 BPF_STMT(BPF_LD | BPF_IMM, SKF_NET_OFF - 15), 481 BPF_STMT(BPF_LDX | BPF_LEN, 0), 482 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 483 BPF_STMT(BPF_MISC | BPF_TAX, 0), 484 BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0), 485 BPF_STMT(BPF_RET | BPF_A, 0) 486 }, 487 CLASSIC, 488 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 }, 489 { { 14, 0 }, { 15, 1 }, { 17, 3 } }, 490 }, 491 { 492 "LD_PKTTYPE", 493 .u.insns = { 494 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 495 SKF_AD_OFF + SKF_AD_PKTTYPE), 496 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0), 497 BPF_STMT(BPF_RET | BPF_K, 1), 498 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 499 SKF_AD_OFF + SKF_AD_PKTTYPE), 500 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0), 501 BPF_STMT(BPF_RET | BPF_K, 1), 502 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 503 SKF_AD_OFF + SKF_AD_PKTTYPE), 504 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0), 505 BPF_STMT(BPF_RET | BPF_K, 1), 506 BPF_STMT(BPF_RET | BPF_A, 0) 507 }, 508 CLASSIC, 509 { }, 510 { { 1, 3 }, { 10, 3 } }, 511 }, 512 { 513 "LD_MARK", 514 .u.insns = { 515 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 516 SKF_AD_OFF + SKF_AD_MARK), 517 BPF_STMT(BPF_RET | BPF_A, 0) 518 }, 519 CLASSIC, 520 { }, 521 { { 1, SKB_MARK}, { 10, SKB_MARK} }, 522 }, 523 { 524 "LD_RXHASH", 525 .u.insns = { 526 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 527 SKF_AD_OFF + SKF_AD_RXHASH), 528 BPF_STMT(BPF_RET | BPF_A, 0) 529 }, 530 CLASSIC, 531 { }, 532 { { 1, SKB_HASH}, { 10, SKB_HASH} }, 533 }, 534 { 535 "LD_QUEUE", 536 .u.insns = { 537 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 538 SKF_AD_OFF + SKF_AD_QUEUE), 539 BPF_STMT(BPF_RET | BPF_A, 0) 540 }, 541 CLASSIC, 542 { }, 543 { { 1, SKB_QUEUE_MAP }, { 10, SKB_QUEUE_MAP } }, 544 }, 545 { 546 "LD_PROTOCOL", 547 .u.insns = { 548 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 1), 549 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 20, 1, 0), 550 BPF_STMT(BPF_RET | BPF_K, 0), 551 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 552 SKF_AD_OFF + SKF_AD_PROTOCOL), 553 BPF_STMT(BPF_MISC | BPF_TAX, 0), 554 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), 555 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 30, 1, 0), 556 BPF_STMT(BPF_RET | BPF_K, 0), 557 BPF_STMT(BPF_MISC | BPF_TXA, 0), 558 BPF_STMT(BPF_RET | BPF_A, 0) 559 }, 560 CLASSIC, 561 { 10, 20, 30 }, 562 { { 10, ETH_P_IP }, { 100, ETH_P_IP } }, 563 }, 564 { 565 "LD_VLAN_TAG", 566 .u.insns = { 567 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 568 SKF_AD_OFF + SKF_AD_VLAN_TAG), 569 BPF_STMT(BPF_RET | BPF_A, 0) 570 }, 571 CLASSIC, 572 { }, 573 { 574 { 1, SKB_VLAN_TCI & ~VLAN_TAG_PRESENT }, 575 { 10, SKB_VLAN_TCI & ~VLAN_TAG_PRESENT } 576 }, 577 }, 578 { 579 "LD_VLAN_TAG_PRESENT", 580 .u.insns = { 581 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 582 SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT), 583 BPF_STMT(BPF_RET | BPF_A, 0) 584 }, 585 CLASSIC, 586 { }, 587 { 588 { 1, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) }, 589 { 10, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) } 590 }, 591 }, 592 { 593 "LD_IFINDEX", 594 .u.insns = { 595 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 596 SKF_AD_OFF + SKF_AD_IFINDEX), 597 BPF_STMT(BPF_RET | BPF_A, 0) 598 }, 599 CLASSIC, 600 { }, 601 { { 1, SKB_DEV_IFINDEX }, { 10, SKB_DEV_IFINDEX } }, 602 }, 603 { 604 "LD_HATYPE", 605 .u.insns = { 606 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 607 SKF_AD_OFF + SKF_AD_HATYPE), 608 BPF_STMT(BPF_RET | BPF_A, 0) 609 }, 610 CLASSIC, 611 { }, 612 { { 1, SKB_DEV_TYPE }, { 10, SKB_DEV_TYPE } }, 613 }, 614 { 615 "LD_CPU", 616 .u.insns = { 617 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 618 SKF_AD_OFF + SKF_AD_CPU), 619 BPF_STMT(BPF_MISC | BPF_TAX, 0), 620 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 621 SKF_AD_OFF + SKF_AD_CPU), 622 BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0), 623 BPF_STMT(BPF_RET | BPF_A, 0) 624 }, 625 CLASSIC, 626 { }, 627 { { 1, 0 }, { 10, 0 } }, 628 }, 629 { 630 "LD_NLATTR", 631 .u.insns = { 632 BPF_STMT(BPF_LDX | BPF_IMM, 2), 633 BPF_STMT(BPF_MISC | BPF_TXA, 0), 634 BPF_STMT(BPF_LDX | BPF_IMM, 3), 635 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 636 SKF_AD_OFF + SKF_AD_NLATTR), 637 BPF_STMT(BPF_RET | BPF_A, 0) 638 }, 639 CLASSIC, 640 #ifdef __BIG_ENDIAN 641 { 0xff, 0xff, 0, 4, 0, 2, 0, 4, 0, 3 }, 642 #else 643 { 0xff, 0xff, 4, 0, 2, 0, 4, 0, 3, 0 }, 644 #endif 645 { { 4, 0 }, { 20, 6 } }, 646 }, 647 { 648 "LD_NLATTR_NEST", 649 .u.insns = { 650 BPF_STMT(BPF_LD | BPF_IMM, 2), 651 BPF_STMT(BPF_LDX | BPF_IMM, 3), 652 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 653 SKF_AD_OFF + SKF_AD_NLATTR_NEST), 654 BPF_STMT(BPF_LD | BPF_IMM, 2), 655 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 656 SKF_AD_OFF + SKF_AD_NLATTR_NEST), 657 BPF_STMT(BPF_LD | BPF_IMM, 2), 658 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 659 SKF_AD_OFF + SKF_AD_NLATTR_NEST), 660 BPF_STMT(BPF_LD | BPF_IMM, 2), 661 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 662 SKF_AD_OFF + SKF_AD_NLATTR_NEST), 663 BPF_STMT(BPF_LD | BPF_IMM, 2), 664 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 665 SKF_AD_OFF + SKF_AD_NLATTR_NEST), 666 BPF_STMT(BPF_LD | BPF_IMM, 2), 667 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 668 SKF_AD_OFF + SKF_AD_NLATTR_NEST), 669 BPF_STMT(BPF_LD | BPF_IMM, 2), 670 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 671 SKF_AD_OFF + SKF_AD_NLATTR_NEST), 672 BPF_STMT(BPF_LD | BPF_IMM, 2), 673 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 674 SKF_AD_OFF + SKF_AD_NLATTR_NEST), 675 BPF_STMT(BPF_RET | BPF_A, 0) 676 }, 677 CLASSIC, 678 #ifdef __BIG_ENDIAN 679 { 0xff, 0xff, 0, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3 }, 680 #else 681 { 0xff, 0xff, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3, 0 }, 682 #endif 683 { { 4, 0 }, { 20, 10 } }, 684 }, 685 { 686 "LD_PAYLOAD_OFF", 687 .u.insns = { 688 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 689 SKF_AD_OFF + SKF_AD_PAY_OFFSET), 690 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 691 SKF_AD_OFF + SKF_AD_PAY_OFFSET), 692 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 693 SKF_AD_OFF + SKF_AD_PAY_OFFSET), 694 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 695 SKF_AD_OFF + SKF_AD_PAY_OFFSET), 696 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 697 SKF_AD_OFF + SKF_AD_PAY_OFFSET), 698 BPF_STMT(BPF_RET | BPF_A, 0) 699 }, 700 CLASSIC, 701 /* 00:00:00:00:00:00 > 00:00:00:00:00:00, ethtype IPv4 (0x0800), 702 * length 98: 127.0.0.1 > 127.0.0.1: ICMP echo request, 703 * id 9737, seq 1, length 64 704 */ 705 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 706 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 707 0x08, 0x00, 708 0x45, 0x00, 0x00, 0x54, 0xac, 0x8b, 0x40, 0x00, 0x40, 709 0x01, 0x90, 0x1b, 0x7f, 0x00, 0x00, 0x01 }, 710 { { 30, 0 }, { 100, 42 } }, 711 }, 712 { 713 "LD_ANC_XOR", 714 .u.insns = { 715 BPF_STMT(BPF_LD | BPF_IMM, 10), 716 BPF_STMT(BPF_LDX | BPF_IMM, 300), 717 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 718 SKF_AD_OFF + SKF_AD_ALU_XOR_X), 719 BPF_STMT(BPF_RET | BPF_A, 0) 720 }, 721 CLASSIC, 722 { }, 723 { { 4, 10 ^ 300 }, { 20, 10 ^ 300 } }, 724 }, 725 { 726 "SPILL_FILL", 727 .u.insns = { 728 BPF_STMT(BPF_LDX | BPF_LEN, 0), 729 BPF_STMT(BPF_LD | BPF_IMM, 2), 730 BPF_STMT(BPF_ALU | BPF_RSH, 1), 731 BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0), 732 BPF_STMT(BPF_ST, 1), /* M1 = 1 ^ len */ 733 BPF_STMT(BPF_ALU | BPF_XOR | BPF_K, 0x80000000), 734 BPF_STMT(BPF_ST, 2), /* M2 = 1 ^ len ^ 0x80000000 */ 735 BPF_STMT(BPF_STX, 15), /* M3 = len */ 736 BPF_STMT(BPF_LDX | BPF_MEM, 1), 737 BPF_STMT(BPF_LD | BPF_MEM, 2), 738 BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0), 739 BPF_STMT(BPF_LDX | BPF_MEM, 15), 740 BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0), 741 BPF_STMT(BPF_RET | BPF_A, 0) 742 }, 743 CLASSIC, 744 { }, 745 { { 1, 0x80000001 }, { 2, 0x80000002 }, { 60, 0x80000000 ^ 60 } } 746 }, 747 { 748 "JEQ", 749 .u.insns = { 750 BPF_STMT(BPF_LDX | BPF_LEN, 0), 751 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), 752 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 1), 753 BPF_STMT(BPF_RET | BPF_K, 1), 754 BPF_STMT(BPF_RET | BPF_K, MAX_K) 755 }, 756 CLASSIC, 757 { 3, 3, 3, 3, 3 }, 758 { { 1, 0 }, { 3, 1 }, { 4, MAX_K } }, 759 }, 760 { 761 "JGT", 762 .u.insns = { 763 BPF_STMT(BPF_LDX | BPF_LEN, 0), 764 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), 765 BPF_JUMP(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 1), 766 BPF_STMT(BPF_RET | BPF_K, 1), 767 BPF_STMT(BPF_RET | BPF_K, MAX_K) 768 }, 769 CLASSIC, 770 { 4, 4, 4, 3, 3 }, 771 { { 2, 0 }, { 3, 1 }, { 4, MAX_K } }, 772 }, 773 { 774 "JGE", 775 .u.insns = { 776 BPF_STMT(BPF_LDX | BPF_LEN, 0), 777 BPF_STMT(BPF_LD | BPF_B | BPF_IND, MAX_K), 778 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 1, 1, 0), 779 BPF_STMT(BPF_RET | BPF_K, 10), 780 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 2, 1, 0), 781 BPF_STMT(BPF_RET | BPF_K, 20), 782 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 3, 1, 0), 783 BPF_STMT(BPF_RET | BPF_K, 30), 784 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 4, 1, 0), 785 BPF_STMT(BPF_RET | BPF_K, 40), 786 BPF_STMT(BPF_RET | BPF_K, MAX_K) 787 }, 788 CLASSIC, 789 { 1, 2, 3, 4, 5 }, 790 { { 1, 20 }, { 3, 40 }, { 5, MAX_K } }, 791 }, 792 { 793 "JSET", 794 .u.insns = { 795 BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), 796 BPF_JUMP(BPF_JMP | BPF_JA, 1, 1, 1), 797 BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), 798 BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), 799 BPF_STMT(BPF_LDX | BPF_LEN, 0), 800 BPF_STMT(BPF_MISC | BPF_TXA, 0), 801 BPF_STMT(BPF_ALU | BPF_SUB | BPF_K, 4), 802 BPF_STMT(BPF_MISC | BPF_TAX, 0), 803 BPF_STMT(BPF_LD | BPF_W | BPF_IND, 0), 804 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 1, 0, 1), 805 BPF_STMT(BPF_RET | BPF_K, 10), 806 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x80000000, 0, 1), 807 BPF_STMT(BPF_RET | BPF_K, 20), 808 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), 809 BPF_STMT(BPF_RET | BPF_K, 30), 810 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), 811 BPF_STMT(BPF_RET | BPF_K, 30), 812 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), 813 BPF_STMT(BPF_RET | BPF_K, 30), 814 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), 815 BPF_STMT(BPF_RET | BPF_K, 30), 816 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0), 817 BPF_STMT(BPF_RET | BPF_K, 30), 818 BPF_STMT(BPF_RET | BPF_K, MAX_K) 819 }, 820 CLASSIC, 821 { 0, 0xAA, 0x55, 1 }, 822 { { 4, 10 }, { 5, 20 }, { 6, MAX_K } }, 823 }, 824 { 825 "tcpdump port 22", 826 .u.insns = { 827 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), 828 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x86dd, 0, 8), /* IPv6 */ 829 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 20), 830 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x84, 2, 0), 831 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 1, 0), 832 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x11, 0, 17), 833 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 54), 834 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 14, 0), 835 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 56), 836 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 12, 13), 837 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x0800, 0, 12), /* IPv4 */ 838 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 23), 839 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x84, 2, 0), 840 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 1, 0), 841 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x11, 0, 8), 842 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20), 843 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x1fff, 6, 0), 844 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14), 845 BPF_STMT(BPF_LD | BPF_H | BPF_IND, 14), 846 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 2, 0), 847 BPF_STMT(BPF_LD | BPF_H | BPF_IND, 16), 848 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 0, 1), 849 BPF_STMT(BPF_RET | BPF_K, 0xffff), 850 BPF_STMT(BPF_RET | BPF_K, 0), 851 }, 852 CLASSIC, 853 /* 3c:07:54:43:e5:76 > 10:bf:48:d6:43:d6, ethertype IPv4(0x0800) 854 * length 114: 10.1.1.149.49700 > 10.1.2.10.22: Flags [P.], 855 * seq 1305692979:1305693027, ack 3650467037, win 65535, 856 * options [nop,nop,TS val 2502645400 ecr 3971138], length 48 857 */ 858 { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6, 859 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76, 860 0x08, 0x00, 861 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5, 862 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */ 863 0x0a, 0x01, 0x01, 0x95, /* ip src */ 864 0x0a, 0x01, 0x02, 0x0a, /* ip dst */ 865 0xc2, 0x24, 866 0x00, 0x16 /* dst port */ }, 867 { { 10, 0 }, { 30, 0 }, { 100, 65535 } }, 868 }, 869 { 870 "tcpdump complex", 871 .u.insns = { 872 /* tcpdump -nei eth0 'tcp port 22 and (((ip[2:2] - 873 * ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0) and 874 * (len > 115 or len < 30000000000)' -d 875 */ 876 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), 877 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x86dd, 30, 0), 878 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x800, 0, 29), 879 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 23), 880 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 0, 27), 881 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20), 882 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x1fff, 25, 0), 883 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14), 884 BPF_STMT(BPF_LD | BPF_H | BPF_IND, 14), 885 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 2, 0), 886 BPF_STMT(BPF_LD | BPF_H | BPF_IND, 16), 887 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 0, 20), 888 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 16), 889 BPF_STMT(BPF_ST, 1), 890 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 14), 891 BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf), 892 BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 2), 893 BPF_STMT(BPF_MISC | BPF_TAX, 0x5), /* libpcap emits K on TAX */ 894 BPF_STMT(BPF_LD | BPF_MEM, 1), 895 BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0), 896 BPF_STMT(BPF_ST, 5), 897 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14), 898 BPF_STMT(BPF_LD | BPF_B | BPF_IND, 26), 899 BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0), 900 BPF_STMT(BPF_ALU | BPF_RSH | BPF_K, 2), 901 BPF_STMT(BPF_MISC | BPF_TAX, 0x9), /* libpcap emits K on TAX */ 902 BPF_STMT(BPF_LD | BPF_MEM, 5), 903 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 4, 0), 904 BPF_STMT(BPF_LD | BPF_LEN, 0), 905 BPF_JUMP(BPF_JMP | BPF_JGT | BPF_K, 0x73, 1, 0), 906 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 0xfc23ac00, 1, 0), 907 BPF_STMT(BPF_RET | BPF_K, 0xffff), 908 BPF_STMT(BPF_RET | BPF_K, 0), 909 }, 910 CLASSIC, 911 { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6, 912 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76, 913 0x08, 0x00, 914 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5, 915 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */ 916 0x0a, 0x01, 0x01, 0x95, /* ip src */ 917 0x0a, 0x01, 0x02, 0x0a, /* ip dst */ 918 0xc2, 0x24, 919 0x00, 0x16 /* dst port */ }, 920 { { 10, 0 }, { 30, 0 }, { 100, 65535 } }, 921 }, 922 { 923 "RET_A", 924 .u.insns = { 925 /* check that unitialized X and A contain zeros */ 926 BPF_STMT(BPF_MISC | BPF_TXA, 0), 927 BPF_STMT(BPF_RET | BPF_A, 0) 928 }, 929 CLASSIC, 930 { }, 931 { {1, 0}, {2, 0} }, 932 }, 933 { 934 "INT: ADD trivial", 935 .u.insns_int = { 936 BPF_ALU64_IMM(BPF_MOV, R1, 1), 937 BPF_ALU64_IMM(BPF_ADD, R1, 2), 938 BPF_ALU64_IMM(BPF_MOV, R2, 3), 939 BPF_ALU64_REG(BPF_SUB, R1, R2), 940 BPF_ALU64_IMM(BPF_ADD, R1, -1), 941 BPF_ALU64_IMM(BPF_MUL, R1, 3), 942 BPF_ALU64_REG(BPF_MOV, R0, R1), 943 BPF_EXIT_INSN(), 944 }, 945 INTERNAL, 946 { }, 947 { { 0, 0xfffffffd } } 948 }, 949 { 950 "INT: MUL_X", 951 .u.insns_int = { 952 BPF_ALU64_IMM(BPF_MOV, R0, -1), 953 BPF_ALU64_IMM(BPF_MOV, R1, -1), 954 BPF_ALU64_IMM(BPF_MOV, R2, 3), 955 BPF_ALU64_REG(BPF_MUL, R1, R2), 956 BPF_JMP_IMM(BPF_JEQ, R1, 0xfffffffd, 1), 957 BPF_EXIT_INSN(), 958 BPF_ALU64_IMM(BPF_MOV, R0, 1), 959 BPF_EXIT_INSN(), 960 }, 961 INTERNAL, 962 { }, 963 { { 0, 1 } } 964 }, 965 { 966 "INT: MUL_X2", 967 .u.insns_int = { 968 BPF_ALU32_IMM(BPF_MOV, R0, -1), 969 BPF_ALU32_IMM(BPF_MOV, R1, -1), 970 BPF_ALU32_IMM(BPF_MOV, R2, 3), 971 BPF_ALU64_REG(BPF_MUL, R1, R2), 972 BPF_ALU64_IMM(BPF_RSH, R1, 8), 973 BPF_JMP_IMM(BPF_JEQ, R1, 0x2ffffff, 1), 974 BPF_EXIT_INSN(), 975 BPF_ALU32_IMM(BPF_MOV, R0, 1), 976 BPF_EXIT_INSN(), 977 }, 978 INTERNAL, 979 { }, 980 { { 0, 1 } } 981 }, 982 { 983 "INT: MUL32_X", 984 .u.insns_int = { 985 BPF_ALU32_IMM(BPF_MOV, R0, -1), 986 BPF_ALU64_IMM(BPF_MOV, R1, -1), 987 BPF_ALU32_IMM(BPF_MOV, R2, 3), 988 BPF_ALU32_REG(BPF_MUL, R1, R2), 989 BPF_ALU64_IMM(BPF_RSH, R1, 8), 990 BPF_JMP_IMM(BPF_JEQ, R1, 0xffffff, 1), 991 BPF_EXIT_INSN(), 992 BPF_ALU32_IMM(BPF_MOV, R0, 1), 993 BPF_EXIT_INSN(), 994 }, 995 INTERNAL, 996 { }, 997 { { 0, 1 } } 998 }, 999 { 1000 /* Have to test all register combinations, since 1001 * JITing of different registers will produce 1002 * different asm code. 1003 */ 1004 "INT: ADD 64-bit", 1005 .u.insns_int = { 1006 BPF_ALU64_IMM(BPF_MOV, R0, 0), 1007 BPF_ALU64_IMM(BPF_MOV, R1, 1), 1008 BPF_ALU64_IMM(BPF_MOV, R2, 2), 1009 BPF_ALU64_IMM(BPF_MOV, R3, 3), 1010 BPF_ALU64_IMM(BPF_MOV, R4, 4), 1011 BPF_ALU64_IMM(BPF_MOV, R5, 5), 1012 BPF_ALU64_IMM(BPF_MOV, R6, 6), 1013 BPF_ALU64_IMM(BPF_MOV, R7, 7), 1014 BPF_ALU64_IMM(BPF_MOV, R8, 8), 1015 BPF_ALU64_IMM(BPF_MOV, R9, 9), 1016 BPF_ALU64_IMM(BPF_ADD, R0, 20), 1017 BPF_ALU64_IMM(BPF_ADD, R1, 20), 1018 BPF_ALU64_IMM(BPF_ADD, R2, 20), 1019 BPF_ALU64_IMM(BPF_ADD, R3, 20), 1020 BPF_ALU64_IMM(BPF_ADD, R4, 20), 1021 BPF_ALU64_IMM(BPF_ADD, R5, 20), 1022 BPF_ALU64_IMM(BPF_ADD, R6, 20), 1023 BPF_ALU64_IMM(BPF_ADD, R7, 20), 1024 BPF_ALU64_IMM(BPF_ADD, R8, 20), 1025 BPF_ALU64_IMM(BPF_ADD, R9, 20), 1026 BPF_ALU64_IMM(BPF_SUB, R0, 10), 1027 BPF_ALU64_IMM(BPF_SUB, R1, 10), 1028 BPF_ALU64_IMM(BPF_SUB, R2, 10), 1029 BPF_ALU64_IMM(BPF_SUB, R3, 10), 1030 BPF_ALU64_IMM(BPF_SUB, R4, 10), 1031 BPF_ALU64_IMM(BPF_SUB, R5, 10), 1032 BPF_ALU64_IMM(BPF_SUB, R6, 10), 1033 BPF_ALU64_IMM(BPF_SUB, R7, 10), 1034 BPF_ALU64_IMM(BPF_SUB, R8, 10), 1035 BPF_ALU64_IMM(BPF_SUB, R9, 10), 1036 BPF_ALU64_REG(BPF_ADD, R0, R0), 1037 BPF_ALU64_REG(BPF_ADD, R0, R1), 1038 BPF_ALU64_REG(BPF_ADD, R0, R2), 1039 BPF_ALU64_REG(BPF_ADD, R0, R3), 1040 BPF_ALU64_REG(BPF_ADD, R0, R4), 1041 BPF_ALU64_REG(BPF_ADD, R0, R5), 1042 BPF_ALU64_REG(BPF_ADD, R0, R6), 1043 BPF_ALU64_REG(BPF_ADD, R0, R7), 1044 BPF_ALU64_REG(BPF_ADD, R0, R8), 1045 BPF_ALU64_REG(BPF_ADD, R0, R9), /* R0 == 155 */ 1046 BPF_JMP_IMM(BPF_JEQ, R0, 155, 1), 1047 BPF_EXIT_INSN(), 1048 BPF_ALU64_REG(BPF_ADD, R1, R0), 1049 BPF_ALU64_REG(BPF_ADD, R1, R1), 1050 BPF_ALU64_REG(BPF_ADD, R1, R2), 1051 BPF_ALU64_REG(BPF_ADD, R1, R3), 1052 BPF_ALU64_REG(BPF_ADD, R1, R4), 1053 BPF_ALU64_REG(BPF_ADD, R1, R5), 1054 BPF_ALU64_REG(BPF_ADD, R1, R6), 1055 BPF_ALU64_REG(BPF_ADD, R1, R7), 1056 BPF_ALU64_REG(BPF_ADD, R1, R8), 1057 BPF_ALU64_REG(BPF_ADD, R1, R9), /* R1 == 456 */ 1058 BPF_JMP_IMM(BPF_JEQ, R1, 456, 1), 1059 BPF_EXIT_INSN(), 1060 BPF_ALU64_REG(BPF_ADD, R2, R0), 1061 BPF_ALU64_REG(BPF_ADD, R2, R1), 1062 BPF_ALU64_REG(BPF_ADD, R2, R2), 1063 BPF_ALU64_REG(BPF_ADD, R2, R3), 1064 BPF_ALU64_REG(BPF_ADD, R2, R4), 1065 BPF_ALU64_REG(BPF_ADD, R2, R5), 1066 BPF_ALU64_REG(BPF_ADD, R2, R6), 1067 BPF_ALU64_REG(BPF_ADD, R2, R7), 1068 BPF_ALU64_REG(BPF_ADD, R2, R8), 1069 BPF_ALU64_REG(BPF_ADD, R2, R9), /* R2 == 1358 */ 1070 BPF_JMP_IMM(BPF_JEQ, R2, 1358, 1), 1071 BPF_EXIT_INSN(), 1072 BPF_ALU64_REG(BPF_ADD, R3, R0), 1073 BPF_ALU64_REG(BPF_ADD, R3, R1), 1074 BPF_ALU64_REG(BPF_ADD, R3, R2), 1075 BPF_ALU64_REG(BPF_ADD, R3, R3), 1076 BPF_ALU64_REG(BPF_ADD, R3, R4), 1077 BPF_ALU64_REG(BPF_ADD, R3, R5), 1078 BPF_ALU64_REG(BPF_ADD, R3, R6), 1079 BPF_ALU64_REG(BPF_ADD, R3, R7), 1080 BPF_ALU64_REG(BPF_ADD, R3, R8), 1081 BPF_ALU64_REG(BPF_ADD, R3, R9), /* R3 == 4063 */ 1082 BPF_JMP_IMM(BPF_JEQ, R3, 4063, 1), 1083 BPF_EXIT_INSN(), 1084 BPF_ALU64_REG(BPF_ADD, R4, R0), 1085 BPF_ALU64_REG(BPF_ADD, R4, R1), 1086 BPF_ALU64_REG(BPF_ADD, R4, R2), 1087 BPF_ALU64_REG(BPF_ADD, R4, R3), 1088 BPF_ALU64_REG(BPF_ADD, R4, R4), 1089 BPF_ALU64_REG(BPF_ADD, R4, R5), 1090 BPF_ALU64_REG(BPF_ADD, R4, R6), 1091 BPF_ALU64_REG(BPF_ADD, R4, R7), 1092 BPF_ALU64_REG(BPF_ADD, R4, R8), 1093 BPF_ALU64_REG(BPF_ADD, R4, R9), /* R4 == 12177 */ 1094 BPF_JMP_IMM(BPF_JEQ, R4, 12177, 1), 1095 BPF_EXIT_INSN(), 1096 BPF_ALU64_REG(BPF_ADD, R5, R0), 1097 BPF_ALU64_REG(BPF_ADD, R5, R1), 1098 BPF_ALU64_REG(BPF_ADD, R5, R2), 1099 BPF_ALU64_REG(BPF_ADD, R5, R3), 1100 BPF_ALU64_REG(BPF_ADD, R5, R4), 1101 BPF_ALU64_REG(BPF_ADD, R5, R5), 1102 BPF_ALU64_REG(BPF_ADD, R5, R6), 1103 BPF_ALU64_REG(BPF_ADD, R5, R7), 1104 BPF_ALU64_REG(BPF_ADD, R5, R8), 1105 BPF_ALU64_REG(BPF_ADD, R5, R9), /* R5 == 36518 */ 1106 BPF_JMP_IMM(BPF_JEQ, R5, 36518, 1), 1107 BPF_EXIT_INSN(), 1108 BPF_ALU64_REG(BPF_ADD, R6, R0), 1109 BPF_ALU64_REG(BPF_ADD, R6, R1), 1110 BPF_ALU64_REG(BPF_ADD, R6, R2), 1111 BPF_ALU64_REG(BPF_ADD, R6, R3), 1112 BPF_ALU64_REG(BPF_ADD, R6, R4), 1113 BPF_ALU64_REG(BPF_ADD, R6, R5), 1114 BPF_ALU64_REG(BPF_ADD, R6, R6), 1115 BPF_ALU64_REG(BPF_ADD, R6, R7), 1116 BPF_ALU64_REG(BPF_ADD, R6, R8), 1117 BPF_ALU64_REG(BPF_ADD, R6, R9), /* R6 == 109540 */ 1118 BPF_JMP_IMM(BPF_JEQ, R6, 109540, 1), 1119 BPF_EXIT_INSN(), 1120 BPF_ALU64_REG(BPF_ADD, R7, R0), 1121 BPF_ALU64_REG(BPF_ADD, R7, R1), 1122 BPF_ALU64_REG(BPF_ADD, R7, R2), 1123 BPF_ALU64_REG(BPF_ADD, R7, R3), 1124 BPF_ALU64_REG(BPF_ADD, R7, R4), 1125 BPF_ALU64_REG(BPF_ADD, R7, R5), 1126 BPF_ALU64_REG(BPF_ADD, R7, R6), 1127 BPF_ALU64_REG(BPF_ADD, R7, R7), 1128 BPF_ALU64_REG(BPF_ADD, R7, R8), 1129 BPF_ALU64_REG(BPF_ADD, R7, R9), /* R7 == 328605 */ 1130 BPF_JMP_IMM(BPF_JEQ, R7, 328605, 1), 1131 BPF_EXIT_INSN(), 1132 BPF_ALU64_REG(BPF_ADD, R8, R0), 1133 BPF_ALU64_REG(BPF_ADD, R8, R1), 1134 BPF_ALU64_REG(BPF_ADD, R8, R2), 1135 BPF_ALU64_REG(BPF_ADD, R8, R3), 1136 BPF_ALU64_REG(BPF_ADD, R8, R4), 1137 BPF_ALU64_REG(BPF_ADD, R8, R5), 1138 BPF_ALU64_REG(BPF_ADD, R8, R6), 1139 BPF_ALU64_REG(BPF_ADD, R8, R7), 1140 BPF_ALU64_REG(BPF_ADD, R8, R8), 1141 BPF_ALU64_REG(BPF_ADD, R8, R9), /* R8 == 985799 */ 1142 BPF_JMP_IMM(BPF_JEQ, R8, 985799, 1), 1143 BPF_EXIT_INSN(), 1144 BPF_ALU64_REG(BPF_ADD, R9, R0), 1145 BPF_ALU64_REG(BPF_ADD, R9, R1), 1146 BPF_ALU64_REG(BPF_ADD, R9, R2), 1147 BPF_ALU64_REG(BPF_ADD, R9, R3), 1148 BPF_ALU64_REG(BPF_ADD, R9, R4), 1149 BPF_ALU64_REG(BPF_ADD, R9, R5), 1150 BPF_ALU64_REG(BPF_ADD, R9, R6), 1151 BPF_ALU64_REG(BPF_ADD, R9, R7), 1152 BPF_ALU64_REG(BPF_ADD, R9, R8), 1153 BPF_ALU64_REG(BPF_ADD, R9, R9), /* R9 == 2957380 */ 1154 BPF_ALU64_REG(BPF_MOV, R0, R9), 1155 BPF_EXIT_INSN(), 1156 }, 1157 INTERNAL, 1158 { }, 1159 { { 0, 2957380 } } 1160 }, 1161 { 1162 "INT: ADD 32-bit", 1163 .u.insns_int = { 1164 BPF_ALU32_IMM(BPF_MOV, R0, 20), 1165 BPF_ALU32_IMM(BPF_MOV, R1, 1), 1166 BPF_ALU32_IMM(BPF_MOV, R2, 2), 1167 BPF_ALU32_IMM(BPF_MOV, R3, 3), 1168 BPF_ALU32_IMM(BPF_MOV, R4, 4), 1169 BPF_ALU32_IMM(BPF_MOV, R5, 5), 1170 BPF_ALU32_IMM(BPF_MOV, R6, 6), 1171 BPF_ALU32_IMM(BPF_MOV, R7, 7), 1172 BPF_ALU32_IMM(BPF_MOV, R8, 8), 1173 BPF_ALU32_IMM(BPF_MOV, R9, 9), 1174 BPF_ALU64_IMM(BPF_ADD, R1, 10), 1175 BPF_ALU64_IMM(BPF_ADD, R2, 10), 1176 BPF_ALU64_IMM(BPF_ADD, R3, 10), 1177 BPF_ALU64_IMM(BPF_ADD, R4, 10), 1178 BPF_ALU64_IMM(BPF_ADD, R5, 10), 1179 BPF_ALU64_IMM(BPF_ADD, R6, 10), 1180 BPF_ALU64_IMM(BPF_ADD, R7, 10), 1181 BPF_ALU64_IMM(BPF_ADD, R8, 10), 1182 BPF_ALU64_IMM(BPF_ADD, R9, 10), 1183 BPF_ALU32_REG(BPF_ADD, R0, R1), 1184 BPF_ALU32_REG(BPF_ADD, R0, R2), 1185 BPF_ALU32_REG(BPF_ADD, R0, R3), 1186 BPF_ALU32_REG(BPF_ADD, R0, R4), 1187 BPF_ALU32_REG(BPF_ADD, R0, R5), 1188 BPF_ALU32_REG(BPF_ADD, R0, R6), 1189 BPF_ALU32_REG(BPF_ADD, R0, R7), 1190 BPF_ALU32_REG(BPF_ADD, R0, R8), 1191 BPF_ALU32_REG(BPF_ADD, R0, R9), /* R0 == 155 */ 1192 BPF_JMP_IMM(BPF_JEQ, R0, 155, 1), 1193 BPF_EXIT_INSN(), 1194 BPF_ALU32_REG(BPF_ADD, R1, R0), 1195 BPF_ALU32_REG(BPF_ADD, R1, R1), 1196 BPF_ALU32_REG(BPF_ADD, R1, R2), 1197 BPF_ALU32_REG(BPF_ADD, R1, R3), 1198 BPF_ALU32_REG(BPF_ADD, R1, R4), 1199 BPF_ALU32_REG(BPF_ADD, R1, R5), 1200 BPF_ALU32_REG(BPF_ADD, R1, R6), 1201 BPF_ALU32_REG(BPF_ADD, R1, R7), 1202 BPF_ALU32_REG(BPF_ADD, R1, R8), 1203 BPF_ALU32_REG(BPF_ADD, R1, R9), /* R1 == 456 */ 1204 BPF_JMP_IMM(BPF_JEQ, R1, 456, 1), 1205 BPF_EXIT_INSN(), 1206 BPF_ALU32_REG(BPF_ADD, R2, R0), 1207 BPF_ALU32_REG(BPF_ADD, R2, R1), 1208 BPF_ALU32_REG(BPF_ADD, R2, R2), 1209 BPF_ALU32_REG(BPF_ADD, R2, R3), 1210 BPF_ALU32_REG(BPF_ADD, R2, R4), 1211 BPF_ALU32_REG(BPF_ADD, R2, R5), 1212 BPF_ALU32_REG(BPF_ADD, R2, R6), 1213 BPF_ALU32_REG(BPF_ADD, R2, R7), 1214 BPF_ALU32_REG(BPF_ADD, R2, R8), 1215 BPF_ALU32_REG(BPF_ADD, R2, R9), /* R2 == 1358 */ 1216 BPF_JMP_IMM(BPF_JEQ, R2, 1358, 1), 1217 BPF_EXIT_INSN(), 1218 BPF_ALU32_REG(BPF_ADD, R3, R0), 1219 BPF_ALU32_REG(BPF_ADD, R3, R1), 1220 BPF_ALU32_REG(BPF_ADD, R3, R2), 1221 BPF_ALU32_REG(BPF_ADD, R3, R3), 1222 BPF_ALU32_REG(BPF_ADD, R3, R4), 1223 BPF_ALU32_REG(BPF_ADD, R3, R5), 1224 BPF_ALU32_REG(BPF_ADD, R3, R6), 1225 BPF_ALU32_REG(BPF_ADD, R3, R7), 1226 BPF_ALU32_REG(BPF_ADD, R3, R8), 1227 BPF_ALU32_REG(BPF_ADD, R3, R9), /* R3 == 4063 */ 1228 BPF_JMP_IMM(BPF_JEQ, R3, 4063, 1), 1229 BPF_EXIT_INSN(), 1230 BPF_ALU32_REG(BPF_ADD, R4, R0), 1231 BPF_ALU32_REG(BPF_ADD, R4, R1), 1232 BPF_ALU32_REG(BPF_ADD, R4, R2), 1233 BPF_ALU32_REG(BPF_ADD, R4, R3), 1234 BPF_ALU32_REG(BPF_ADD, R4, R4), 1235 BPF_ALU32_REG(BPF_ADD, R4, R5), 1236 BPF_ALU32_REG(BPF_ADD, R4, R6), 1237 BPF_ALU32_REG(BPF_ADD, R4, R7), 1238 BPF_ALU32_REG(BPF_ADD, R4, R8), 1239 BPF_ALU32_REG(BPF_ADD, R4, R9), /* R4 == 12177 */ 1240 BPF_JMP_IMM(BPF_JEQ, R4, 12177, 1), 1241 BPF_EXIT_INSN(), 1242 BPF_ALU32_REG(BPF_ADD, R5, R0), 1243 BPF_ALU32_REG(BPF_ADD, R5, R1), 1244 BPF_ALU32_REG(BPF_ADD, R5, R2), 1245 BPF_ALU32_REG(BPF_ADD, R5, R3), 1246 BPF_ALU32_REG(BPF_ADD, R5, R4), 1247 BPF_ALU32_REG(BPF_ADD, R5, R5), 1248 BPF_ALU32_REG(BPF_ADD, R5, R6), 1249 BPF_ALU32_REG(BPF_ADD, R5, R7), 1250 BPF_ALU32_REG(BPF_ADD, R5, R8), 1251 BPF_ALU32_REG(BPF_ADD, R5, R9), /* R5 == 36518 */ 1252 BPF_JMP_IMM(BPF_JEQ, R5, 36518, 1), 1253 BPF_EXIT_INSN(), 1254 BPF_ALU32_REG(BPF_ADD, R6, R0), 1255 BPF_ALU32_REG(BPF_ADD, R6, R1), 1256 BPF_ALU32_REG(BPF_ADD, R6, R2), 1257 BPF_ALU32_REG(BPF_ADD, R6, R3), 1258 BPF_ALU32_REG(BPF_ADD, R6, R4), 1259 BPF_ALU32_REG(BPF_ADD, R6, R5), 1260 BPF_ALU32_REG(BPF_ADD, R6, R6), 1261 BPF_ALU32_REG(BPF_ADD, R6, R7), 1262 BPF_ALU32_REG(BPF_ADD, R6, R8), 1263 BPF_ALU32_REG(BPF_ADD, R6, R9), /* R6 == 109540 */ 1264 BPF_JMP_IMM(BPF_JEQ, R6, 109540, 1), 1265 BPF_EXIT_INSN(), 1266 BPF_ALU32_REG(BPF_ADD, R7, R0), 1267 BPF_ALU32_REG(BPF_ADD, R7, R1), 1268 BPF_ALU32_REG(BPF_ADD, R7, R2), 1269 BPF_ALU32_REG(BPF_ADD, R7, R3), 1270 BPF_ALU32_REG(BPF_ADD, R7, R4), 1271 BPF_ALU32_REG(BPF_ADD, R7, R5), 1272 BPF_ALU32_REG(BPF_ADD, R7, R6), 1273 BPF_ALU32_REG(BPF_ADD, R7, R7), 1274 BPF_ALU32_REG(BPF_ADD, R7, R8), 1275 BPF_ALU32_REG(BPF_ADD, R7, R9), /* R7 == 328605 */ 1276 BPF_JMP_IMM(BPF_JEQ, R7, 328605, 1), 1277 BPF_EXIT_INSN(), 1278 BPF_ALU32_REG(BPF_ADD, R8, R0), 1279 BPF_ALU32_REG(BPF_ADD, R8, R1), 1280 BPF_ALU32_REG(BPF_ADD, R8, R2), 1281 BPF_ALU32_REG(BPF_ADD, R8, R3), 1282 BPF_ALU32_REG(BPF_ADD, R8, R4), 1283 BPF_ALU32_REG(BPF_ADD, R8, R5), 1284 BPF_ALU32_REG(BPF_ADD, R8, R6), 1285 BPF_ALU32_REG(BPF_ADD, R8, R7), 1286 BPF_ALU32_REG(BPF_ADD, R8, R8), 1287 BPF_ALU32_REG(BPF_ADD, R8, R9), /* R8 == 985799 */ 1288 BPF_JMP_IMM(BPF_JEQ, R8, 985799, 1), 1289 BPF_EXIT_INSN(), 1290 BPF_ALU32_REG(BPF_ADD, R9, R0), 1291 BPF_ALU32_REG(BPF_ADD, R9, R1), 1292 BPF_ALU32_REG(BPF_ADD, R9, R2), 1293 BPF_ALU32_REG(BPF_ADD, R9, R3), 1294 BPF_ALU32_REG(BPF_ADD, R9, R4), 1295 BPF_ALU32_REG(BPF_ADD, R9, R5), 1296 BPF_ALU32_REG(BPF_ADD, R9, R6), 1297 BPF_ALU32_REG(BPF_ADD, R9, R7), 1298 BPF_ALU32_REG(BPF_ADD, R9, R8), 1299 BPF_ALU32_REG(BPF_ADD, R9, R9), /* R9 == 2957380 */ 1300 BPF_ALU32_REG(BPF_MOV, R0, R9), 1301 BPF_EXIT_INSN(), 1302 }, 1303 INTERNAL, 1304 { }, 1305 { { 0, 2957380 } } 1306 }, 1307 { /* Mainly checking JIT here. */ 1308 "INT: SUB", 1309 .u.insns_int = { 1310 BPF_ALU64_IMM(BPF_MOV, R0, 0), 1311 BPF_ALU64_IMM(BPF_MOV, R1, 1), 1312 BPF_ALU64_IMM(BPF_MOV, R2, 2), 1313 BPF_ALU64_IMM(BPF_MOV, R3, 3), 1314 BPF_ALU64_IMM(BPF_MOV, R4, 4), 1315 BPF_ALU64_IMM(BPF_MOV, R5, 5), 1316 BPF_ALU64_IMM(BPF_MOV, R6, 6), 1317 BPF_ALU64_IMM(BPF_MOV, R7, 7), 1318 BPF_ALU64_IMM(BPF_MOV, R8, 8), 1319 BPF_ALU64_IMM(BPF_MOV, R9, 9), 1320 BPF_ALU64_REG(BPF_SUB, R0, R0), 1321 BPF_ALU64_REG(BPF_SUB, R0, R1), 1322 BPF_ALU64_REG(BPF_SUB, R0, R2), 1323 BPF_ALU64_REG(BPF_SUB, R0, R3), 1324 BPF_ALU64_REG(BPF_SUB, R0, R4), 1325 BPF_ALU64_REG(BPF_SUB, R0, R5), 1326 BPF_ALU64_REG(BPF_SUB, R0, R6), 1327 BPF_ALU64_REG(BPF_SUB, R0, R7), 1328 BPF_ALU64_REG(BPF_SUB, R0, R8), 1329 BPF_ALU64_REG(BPF_SUB, R0, R9), 1330 BPF_ALU64_IMM(BPF_SUB, R0, 10), 1331 BPF_JMP_IMM(BPF_JEQ, R0, -55, 1), 1332 BPF_EXIT_INSN(), 1333 BPF_ALU64_REG(BPF_SUB, R1, R0), 1334 BPF_ALU64_REG(BPF_SUB, R1, R2), 1335 BPF_ALU64_REG(BPF_SUB, R1, R3), 1336 BPF_ALU64_REG(BPF_SUB, R1, R4), 1337 BPF_ALU64_REG(BPF_SUB, R1, R5), 1338 BPF_ALU64_REG(BPF_SUB, R1, R6), 1339 BPF_ALU64_REG(BPF_SUB, R1, R7), 1340 BPF_ALU64_REG(BPF_SUB, R1, R8), 1341 BPF_ALU64_REG(BPF_SUB, R1, R9), 1342 BPF_ALU64_IMM(BPF_SUB, R1, 10), 1343 BPF_ALU64_REG(BPF_SUB, R2, R0), 1344 BPF_ALU64_REG(BPF_SUB, R2, R1), 1345 BPF_ALU64_REG(BPF_SUB, R2, R3), 1346 BPF_ALU64_REG(BPF_SUB, R2, R4), 1347 BPF_ALU64_REG(BPF_SUB, R2, R5), 1348 BPF_ALU64_REG(BPF_SUB, R2, R6), 1349 BPF_ALU64_REG(BPF_SUB, R2, R7), 1350 BPF_ALU64_REG(BPF_SUB, R2, R8), 1351 BPF_ALU64_REG(BPF_SUB, R2, R9), 1352 BPF_ALU64_IMM(BPF_SUB, R2, 10), 1353 BPF_ALU64_REG(BPF_SUB, R3, R0), 1354 BPF_ALU64_REG(BPF_SUB, R3, R1), 1355 BPF_ALU64_REG(BPF_SUB, R3, R2), 1356 BPF_ALU64_REG(BPF_SUB, R3, R4), 1357 BPF_ALU64_REG(BPF_SUB, R3, R5), 1358 BPF_ALU64_REG(BPF_SUB, R3, R6), 1359 BPF_ALU64_REG(BPF_SUB, R3, R7), 1360 BPF_ALU64_REG(BPF_SUB, R3, R8), 1361 BPF_ALU64_REG(BPF_SUB, R3, R9), 1362 BPF_ALU64_IMM(BPF_SUB, R3, 10), 1363 BPF_ALU64_REG(BPF_SUB, R4, R0), 1364 BPF_ALU64_REG(BPF_SUB, R4, R1), 1365 BPF_ALU64_REG(BPF_SUB, R4, R2), 1366 BPF_ALU64_REG(BPF_SUB, R4, R3), 1367 BPF_ALU64_REG(BPF_SUB, R4, R5), 1368 BPF_ALU64_REG(BPF_SUB, R4, R6), 1369 BPF_ALU64_REG(BPF_SUB, R4, R7), 1370 BPF_ALU64_REG(BPF_SUB, R4, R8), 1371 BPF_ALU64_REG(BPF_SUB, R4, R9), 1372 BPF_ALU64_IMM(BPF_SUB, R4, 10), 1373 BPF_ALU64_REG(BPF_SUB, R5, R0), 1374 BPF_ALU64_REG(BPF_SUB, R5, R1), 1375 BPF_ALU64_REG(BPF_SUB, R5, R2), 1376 BPF_ALU64_REG(BPF_SUB, R5, R3), 1377 BPF_ALU64_REG(BPF_SUB, R5, R4), 1378 BPF_ALU64_REG(BPF_SUB, R5, R6), 1379 BPF_ALU64_REG(BPF_SUB, R5, R7), 1380 BPF_ALU64_REG(BPF_SUB, R5, R8), 1381 BPF_ALU64_REG(BPF_SUB, R5, R9), 1382 BPF_ALU64_IMM(BPF_SUB, R5, 10), 1383 BPF_ALU64_REG(BPF_SUB, R6, R0), 1384 BPF_ALU64_REG(BPF_SUB, R6, R1), 1385 BPF_ALU64_REG(BPF_SUB, R6, R2), 1386 BPF_ALU64_REG(BPF_SUB, R6, R3), 1387 BPF_ALU64_REG(BPF_SUB, R6, R4), 1388 BPF_ALU64_REG(BPF_SUB, R6, R5), 1389 BPF_ALU64_REG(BPF_SUB, R6, R7), 1390 BPF_ALU64_REG(BPF_SUB, R6, R8), 1391 BPF_ALU64_REG(BPF_SUB, R6, R9), 1392 BPF_ALU64_IMM(BPF_SUB, R6, 10), 1393 BPF_ALU64_REG(BPF_SUB, R7, R0), 1394 BPF_ALU64_REG(BPF_SUB, R7, R1), 1395 BPF_ALU64_REG(BPF_SUB, R7, R2), 1396 BPF_ALU64_REG(BPF_SUB, R7, R3), 1397 BPF_ALU64_REG(BPF_SUB, R7, R4), 1398 BPF_ALU64_REG(BPF_SUB, R7, R5), 1399 BPF_ALU64_REG(BPF_SUB, R7, R6), 1400 BPF_ALU64_REG(BPF_SUB, R7, R8), 1401 BPF_ALU64_REG(BPF_SUB, R7, R9), 1402 BPF_ALU64_IMM(BPF_SUB, R7, 10), 1403 BPF_ALU64_REG(BPF_SUB, R8, R0), 1404 BPF_ALU64_REG(BPF_SUB, R8, R1), 1405 BPF_ALU64_REG(BPF_SUB, R8, R2), 1406 BPF_ALU64_REG(BPF_SUB, R8, R3), 1407 BPF_ALU64_REG(BPF_SUB, R8, R4), 1408 BPF_ALU64_REG(BPF_SUB, R8, R5), 1409 BPF_ALU64_REG(BPF_SUB, R8, R6), 1410 BPF_ALU64_REG(BPF_SUB, R8, R7), 1411 BPF_ALU64_REG(BPF_SUB, R8, R9), 1412 BPF_ALU64_IMM(BPF_SUB, R8, 10), 1413 BPF_ALU64_REG(BPF_SUB, R9, R0), 1414 BPF_ALU64_REG(BPF_SUB, R9, R1), 1415 BPF_ALU64_REG(BPF_SUB, R9, R2), 1416 BPF_ALU64_REG(BPF_SUB, R9, R3), 1417 BPF_ALU64_REG(BPF_SUB, R9, R4), 1418 BPF_ALU64_REG(BPF_SUB, R9, R5), 1419 BPF_ALU64_REG(BPF_SUB, R9, R6), 1420 BPF_ALU64_REG(BPF_SUB, R9, R7), 1421 BPF_ALU64_REG(BPF_SUB, R9, R8), 1422 BPF_ALU64_IMM(BPF_SUB, R9, 10), 1423 BPF_ALU64_IMM(BPF_SUB, R0, 10), 1424 BPF_ALU64_IMM(BPF_NEG, R0, 0), 1425 BPF_ALU64_REG(BPF_SUB, R0, R1), 1426 BPF_ALU64_REG(BPF_SUB, R0, R2), 1427 BPF_ALU64_REG(BPF_SUB, R0, R3), 1428 BPF_ALU64_REG(BPF_SUB, R0, R4), 1429 BPF_ALU64_REG(BPF_SUB, R0, R5), 1430 BPF_ALU64_REG(BPF_SUB, R0, R6), 1431 BPF_ALU64_REG(BPF_SUB, R0, R7), 1432 BPF_ALU64_REG(BPF_SUB, R0, R8), 1433 BPF_ALU64_REG(BPF_SUB, R0, R9), 1434 BPF_EXIT_INSN(), 1435 }, 1436 INTERNAL, 1437 { }, 1438 { { 0, 11 } } 1439 }, 1440 { /* Mainly checking JIT here. */ 1441 "INT: XOR", 1442 .u.insns_int = { 1443 BPF_ALU64_REG(BPF_SUB, R0, R0), 1444 BPF_ALU64_REG(BPF_XOR, R1, R1), 1445 BPF_JMP_REG(BPF_JEQ, R0, R1, 1), 1446 BPF_EXIT_INSN(), 1447 BPF_ALU64_IMM(BPF_MOV, R0, 10), 1448 BPF_ALU64_IMM(BPF_MOV, R1, -1), 1449 BPF_ALU64_REG(BPF_SUB, R1, R1), 1450 BPF_ALU64_REG(BPF_XOR, R2, R2), 1451 BPF_JMP_REG(BPF_JEQ, R1, R2, 1), 1452 BPF_EXIT_INSN(), 1453 BPF_ALU64_REG(BPF_SUB, R2, R2), 1454 BPF_ALU64_REG(BPF_XOR, R3, R3), 1455 BPF_ALU64_IMM(BPF_MOV, R0, 10), 1456 BPF_ALU64_IMM(BPF_MOV, R1, -1), 1457 BPF_JMP_REG(BPF_JEQ, R2, R3, 1), 1458 BPF_EXIT_INSN(), 1459 BPF_ALU64_REG(BPF_SUB, R3, R3), 1460 BPF_ALU64_REG(BPF_XOR, R4, R4), 1461 BPF_ALU64_IMM(BPF_MOV, R2, 1), 1462 BPF_ALU64_IMM(BPF_MOV, R5, -1), 1463 BPF_JMP_REG(BPF_JEQ, R3, R4, 1), 1464 BPF_EXIT_INSN(), 1465 BPF_ALU64_REG(BPF_SUB, R4, R4), 1466 BPF_ALU64_REG(BPF_XOR, R5, R5), 1467 BPF_ALU64_IMM(BPF_MOV, R3, 1), 1468 BPF_ALU64_IMM(BPF_MOV, R7, -1), 1469 BPF_JMP_REG(BPF_JEQ, R5, R4, 1), 1470 BPF_EXIT_INSN(), 1471 BPF_ALU64_IMM(BPF_MOV, R5, 1), 1472 BPF_ALU64_REG(BPF_SUB, R5, R5), 1473 BPF_ALU64_REG(BPF_XOR, R6, R6), 1474 BPF_ALU64_IMM(BPF_MOV, R1, 1), 1475 BPF_ALU64_IMM(BPF_MOV, R8, -1), 1476 BPF_JMP_REG(BPF_JEQ, R5, R6, 1), 1477 BPF_EXIT_INSN(), 1478 BPF_ALU64_REG(BPF_SUB, R6, R6), 1479 BPF_ALU64_REG(BPF_XOR, R7, R7), 1480 BPF_JMP_REG(BPF_JEQ, R7, R6, 1), 1481 BPF_EXIT_INSN(), 1482 BPF_ALU64_REG(BPF_SUB, R7, R7), 1483 BPF_ALU64_REG(BPF_XOR, R8, R8), 1484 BPF_JMP_REG(BPF_JEQ, R7, R8, 1), 1485 BPF_EXIT_INSN(), 1486 BPF_ALU64_REG(BPF_SUB, R8, R8), 1487 BPF_ALU64_REG(BPF_XOR, R9, R9), 1488 BPF_JMP_REG(BPF_JEQ, R9, R8, 1), 1489 BPF_EXIT_INSN(), 1490 BPF_ALU64_REG(BPF_SUB, R9, R9), 1491 BPF_ALU64_REG(BPF_XOR, R0, R0), 1492 BPF_JMP_REG(BPF_JEQ, R9, R0, 1), 1493 BPF_EXIT_INSN(), 1494 BPF_ALU64_REG(BPF_SUB, R1, R1), 1495 BPF_ALU64_REG(BPF_XOR, R0, R0), 1496 BPF_JMP_REG(BPF_JEQ, R9, R0, 2), 1497 BPF_ALU64_IMM(BPF_MOV, R0, 0), 1498 BPF_EXIT_INSN(), 1499 BPF_ALU64_IMM(BPF_MOV, R0, 1), 1500 BPF_EXIT_INSN(), 1501 }, 1502 INTERNAL, 1503 { }, 1504 { { 0, 1 } } 1505 }, 1506 { /* Mainly checking JIT here. */ 1507 "INT: MUL", 1508 .u.insns_int = { 1509 BPF_ALU64_IMM(BPF_MOV, R0, 11), 1510 BPF_ALU64_IMM(BPF_MOV, R1, 1), 1511 BPF_ALU64_IMM(BPF_MOV, R2, 2), 1512 BPF_ALU64_IMM(BPF_MOV, R3, 3), 1513 BPF_ALU64_IMM(BPF_MOV, R4, 4), 1514 BPF_ALU64_IMM(BPF_MOV, R5, 5), 1515 BPF_ALU64_IMM(BPF_MOV, R6, 6), 1516 BPF_ALU64_IMM(BPF_MOV, R7, 7), 1517 BPF_ALU64_IMM(BPF_MOV, R8, 8), 1518 BPF_ALU64_IMM(BPF_MOV, R9, 9), 1519 BPF_ALU64_REG(BPF_MUL, R0, R0), 1520 BPF_ALU64_REG(BPF_MUL, R0, R1), 1521 BPF_ALU64_REG(BPF_MUL, R0, R2), 1522 BPF_ALU64_REG(BPF_MUL, R0, R3), 1523 BPF_ALU64_REG(BPF_MUL, R0, R4), 1524 BPF_ALU64_REG(BPF_MUL, R0, R5), 1525 BPF_ALU64_REG(BPF_MUL, R0, R6), 1526 BPF_ALU64_REG(BPF_MUL, R0, R7), 1527 BPF_ALU64_REG(BPF_MUL, R0, R8), 1528 BPF_ALU64_REG(BPF_MUL, R0, R9), 1529 BPF_ALU64_IMM(BPF_MUL, R0, 10), 1530 BPF_JMP_IMM(BPF_JEQ, R0, 439084800, 1), 1531 BPF_EXIT_INSN(), 1532 BPF_ALU64_REG(BPF_MUL, R1, R0), 1533 BPF_ALU64_REG(BPF_MUL, R1, R2), 1534 BPF_ALU64_REG(BPF_MUL, R1, R3), 1535 BPF_ALU64_REG(BPF_MUL, R1, R4), 1536 BPF_ALU64_REG(BPF_MUL, R1, R5), 1537 BPF_ALU64_REG(BPF_MUL, R1, R6), 1538 BPF_ALU64_REG(BPF_MUL, R1, R7), 1539 BPF_ALU64_REG(BPF_MUL, R1, R8), 1540 BPF_ALU64_REG(BPF_MUL, R1, R9), 1541 BPF_ALU64_IMM(BPF_MUL, R1, 10), 1542 BPF_ALU64_REG(BPF_MOV, R2, R1), 1543 BPF_ALU64_IMM(BPF_RSH, R2, 32), 1544 BPF_JMP_IMM(BPF_JEQ, R2, 0x5a924, 1), 1545 BPF_EXIT_INSN(), 1546 BPF_ALU64_IMM(BPF_LSH, R1, 32), 1547 BPF_ALU64_IMM(BPF_ARSH, R1, 32), 1548 BPF_JMP_IMM(BPF_JEQ, R1, 0xebb90000, 1), 1549 BPF_EXIT_INSN(), 1550 BPF_ALU64_REG(BPF_MUL, R2, R0), 1551 BPF_ALU64_REG(BPF_MUL, R2, R1), 1552 BPF_ALU64_REG(BPF_MUL, R2, R3), 1553 BPF_ALU64_REG(BPF_MUL, R2, R4), 1554 BPF_ALU64_REG(BPF_MUL, R2, R5), 1555 BPF_ALU64_REG(BPF_MUL, R2, R6), 1556 BPF_ALU64_REG(BPF_MUL, R2, R7), 1557 BPF_ALU64_REG(BPF_MUL, R2, R8), 1558 BPF_ALU64_REG(BPF_MUL, R2, R9), 1559 BPF_ALU64_IMM(BPF_MUL, R2, 10), 1560 BPF_ALU64_IMM(BPF_RSH, R2, 32), 1561 BPF_ALU64_REG(BPF_MOV, R0, R2), 1562 BPF_EXIT_INSN(), 1563 }, 1564 INTERNAL, 1565 { }, 1566 { { 0, 0x35d97ef2 } } 1567 }, 1568 { 1569 "INT: ALU MIX", 1570 .u.insns_int = { 1571 BPF_ALU64_IMM(BPF_MOV, R0, 11), 1572 BPF_ALU64_IMM(BPF_ADD, R0, -1), 1573 BPF_ALU64_IMM(BPF_MOV, R2, 2), 1574 BPF_ALU64_IMM(BPF_XOR, R2, 3), 1575 BPF_ALU64_REG(BPF_DIV, R0, R2), 1576 BPF_JMP_IMM(BPF_JEQ, R0, 10, 1), 1577 BPF_EXIT_INSN(), 1578 BPF_ALU64_IMM(BPF_MOD, R0, 3), 1579 BPF_JMP_IMM(BPF_JEQ, R0, 1, 1), 1580 BPF_EXIT_INSN(), 1581 BPF_ALU64_IMM(BPF_MOV, R0, -1), 1582 BPF_EXIT_INSN(), 1583 }, 1584 INTERNAL, 1585 { }, 1586 { { 0, -1 } } 1587 }, 1588 { 1589 "INT: shifts by register", 1590 .u.insns_int = { 1591 BPF_MOV64_IMM(R0, -1234), 1592 BPF_MOV64_IMM(R1, 1), 1593 BPF_ALU32_REG(BPF_RSH, R0, R1), 1594 BPF_JMP_IMM(BPF_JEQ, R0, 0x7ffffd97, 1), 1595 BPF_EXIT_INSN(), 1596 BPF_MOV64_IMM(R2, 1), 1597 BPF_ALU64_REG(BPF_LSH, R0, R2), 1598 BPF_MOV32_IMM(R4, -1234), 1599 BPF_JMP_REG(BPF_JEQ, R0, R4, 1), 1600 BPF_EXIT_INSN(), 1601 BPF_ALU64_IMM(BPF_AND, R4, 63), 1602 BPF_ALU64_REG(BPF_LSH, R0, R4), /* R0 <= 46 */ 1603 BPF_MOV64_IMM(R3, 47), 1604 BPF_ALU64_REG(BPF_ARSH, R0, R3), 1605 BPF_JMP_IMM(BPF_JEQ, R0, -617, 1), 1606 BPF_EXIT_INSN(), 1607 BPF_MOV64_IMM(R2, 1), 1608 BPF_ALU64_REG(BPF_LSH, R4, R2), /* R4 = 46 << 1 */ 1609 BPF_JMP_IMM(BPF_JEQ, R4, 92, 1), 1610 BPF_EXIT_INSN(), 1611 BPF_MOV64_IMM(R4, 4), 1612 BPF_ALU64_REG(BPF_LSH, R4, R4), /* R4 = 4 << 4 */ 1613 BPF_JMP_IMM(BPF_JEQ, R4, 64, 1), 1614 BPF_EXIT_INSN(), 1615 BPF_MOV64_IMM(R4, 5), 1616 BPF_ALU32_REG(BPF_LSH, R4, R4), /* R4 = 5 << 5 */ 1617 BPF_JMP_IMM(BPF_JEQ, R4, 160, 1), 1618 BPF_EXIT_INSN(), 1619 BPF_MOV64_IMM(R0, -1), 1620 BPF_EXIT_INSN(), 1621 }, 1622 INTERNAL, 1623 { }, 1624 { { 0, -1 } } 1625 }, 1626 { 1627 "INT: DIV + ABS", 1628 .u.insns_int = { 1629 BPF_ALU64_REG(BPF_MOV, R6, R1), 1630 BPF_LD_ABS(BPF_B, 3), 1631 BPF_ALU64_IMM(BPF_MOV, R2, 2), 1632 BPF_ALU32_REG(BPF_DIV, R0, R2), 1633 BPF_ALU64_REG(BPF_MOV, R8, R0), 1634 BPF_LD_ABS(BPF_B, 4), 1635 BPF_ALU64_REG(BPF_ADD, R8, R0), 1636 BPF_LD_IND(BPF_B, R8, -70), 1637 BPF_EXIT_INSN(), 1638 }, 1639 INTERNAL, 1640 { 10, 20, 30, 40, 50 }, 1641 { { 4, 0 }, { 5, 10 } } 1642 }, 1643 { 1644 "INT: DIV by zero", 1645 .u.insns_int = { 1646 BPF_ALU64_REG(BPF_MOV, R6, R1), 1647 BPF_ALU64_IMM(BPF_MOV, R7, 0), 1648 BPF_LD_ABS(BPF_B, 3), 1649 BPF_ALU32_REG(BPF_DIV, R0, R7), 1650 BPF_EXIT_INSN(), 1651 }, 1652 INTERNAL, 1653 { 10, 20, 30, 40, 50 }, 1654 { { 3, 0 }, { 4, 0 } } 1655 }, 1656 { 1657 "check: missing ret", 1658 .u.insns = { 1659 BPF_STMT(BPF_LD | BPF_IMM, 1), 1660 }, 1661 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, 1662 { }, 1663 { } 1664 }, 1665 { 1666 "check: div_k_0", 1667 .u.insns = { 1668 BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0), 1669 BPF_STMT(BPF_RET | BPF_K, 0) 1670 }, 1671 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, 1672 { }, 1673 { } 1674 }, 1675 { 1676 "check: unknown insn", 1677 .u.insns = { 1678 /* seccomp insn, rejected in socket filter */ 1679 BPF_STMT(BPF_LDX | BPF_W | BPF_ABS, 0), 1680 BPF_STMT(BPF_RET | BPF_K, 0) 1681 }, 1682 CLASSIC | FLAG_EXPECTED_FAIL, 1683 { }, 1684 { } 1685 }, 1686 { 1687 "check: out of range spill/fill", 1688 .u.insns = { 1689 BPF_STMT(BPF_STX, 16), 1690 BPF_STMT(BPF_RET | BPF_K, 0) 1691 }, 1692 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, 1693 { }, 1694 { } 1695 }, 1696 { 1697 "JUMPS + HOLES", 1698 .u.insns = { 1699 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1700 BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 15), 1701 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1702 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1703 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1704 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1705 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1706 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1707 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1708 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1709 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1710 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1711 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1712 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1713 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1714 BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90c2894d, 3, 4), 1715 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1716 BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90c2894d, 1, 2), 1717 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1718 BPF_JUMP(BPF_JMP | BPF_JGE, 0, 14, 15), 1719 BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 14), 1720 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1721 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1722 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1723 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1724 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1725 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1726 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1727 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1728 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1729 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1730 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1731 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1732 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1733 BPF_JUMP(BPF_JMP | BPF_JEQ, 0x2ac28349, 2, 3), 1734 BPF_JUMP(BPF_JMP | BPF_JEQ, 0x2ac28349, 1, 2), 1735 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1736 BPF_JUMP(BPF_JMP | BPF_JGE, 0, 14, 15), 1737 BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 14), 1738 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1739 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1740 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1741 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1742 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1743 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1744 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1745 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1746 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1747 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1748 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1749 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1750 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1751 BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90d2ff41, 2, 3), 1752 BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90d2ff41, 1, 2), 1753 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0), 1754 BPF_STMT(BPF_RET | BPF_A, 0), 1755 BPF_STMT(BPF_RET | BPF_A, 0), 1756 }, 1757 CLASSIC, 1758 { 0x00, 0x1b, 0x21, 0x3c, 0x9d, 0xf8, 1759 0x90, 0xe2, 0xba, 0x0a, 0x56, 0xb4, 1760 0x08, 0x00, 1761 0x45, 0x00, 0x00, 0x28, 0x00, 0x00, 1762 0x20, 0x00, 0x40, 0x11, 0x00, 0x00, /* IP header */ 1763 0xc0, 0xa8, 0x33, 0x01, 1764 0xc0, 0xa8, 0x33, 0x02, 1765 0xbb, 0xb6, 1766 0xa9, 0xfa, 1767 0x00, 0x14, 0x00, 0x00, 1768 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 1769 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 1770 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 1771 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 1772 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 1773 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 1774 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 1775 0xcc, 0xcc, 0xcc, 0xcc }, 1776 { { 88, 0x001b } } 1777 }, 1778 { 1779 "check: RET X", 1780 .u.insns = { 1781 BPF_STMT(BPF_RET | BPF_X, 0), 1782 }, 1783 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, 1784 { }, 1785 { }, 1786 }, 1787 { 1788 "check: LDX + RET X", 1789 .u.insns = { 1790 BPF_STMT(BPF_LDX | BPF_IMM, 42), 1791 BPF_STMT(BPF_RET | BPF_X, 0), 1792 }, 1793 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, 1794 { }, 1795 { }, 1796 }, 1797 { /* Mainly checking JIT here. */ 1798 "M[]: alt STX + LDX", 1799 .u.insns = { 1800 BPF_STMT(BPF_LDX | BPF_IMM, 100), 1801 BPF_STMT(BPF_STX, 0), 1802 BPF_STMT(BPF_LDX | BPF_MEM, 0), 1803 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1804 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1805 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1806 BPF_STMT(BPF_STX, 1), 1807 BPF_STMT(BPF_LDX | BPF_MEM, 1), 1808 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1809 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1810 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1811 BPF_STMT(BPF_STX, 2), 1812 BPF_STMT(BPF_LDX | BPF_MEM, 2), 1813 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1814 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1815 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1816 BPF_STMT(BPF_STX, 3), 1817 BPF_STMT(BPF_LDX | BPF_MEM, 3), 1818 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1819 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1820 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1821 BPF_STMT(BPF_STX, 4), 1822 BPF_STMT(BPF_LDX | BPF_MEM, 4), 1823 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1824 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1825 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1826 BPF_STMT(BPF_STX, 5), 1827 BPF_STMT(BPF_LDX | BPF_MEM, 5), 1828 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1829 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1830 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1831 BPF_STMT(BPF_STX, 6), 1832 BPF_STMT(BPF_LDX | BPF_MEM, 6), 1833 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1834 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1835 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1836 BPF_STMT(BPF_STX, 7), 1837 BPF_STMT(BPF_LDX | BPF_MEM, 7), 1838 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1839 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1840 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1841 BPF_STMT(BPF_STX, 8), 1842 BPF_STMT(BPF_LDX | BPF_MEM, 8), 1843 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1844 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1845 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1846 BPF_STMT(BPF_STX, 9), 1847 BPF_STMT(BPF_LDX | BPF_MEM, 9), 1848 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1849 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1850 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1851 BPF_STMT(BPF_STX, 10), 1852 BPF_STMT(BPF_LDX | BPF_MEM, 10), 1853 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1854 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1855 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1856 BPF_STMT(BPF_STX, 11), 1857 BPF_STMT(BPF_LDX | BPF_MEM, 11), 1858 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1859 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1860 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1861 BPF_STMT(BPF_STX, 12), 1862 BPF_STMT(BPF_LDX | BPF_MEM, 12), 1863 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1864 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1865 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1866 BPF_STMT(BPF_STX, 13), 1867 BPF_STMT(BPF_LDX | BPF_MEM, 13), 1868 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1869 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1870 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1871 BPF_STMT(BPF_STX, 14), 1872 BPF_STMT(BPF_LDX | BPF_MEM, 14), 1873 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1874 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1875 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1876 BPF_STMT(BPF_STX, 15), 1877 BPF_STMT(BPF_LDX | BPF_MEM, 15), 1878 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1879 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1), 1880 BPF_STMT(BPF_MISC | BPF_TAX, 0), 1881 BPF_STMT(BPF_RET | BPF_A, 0), 1882 }, 1883 CLASSIC | FLAG_NO_DATA, 1884 { }, 1885 { { 0, 116 } }, 1886 }, 1887 { /* Mainly checking JIT here. */ 1888 "M[]: full STX + full LDX", 1889 .u.insns = { 1890 BPF_STMT(BPF_LDX | BPF_IMM, 0xbadfeedb), 1891 BPF_STMT(BPF_STX, 0), 1892 BPF_STMT(BPF_LDX | BPF_IMM, 0xecabedae), 1893 BPF_STMT(BPF_STX, 1), 1894 BPF_STMT(BPF_LDX | BPF_IMM, 0xafccfeaf), 1895 BPF_STMT(BPF_STX, 2), 1896 BPF_STMT(BPF_LDX | BPF_IMM, 0xbffdcedc), 1897 BPF_STMT(BPF_STX, 3), 1898 BPF_STMT(BPF_LDX | BPF_IMM, 0xfbbbdccb), 1899 BPF_STMT(BPF_STX, 4), 1900 BPF_STMT(BPF_LDX | BPF_IMM, 0xfbabcbda), 1901 BPF_STMT(BPF_STX, 5), 1902 BPF_STMT(BPF_LDX | BPF_IMM, 0xaedecbdb), 1903 BPF_STMT(BPF_STX, 6), 1904 BPF_STMT(BPF_LDX | BPF_IMM, 0xadebbade), 1905 BPF_STMT(BPF_STX, 7), 1906 BPF_STMT(BPF_LDX | BPF_IMM, 0xfcfcfaec), 1907 BPF_STMT(BPF_STX, 8), 1908 BPF_STMT(BPF_LDX | BPF_IMM, 0xbcdddbdc), 1909 BPF_STMT(BPF_STX, 9), 1910 BPF_STMT(BPF_LDX | BPF_IMM, 0xfeefdfac), 1911 BPF_STMT(BPF_STX, 10), 1912 BPF_STMT(BPF_LDX | BPF_IMM, 0xcddcdeea), 1913 BPF_STMT(BPF_STX, 11), 1914 BPF_STMT(BPF_LDX | BPF_IMM, 0xaccfaebb), 1915 BPF_STMT(BPF_STX, 12), 1916 BPF_STMT(BPF_LDX | BPF_IMM, 0xbdcccdcf), 1917 BPF_STMT(BPF_STX, 13), 1918 BPF_STMT(BPF_LDX | BPF_IMM, 0xaaedecde), 1919 BPF_STMT(BPF_STX, 14), 1920 BPF_STMT(BPF_LDX | BPF_IMM, 0xfaeacdad), 1921 BPF_STMT(BPF_STX, 15), 1922 BPF_STMT(BPF_LDX | BPF_MEM, 0), 1923 BPF_STMT(BPF_MISC | BPF_TXA, 0), 1924 BPF_STMT(BPF_LDX | BPF_MEM, 1), 1925 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1926 BPF_STMT(BPF_LDX | BPF_MEM, 2), 1927 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1928 BPF_STMT(BPF_LDX | BPF_MEM, 3), 1929 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1930 BPF_STMT(BPF_LDX | BPF_MEM, 4), 1931 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1932 BPF_STMT(BPF_LDX | BPF_MEM, 5), 1933 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1934 BPF_STMT(BPF_LDX | BPF_MEM, 6), 1935 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1936 BPF_STMT(BPF_LDX | BPF_MEM, 7), 1937 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1938 BPF_STMT(BPF_LDX | BPF_MEM, 8), 1939 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1940 BPF_STMT(BPF_LDX | BPF_MEM, 9), 1941 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1942 BPF_STMT(BPF_LDX | BPF_MEM, 10), 1943 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1944 BPF_STMT(BPF_LDX | BPF_MEM, 11), 1945 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1946 BPF_STMT(BPF_LDX | BPF_MEM, 12), 1947 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1948 BPF_STMT(BPF_LDX | BPF_MEM, 13), 1949 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1950 BPF_STMT(BPF_LDX | BPF_MEM, 14), 1951 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1952 BPF_STMT(BPF_LDX | BPF_MEM, 15), 1953 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), 1954 BPF_STMT(BPF_RET | BPF_A, 0), 1955 }, 1956 CLASSIC | FLAG_NO_DATA, 1957 { }, 1958 { { 0, 0x2a5a5e5 } }, 1959 }, 1960 { 1961 "check: SKF_AD_MAX", 1962 .u.insns = { 1963 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 1964 SKF_AD_OFF + SKF_AD_MAX), 1965 BPF_STMT(BPF_RET | BPF_A, 0), 1966 }, 1967 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, 1968 { }, 1969 { }, 1970 }, 1971 { /* Passes checker but fails during runtime. */ 1972 "LD [SKF_AD_OFF-1]", 1973 .u.insns = { 1974 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 1975 SKF_AD_OFF - 1), 1976 BPF_STMT(BPF_RET | BPF_K, 1), 1977 }, 1978 CLASSIC, 1979 { }, 1980 { { 1, 0 } }, 1981 }, 1982 { 1983 "load 64-bit immediate", 1984 .u.insns_int = { 1985 BPF_LD_IMM64(R1, 0x567800001234LL), 1986 BPF_MOV64_REG(R2, R1), 1987 BPF_MOV64_REG(R3, R2), 1988 BPF_ALU64_IMM(BPF_RSH, R2, 32), 1989 BPF_ALU64_IMM(BPF_LSH, R3, 32), 1990 BPF_ALU64_IMM(BPF_RSH, R3, 32), 1991 BPF_ALU64_IMM(BPF_MOV, R0, 0), 1992 BPF_JMP_IMM(BPF_JEQ, R2, 0x5678, 1), 1993 BPF_EXIT_INSN(), 1994 BPF_JMP_IMM(BPF_JEQ, R3, 0x1234, 1), 1995 BPF_EXIT_INSN(), 1996 BPF_LD_IMM64(R0, 0x1ffffffffLL), 1997 BPF_ALU64_IMM(BPF_RSH, R0, 32), /* R0 = 1 */ 1998 BPF_EXIT_INSN(), 1999 }, 2000 INTERNAL, 2001 { }, 2002 { { 0, 1 } } 2003 }, 2004 { 2005 "nmap reduced", 2006 .u.insns_int = { 2007 BPF_MOV64_REG(R6, R1), 2008 BPF_LD_ABS(BPF_H, 12), 2009 BPF_JMP_IMM(BPF_JNE, R0, 0x806, 28), 2010 BPF_LD_ABS(BPF_H, 12), 2011 BPF_JMP_IMM(BPF_JNE, R0, 0x806, 26), 2012 BPF_MOV32_IMM(R0, 18), 2013 BPF_STX_MEM(BPF_W, R10, R0, -64), 2014 BPF_LDX_MEM(BPF_W, R7, R10, -64), 2015 BPF_LD_IND(BPF_W, R7, 14), 2016 BPF_STX_MEM(BPF_W, R10, R0, -60), 2017 BPF_MOV32_IMM(R0, 280971478), 2018 BPF_STX_MEM(BPF_W, R10, R0, -56), 2019 BPF_LDX_MEM(BPF_W, R7, R10, -56), 2020 BPF_LDX_MEM(BPF_W, R0, R10, -60), 2021 BPF_ALU32_REG(BPF_SUB, R0, R7), 2022 BPF_JMP_IMM(BPF_JNE, R0, 0, 15), 2023 BPF_LD_ABS(BPF_H, 12), 2024 BPF_JMP_IMM(BPF_JNE, R0, 0x806, 13), 2025 BPF_MOV32_IMM(R0, 22), 2026 BPF_STX_MEM(BPF_W, R10, R0, -56), 2027 BPF_LDX_MEM(BPF_W, R7, R10, -56), 2028 BPF_LD_IND(BPF_H, R7, 14), 2029 BPF_STX_MEM(BPF_W, R10, R0, -52), 2030 BPF_MOV32_IMM(R0, 17366), 2031 BPF_STX_MEM(BPF_W, R10, R0, -48), 2032 BPF_LDX_MEM(BPF_W, R7, R10, -48), 2033 BPF_LDX_MEM(BPF_W, R0, R10, -52), 2034 BPF_ALU32_REG(BPF_SUB, R0, R7), 2035 BPF_JMP_IMM(BPF_JNE, R0, 0, 2), 2036 BPF_MOV32_IMM(R0, 256), 2037 BPF_EXIT_INSN(), 2038 BPF_MOV32_IMM(R0, 0), 2039 BPF_EXIT_INSN(), 2040 }, 2041 INTERNAL, 2042 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x06, 0, 0, 2043 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2044 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6}, 2045 { { 38, 256 } } 2046 }, 2047 /* BPF_ALU | BPF_MOV | BPF_X */ 2048 { 2049 "ALU_MOV_X: dst = 2", 2050 .u.insns_int = { 2051 BPF_ALU32_IMM(BPF_MOV, R1, 2), 2052 BPF_ALU32_REG(BPF_MOV, R0, R1), 2053 BPF_EXIT_INSN(), 2054 }, 2055 INTERNAL, 2056 { }, 2057 { { 0, 2 } }, 2058 }, 2059 { 2060 "ALU_MOV_X: dst = 4294967295", 2061 .u.insns_int = { 2062 BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U), 2063 BPF_ALU32_REG(BPF_MOV, R0, R1), 2064 BPF_EXIT_INSN(), 2065 }, 2066 INTERNAL, 2067 { }, 2068 { { 0, 4294967295U } }, 2069 }, 2070 { 2071 "ALU64_MOV_X: dst = 2", 2072 .u.insns_int = { 2073 BPF_ALU32_IMM(BPF_MOV, R1, 2), 2074 BPF_ALU64_REG(BPF_MOV, R0, R1), 2075 BPF_EXIT_INSN(), 2076 }, 2077 INTERNAL, 2078 { }, 2079 { { 0, 2 } }, 2080 }, 2081 { 2082 "ALU64_MOV_X: dst = 4294967295", 2083 .u.insns_int = { 2084 BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U), 2085 BPF_ALU64_REG(BPF_MOV, R0, R1), 2086 BPF_EXIT_INSN(), 2087 }, 2088 INTERNAL, 2089 { }, 2090 { { 0, 4294967295U } }, 2091 }, 2092 /* BPF_ALU | BPF_MOV | BPF_K */ 2093 { 2094 "ALU_MOV_K: dst = 2", 2095 .u.insns_int = { 2096 BPF_ALU32_IMM(BPF_MOV, R0, 2), 2097 BPF_EXIT_INSN(), 2098 }, 2099 INTERNAL, 2100 { }, 2101 { { 0, 2 } }, 2102 }, 2103 { 2104 "ALU_MOV_K: dst = 4294967295", 2105 .u.insns_int = { 2106 BPF_ALU32_IMM(BPF_MOV, R0, 4294967295U), 2107 BPF_EXIT_INSN(), 2108 }, 2109 INTERNAL, 2110 { }, 2111 { { 0, 4294967295U } }, 2112 }, 2113 { 2114 "ALU_MOV_K: 0x0000ffffffff0000 = 0x00000000ffffffff", 2115 .u.insns_int = { 2116 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), 2117 BPF_LD_IMM64(R3, 0x00000000ffffffffLL), 2118 BPF_ALU32_IMM(BPF_MOV, R2, 0xffffffff), 2119 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 2120 BPF_MOV32_IMM(R0, 2), 2121 BPF_EXIT_INSN(), 2122 BPF_MOV32_IMM(R0, 1), 2123 BPF_EXIT_INSN(), 2124 }, 2125 INTERNAL, 2126 { }, 2127 { { 0, 0x1 } }, 2128 }, 2129 { 2130 "ALU64_MOV_K: dst = 2", 2131 .u.insns_int = { 2132 BPF_ALU64_IMM(BPF_MOV, R0, 2), 2133 BPF_EXIT_INSN(), 2134 }, 2135 INTERNAL, 2136 { }, 2137 { { 0, 2 } }, 2138 }, 2139 { 2140 "ALU64_MOV_K: dst = 2147483647", 2141 .u.insns_int = { 2142 BPF_ALU64_IMM(BPF_MOV, R0, 2147483647), 2143 BPF_EXIT_INSN(), 2144 }, 2145 INTERNAL, 2146 { }, 2147 { { 0, 2147483647 } }, 2148 }, 2149 { 2150 "ALU64_OR_K: dst = 0x0", 2151 .u.insns_int = { 2152 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), 2153 BPF_LD_IMM64(R3, 0x0), 2154 BPF_ALU64_IMM(BPF_MOV, R2, 0x0), 2155 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 2156 BPF_MOV32_IMM(R0, 2), 2157 BPF_EXIT_INSN(), 2158 BPF_MOV32_IMM(R0, 1), 2159 BPF_EXIT_INSN(), 2160 }, 2161 INTERNAL, 2162 { }, 2163 { { 0, 0x1 } }, 2164 }, 2165 { 2166 "ALU64_MOV_K: dst = -1", 2167 .u.insns_int = { 2168 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), 2169 BPF_LD_IMM64(R3, 0xffffffffffffffffLL), 2170 BPF_ALU64_IMM(BPF_MOV, R2, 0xffffffff), 2171 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 2172 BPF_MOV32_IMM(R0, 2), 2173 BPF_EXIT_INSN(), 2174 BPF_MOV32_IMM(R0, 1), 2175 BPF_EXIT_INSN(), 2176 }, 2177 INTERNAL, 2178 { }, 2179 { { 0, 0x1 } }, 2180 }, 2181 /* BPF_ALU | BPF_ADD | BPF_X */ 2182 { 2183 "ALU_ADD_X: 1 + 2 = 3", 2184 .u.insns_int = { 2185 BPF_LD_IMM64(R0, 1), 2186 BPF_ALU32_IMM(BPF_MOV, R1, 2), 2187 BPF_ALU32_REG(BPF_ADD, R0, R1), 2188 BPF_EXIT_INSN(), 2189 }, 2190 INTERNAL, 2191 { }, 2192 { { 0, 3 } }, 2193 }, 2194 { 2195 "ALU_ADD_X: 1 + 4294967294 = 4294967295", 2196 .u.insns_int = { 2197 BPF_LD_IMM64(R0, 1), 2198 BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), 2199 BPF_ALU32_REG(BPF_ADD, R0, R1), 2200 BPF_EXIT_INSN(), 2201 }, 2202 INTERNAL, 2203 { }, 2204 { { 0, 4294967295U } }, 2205 }, 2206 { 2207 "ALU64_ADD_X: 1 + 2 = 3", 2208 .u.insns_int = { 2209 BPF_LD_IMM64(R0, 1), 2210 BPF_ALU32_IMM(BPF_MOV, R1, 2), 2211 BPF_ALU64_REG(BPF_ADD, R0, R1), 2212 BPF_EXIT_INSN(), 2213 }, 2214 INTERNAL, 2215 { }, 2216 { { 0, 3 } }, 2217 }, 2218 { 2219 "ALU64_ADD_X: 1 + 4294967294 = 4294967295", 2220 .u.insns_int = { 2221 BPF_LD_IMM64(R0, 1), 2222 BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), 2223 BPF_ALU64_REG(BPF_ADD, R0, R1), 2224 BPF_EXIT_INSN(), 2225 }, 2226 INTERNAL, 2227 { }, 2228 { { 0, 4294967295U } }, 2229 }, 2230 /* BPF_ALU | BPF_ADD | BPF_K */ 2231 { 2232 "ALU_ADD_K: 1 + 2 = 3", 2233 .u.insns_int = { 2234 BPF_LD_IMM64(R0, 1), 2235 BPF_ALU32_IMM(BPF_ADD, R0, 2), 2236 BPF_EXIT_INSN(), 2237 }, 2238 INTERNAL, 2239 { }, 2240 { { 0, 3 } }, 2241 }, 2242 { 2243 "ALU_ADD_K: 3 + 0 = 3", 2244 .u.insns_int = { 2245 BPF_LD_IMM64(R0, 3), 2246 BPF_ALU32_IMM(BPF_ADD, R0, 0), 2247 BPF_EXIT_INSN(), 2248 }, 2249 INTERNAL, 2250 { }, 2251 { { 0, 3 } }, 2252 }, 2253 { 2254 "ALU_ADD_K: 1 + 4294967294 = 4294967295", 2255 .u.insns_int = { 2256 BPF_LD_IMM64(R0, 1), 2257 BPF_ALU32_IMM(BPF_ADD, R0, 4294967294U), 2258 BPF_EXIT_INSN(), 2259 }, 2260 INTERNAL, 2261 { }, 2262 { { 0, 4294967295U } }, 2263 }, 2264 { 2265 "ALU_ADD_K: 0 + (-1) = 0x00000000ffffffff", 2266 .u.insns_int = { 2267 BPF_LD_IMM64(R2, 0x0), 2268 BPF_LD_IMM64(R3, 0x00000000ffffffff), 2269 BPF_ALU32_IMM(BPF_ADD, R2, 0xffffffff), 2270 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 2271 BPF_MOV32_IMM(R0, 2), 2272 BPF_EXIT_INSN(), 2273 BPF_MOV32_IMM(R0, 1), 2274 BPF_EXIT_INSN(), 2275 }, 2276 INTERNAL, 2277 { }, 2278 { { 0, 0x1 } }, 2279 }, 2280 { 2281 "ALU64_ADD_K: 1 + 2 = 3", 2282 .u.insns_int = { 2283 BPF_LD_IMM64(R0, 1), 2284 BPF_ALU64_IMM(BPF_ADD, R0, 2), 2285 BPF_EXIT_INSN(), 2286 }, 2287 INTERNAL, 2288 { }, 2289 { { 0, 3 } }, 2290 }, 2291 { 2292 "ALU64_ADD_K: 3 + 0 = 3", 2293 .u.insns_int = { 2294 BPF_LD_IMM64(R0, 3), 2295 BPF_ALU64_IMM(BPF_ADD, R0, 0), 2296 BPF_EXIT_INSN(), 2297 }, 2298 INTERNAL, 2299 { }, 2300 { { 0, 3 } }, 2301 }, 2302 { 2303 "ALU64_ADD_K: 1 + 2147483646 = 2147483647", 2304 .u.insns_int = { 2305 BPF_LD_IMM64(R0, 1), 2306 BPF_ALU64_IMM(BPF_ADD, R0, 2147483646), 2307 BPF_EXIT_INSN(), 2308 }, 2309 INTERNAL, 2310 { }, 2311 { { 0, 2147483647 } }, 2312 }, 2313 { 2314 "ALU64_ADD_K: 2147483646 + -2147483647 = -1", 2315 .u.insns_int = { 2316 BPF_LD_IMM64(R0, 2147483646), 2317 BPF_ALU64_IMM(BPF_ADD, R0, -2147483647), 2318 BPF_EXIT_INSN(), 2319 }, 2320 INTERNAL, 2321 { }, 2322 { { 0, -1 } }, 2323 }, 2324 { 2325 "ALU64_ADD_K: 1 + 0 = 1", 2326 .u.insns_int = { 2327 BPF_LD_IMM64(R2, 0x1), 2328 BPF_LD_IMM64(R3, 0x1), 2329 BPF_ALU64_IMM(BPF_ADD, R2, 0x0), 2330 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 2331 BPF_MOV32_IMM(R0, 2), 2332 BPF_EXIT_INSN(), 2333 BPF_MOV32_IMM(R0, 1), 2334 BPF_EXIT_INSN(), 2335 }, 2336 INTERNAL, 2337 { }, 2338 { { 0, 0x1 } }, 2339 }, 2340 { 2341 "ALU64_ADD_K: 0 + (-1) = 0xffffffffffffffff", 2342 .u.insns_int = { 2343 BPF_LD_IMM64(R2, 0x0), 2344 BPF_LD_IMM64(R3, 0xffffffffffffffffLL), 2345 BPF_ALU64_IMM(BPF_ADD, R2, 0xffffffff), 2346 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 2347 BPF_MOV32_IMM(R0, 2), 2348 BPF_EXIT_INSN(), 2349 BPF_MOV32_IMM(R0, 1), 2350 BPF_EXIT_INSN(), 2351 }, 2352 INTERNAL, 2353 { }, 2354 { { 0, 0x1 } }, 2355 }, 2356 /* BPF_ALU | BPF_SUB | BPF_X */ 2357 { 2358 "ALU_SUB_X: 3 - 1 = 2", 2359 .u.insns_int = { 2360 BPF_LD_IMM64(R0, 3), 2361 BPF_ALU32_IMM(BPF_MOV, R1, 1), 2362 BPF_ALU32_REG(BPF_SUB, R0, R1), 2363 BPF_EXIT_INSN(), 2364 }, 2365 INTERNAL, 2366 { }, 2367 { { 0, 2 } }, 2368 }, 2369 { 2370 "ALU_SUB_X: 4294967295 - 4294967294 = 1", 2371 .u.insns_int = { 2372 BPF_LD_IMM64(R0, 4294967295U), 2373 BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), 2374 BPF_ALU32_REG(BPF_SUB, R0, R1), 2375 BPF_EXIT_INSN(), 2376 }, 2377 INTERNAL, 2378 { }, 2379 { { 0, 1 } }, 2380 }, 2381 { 2382 "ALU64_SUB_X: 3 - 1 = 2", 2383 .u.insns_int = { 2384 BPF_LD_IMM64(R0, 3), 2385 BPF_ALU32_IMM(BPF_MOV, R1, 1), 2386 BPF_ALU64_REG(BPF_SUB, R0, R1), 2387 BPF_EXIT_INSN(), 2388 }, 2389 INTERNAL, 2390 { }, 2391 { { 0, 2 } }, 2392 }, 2393 { 2394 "ALU64_SUB_X: 4294967295 - 4294967294 = 1", 2395 .u.insns_int = { 2396 BPF_LD_IMM64(R0, 4294967295U), 2397 BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U), 2398 BPF_ALU64_REG(BPF_SUB, R0, R1), 2399 BPF_EXIT_INSN(), 2400 }, 2401 INTERNAL, 2402 { }, 2403 { { 0, 1 } }, 2404 }, 2405 /* BPF_ALU | BPF_SUB | BPF_K */ 2406 { 2407 "ALU_SUB_K: 3 - 1 = 2", 2408 .u.insns_int = { 2409 BPF_LD_IMM64(R0, 3), 2410 BPF_ALU32_IMM(BPF_SUB, R0, 1), 2411 BPF_EXIT_INSN(), 2412 }, 2413 INTERNAL, 2414 { }, 2415 { { 0, 2 } }, 2416 }, 2417 { 2418 "ALU_SUB_K: 3 - 0 = 3", 2419 .u.insns_int = { 2420 BPF_LD_IMM64(R0, 3), 2421 BPF_ALU32_IMM(BPF_SUB, R0, 0), 2422 BPF_EXIT_INSN(), 2423 }, 2424 INTERNAL, 2425 { }, 2426 { { 0, 3 } }, 2427 }, 2428 { 2429 "ALU_SUB_K: 4294967295 - 4294967294 = 1", 2430 .u.insns_int = { 2431 BPF_LD_IMM64(R0, 4294967295U), 2432 BPF_ALU32_IMM(BPF_SUB, R0, 4294967294U), 2433 BPF_EXIT_INSN(), 2434 }, 2435 INTERNAL, 2436 { }, 2437 { { 0, 1 } }, 2438 }, 2439 { 2440 "ALU64_SUB_K: 3 - 1 = 2", 2441 .u.insns_int = { 2442 BPF_LD_IMM64(R0, 3), 2443 BPF_ALU64_IMM(BPF_SUB, R0, 1), 2444 BPF_EXIT_INSN(), 2445 }, 2446 INTERNAL, 2447 { }, 2448 { { 0, 2 } }, 2449 }, 2450 { 2451 "ALU64_SUB_K: 3 - 0 = 3", 2452 .u.insns_int = { 2453 BPF_LD_IMM64(R0, 3), 2454 BPF_ALU64_IMM(BPF_SUB, R0, 0), 2455 BPF_EXIT_INSN(), 2456 }, 2457 INTERNAL, 2458 { }, 2459 { { 0, 3 } }, 2460 }, 2461 { 2462 "ALU64_SUB_K: 4294967294 - 4294967295 = -1", 2463 .u.insns_int = { 2464 BPF_LD_IMM64(R0, 4294967294U), 2465 BPF_ALU64_IMM(BPF_SUB, R0, 4294967295U), 2466 BPF_EXIT_INSN(), 2467 }, 2468 INTERNAL, 2469 { }, 2470 { { 0, -1 } }, 2471 }, 2472 { 2473 "ALU64_ADD_K: 2147483646 - 2147483647 = -1", 2474 .u.insns_int = { 2475 BPF_LD_IMM64(R0, 2147483646), 2476 BPF_ALU64_IMM(BPF_SUB, R0, 2147483647), 2477 BPF_EXIT_INSN(), 2478 }, 2479 INTERNAL, 2480 { }, 2481 { { 0, -1 } }, 2482 }, 2483 /* BPF_ALU | BPF_MUL | BPF_X */ 2484 { 2485 "ALU_MUL_X: 2 * 3 = 6", 2486 .u.insns_int = { 2487 BPF_LD_IMM64(R0, 2), 2488 BPF_ALU32_IMM(BPF_MOV, R1, 3), 2489 BPF_ALU32_REG(BPF_MUL, R0, R1), 2490 BPF_EXIT_INSN(), 2491 }, 2492 INTERNAL, 2493 { }, 2494 { { 0, 6 } }, 2495 }, 2496 { 2497 "ALU_MUL_X: 2 * 0x7FFFFFF8 = 0xFFFFFFF0", 2498 .u.insns_int = { 2499 BPF_LD_IMM64(R0, 2), 2500 BPF_ALU32_IMM(BPF_MOV, R1, 0x7FFFFFF8), 2501 BPF_ALU32_REG(BPF_MUL, R0, R1), 2502 BPF_EXIT_INSN(), 2503 }, 2504 INTERNAL, 2505 { }, 2506 { { 0, 0xFFFFFFF0 } }, 2507 }, 2508 { 2509 "ALU_MUL_X: -1 * -1 = 1", 2510 .u.insns_int = { 2511 BPF_LD_IMM64(R0, -1), 2512 BPF_ALU32_IMM(BPF_MOV, R1, -1), 2513 BPF_ALU32_REG(BPF_MUL, R0, R1), 2514 BPF_EXIT_INSN(), 2515 }, 2516 INTERNAL, 2517 { }, 2518 { { 0, 1 } }, 2519 }, 2520 { 2521 "ALU64_MUL_X: 2 * 3 = 6", 2522 .u.insns_int = { 2523 BPF_LD_IMM64(R0, 2), 2524 BPF_ALU32_IMM(BPF_MOV, R1, 3), 2525 BPF_ALU64_REG(BPF_MUL, R0, R1), 2526 BPF_EXIT_INSN(), 2527 }, 2528 INTERNAL, 2529 { }, 2530 { { 0, 6 } }, 2531 }, 2532 { 2533 "ALU64_MUL_X: 1 * 2147483647 = 2147483647", 2534 .u.insns_int = { 2535 BPF_LD_IMM64(R0, 1), 2536 BPF_ALU32_IMM(BPF_MOV, R1, 2147483647), 2537 BPF_ALU64_REG(BPF_MUL, R0, R1), 2538 BPF_EXIT_INSN(), 2539 }, 2540 INTERNAL, 2541 { }, 2542 { { 0, 2147483647 } }, 2543 }, 2544 /* BPF_ALU | BPF_MUL | BPF_K */ 2545 { 2546 "ALU_MUL_K: 2 * 3 = 6", 2547 .u.insns_int = { 2548 BPF_LD_IMM64(R0, 2), 2549 BPF_ALU32_IMM(BPF_MUL, R0, 3), 2550 BPF_EXIT_INSN(), 2551 }, 2552 INTERNAL, 2553 { }, 2554 { { 0, 6 } }, 2555 }, 2556 { 2557 "ALU_MUL_K: 3 * 1 = 3", 2558 .u.insns_int = { 2559 BPF_LD_IMM64(R0, 3), 2560 BPF_ALU32_IMM(BPF_MUL, R0, 1), 2561 BPF_EXIT_INSN(), 2562 }, 2563 INTERNAL, 2564 { }, 2565 { { 0, 3 } }, 2566 }, 2567 { 2568 "ALU_MUL_K: 2 * 0x7FFFFFF8 = 0xFFFFFFF0", 2569 .u.insns_int = { 2570 BPF_LD_IMM64(R0, 2), 2571 BPF_ALU32_IMM(BPF_MUL, R0, 0x7FFFFFF8), 2572 BPF_EXIT_INSN(), 2573 }, 2574 INTERNAL, 2575 { }, 2576 { { 0, 0xFFFFFFF0 } }, 2577 }, 2578 { 2579 "ALU_MUL_K: 1 * (-1) = 0x00000000ffffffff", 2580 .u.insns_int = { 2581 BPF_LD_IMM64(R2, 0x1), 2582 BPF_LD_IMM64(R3, 0x00000000ffffffff), 2583 BPF_ALU32_IMM(BPF_MUL, R2, 0xffffffff), 2584 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 2585 BPF_MOV32_IMM(R0, 2), 2586 BPF_EXIT_INSN(), 2587 BPF_MOV32_IMM(R0, 1), 2588 BPF_EXIT_INSN(), 2589 }, 2590 INTERNAL, 2591 { }, 2592 { { 0, 0x1 } }, 2593 }, 2594 { 2595 "ALU64_MUL_K: 2 * 3 = 6", 2596 .u.insns_int = { 2597 BPF_LD_IMM64(R0, 2), 2598 BPF_ALU64_IMM(BPF_MUL, R0, 3), 2599 BPF_EXIT_INSN(), 2600 }, 2601 INTERNAL, 2602 { }, 2603 { { 0, 6 } }, 2604 }, 2605 { 2606 "ALU64_MUL_K: 3 * 1 = 3", 2607 .u.insns_int = { 2608 BPF_LD_IMM64(R0, 3), 2609 BPF_ALU64_IMM(BPF_MUL, R0, 1), 2610 BPF_EXIT_INSN(), 2611 }, 2612 INTERNAL, 2613 { }, 2614 { { 0, 3 } }, 2615 }, 2616 { 2617 "ALU64_MUL_K: 1 * 2147483647 = 2147483647", 2618 .u.insns_int = { 2619 BPF_LD_IMM64(R0, 1), 2620 BPF_ALU64_IMM(BPF_MUL, R0, 2147483647), 2621 BPF_EXIT_INSN(), 2622 }, 2623 INTERNAL, 2624 { }, 2625 { { 0, 2147483647 } }, 2626 }, 2627 { 2628 "ALU64_MUL_K: 1 * -2147483647 = -2147483647", 2629 .u.insns_int = { 2630 BPF_LD_IMM64(R0, 1), 2631 BPF_ALU64_IMM(BPF_MUL, R0, -2147483647), 2632 BPF_EXIT_INSN(), 2633 }, 2634 INTERNAL, 2635 { }, 2636 { { 0, -2147483647 } }, 2637 }, 2638 { 2639 "ALU64_MUL_K: 1 * (-1) = 0xffffffffffffffff", 2640 .u.insns_int = { 2641 BPF_LD_IMM64(R2, 0x1), 2642 BPF_LD_IMM64(R3, 0xffffffffffffffffLL), 2643 BPF_ALU64_IMM(BPF_MUL, R2, 0xffffffff), 2644 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 2645 BPF_MOV32_IMM(R0, 2), 2646 BPF_EXIT_INSN(), 2647 BPF_MOV32_IMM(R0, 1), 2648 BPF_EXIT_INSN(), 2649 }, 2650 INTERNAL, 2651 { }, 2652 { { 0, 0x1 } }, 2653 }, 2654 /* BPF_ALU | BPF_DIV | BPF_X */ 2655 { 2656 "ALU_DIV_X: 6 / 2 = 3", 2657 .u.insns_int = { 2658 BPF_LD_IMM64(R0, 6), 2659 BPF_ALU32_IMM(BPF_MOV, R1, 2), 2660 BPF_ALU32_REG(BPF_DIV, R0, R1), 2661 BPF_EXIT_INSN(), 2662 }, 2663 INTERNAL, 2664 { }, 2665 { { 0, 3 } }, 2666 }, 2667 { 2668 "ALU_DIV_X: 4294967295 / 4294967295 = 1", 2669 .u.insns_int = { 2670 BPF_LD_IMM64(R0, 4294967295U), 2671 BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U), 2672 BPF_ALU32_REG(BPF_DIV, R0, R1), 2673 BPF_EXIT_INSN(), 2674 }, 2675 INTERNAL, 2676 { }, 2677 { { 0, 1 } }, 2678 }, 2679 { 2680 "ALU64_DIV_X: 6 / 2 = 3", 2681 .u.insns_int = { 2682 BPF_LD_IMM64(R0, 6), 2683 BPF_ALU32_IMM(BPF_MOV, R1, 2), 2684 BPF_ALU64_REG(BPF_DIV, R0, R1), 2685 BPF_EXIT_INSN(), 2686 }, 2687 INTERNAL, 2688 { }, 2689 { { 0, 3 } }, 2690 }, 2691 { 2692 "ALU64_DIV_X: 2147483647 / 2147483647 = 1", 2693 .u.insns_int = { 2694 BPF_LD_IMM64(R0, 2147483647), 2695 BPF_ALU32_IMM(BPF_MOV, R1, 2147483647), 2696 BPF_ALU64_REG(BPF_DIV, R0, R1), 2697 BPF_EXIT_INSN(), 2698 }, 2699 INTERNAL, 2700 { }, 2701 { { 0, 1 } }, 2702 }, 2703 { 2704 "ALU64_DIV_X: 0xffffffffffffffff / (-1) = 0x0000000000000001", 2705 .u.insns_int = { 2706 BPF_LD_IMM64(R2, 0xffffffffffffffffLL), 2707 BPF_LD_IMM64(R4, 0xffffffffffffffffLL), 2708 BPF_LD_IMM64(R3, 0x0000000000000001LL), 2709 BPF_ALU64_REG(BPF_DIV, R2, R4), 2710 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 2711 BPF_MOV32_IMM(R0, 2), 2712 BPF_EXIT_INSN(), 2713 BPF_MOV32_IMM(R0, 1), 2714 BPF_EXIT_INSN(), 2715 }, 2716 INTERNAL, 2717 { }, 2718 { { 0, 0x1 } }, 2719 }, 2720 /* BPF_ALU | BPF_DIV | BPF_K */ 2721 { 2722 "ALU_DIV_K: 6 / 2 = 3", 2723 .u.insns_int = { 2724 BPF_LD_IMM64(R0, 6), 2725 BPF_ALU32_IMM(BPF_DIV, R0, 2), 2726 BPF_EXIT_INSN(), 2727 }, 2728 INTERNAL, 2729 { }, 2730 { { 0, 3 } }, 2731 }, 2732 { 2733 "ALU_DIV_K: 3 / 1 = 3", 2734 .u.insns_int = { 2735 BPF_LD_IMM64(R0, 3), 2736 BPF_ALU32_IMM(BPF_DIV, R0, 1), 2737 BPF_EXIT_INSN(), 2738 }, 2739 INTERNAL, 2740 { }, 2741 { { 0, 3 } }, 2742 }, 2743 { 2744 "ALU_DIV_K: 4294967295 / 4294967295 = 1", 2745 .u.insns_int = { 2746 BPF_LD_IMM64(R0, 4294967295U), 2747 BPF_ALU32_IMM(BPF_DIV, R0, 4294967295U), 2748 BPF_EXIT_INSN(), 2749 }, 2750 INTERNAL, 2751 { }, 2752 { { 0, 1 } }, 2753 }, 2754 { 2755 "ALU_DIV_K: 0xffffffffffffffff / (-1) = 0x1", 2756 .u.insns_int = { 2757 BPF_LD_IMM64(R2, 0xffffffffffffffffLL), 2758 BPF_LD_IMM64(R3, 0x1UL), 2759 BPF_ALU32_IMM(BPF_DIV, R2, 0xffffffff), 2760 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 2761 BPF_MOV32_IMM(R0, 2), 2762 BPF_EXIT_INSN(), 2763 BPF_MOV32_IMM(R0, 1), 2764 BPF_EXIT_INSN(), 2765 }, 2766 INTERNAL, 2767 { }, 2768 { { 0, 0x1 } }, 2769 }, 2770 { 2771 "ALU64_DIV_K: 6 / 2 = 3", 2772 .u.insns_int = { 2773 BPF_LD_IMM64(R0, 6), 2774 BPF_ALU64_IMM(BPF_DIV, R0, 2), 2775 BPF_EXIT_INSN(), 2776 }, 2777 INTERNAL, 2778 { }, 2779 { { 0, 3 } }, 2780 }, 2781 { 2782 "ALU64_DIV_K: 3 / 1 = 3", 2783 .u.insns_int = { 2784 BPF_LD_IMM64(R0, 3), 2785 BPF_ALU64_IMM(BPF_DIV, R0, 1), 2786 BPF_EXIT_INSN(), 2787 }, 2788 INTERNAL, 2789 { }, 2790 { { 0, 3 } }, 2791 }, 2792 { 2793 "ALU64_DIV_K: 2147483647 / 2147483647 = 1", 2794 .u.insns_int = { 2795 BPF_LD_IMM64(R0, 2147483647), 2796 BPF_ALU64_IMM(BPF_DIV, R0, 2147483647), 2797 BPF_EXIT_INSN(), 2798 }, 2799 INTERNAL, 2800 { }, 2801 { { 0, 1 } }, 2802 }, 2803 { 2804 "ALU64_DIV_K: 0xffffffffffffffff / (-1) = 0x0000000000000001", 2805 .u.insns_int = { 2806 BPF_LD_IMM64(R2, 0xffffffffffffffffLL), 2807 BPF_LD_IMM64(R3, 0x0000000000000001LL), 2808 BPF_ALU64_IMM(BPF_DIV, R2, 0xffffffff), 2809 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 2810 BPF_MOV32_IMM(R0, 2), 2811 BPF_EXIT_INSN(), 2812 BPF_MOV32_IMM(R0, 1), 2813 BPF_EXIT_INSN(), 2814 }, 2815 INTERNAL, 2816 { }, 2817 { { 0, 0x1 } }, 2818 }, 2819 /* BPF_ALU | BPF_MOD | BPF_X */ 2820 { 2821 "ALU_MOD_X: 3 % 2 = 1", 2822 .u.insns_int = { 2823 BPF_LD_IMM64(R0, 3), 2824 BPF_ALU32_IMM(BPF_MOV, R1, 2), 2825 BPF_ALU32_REG(BPF_MOD, R0, R1), 2826 BPF_EXIT_INSN(), 2827 }, 2828 INTERNAL, 2829 { }, 2830 { { 0, 1 } }, 2831 }, 2832 { 2833 "ALU_MOD_X: 4294967295 % 4294967293 = 2", 2834 .u.insns_int = { 2835 BPF_LD_IMM64(R0, 4294967295U), 2836 BPF_ALU32_IMM(BPF_MOV, R1, 4294967293U), 2837 BPF_ALU32_REG(BPF_MOD, R0, R1), 2838 BPF_EXIT_INSN(), 2839 }, 2840 INTERNAL, 2841 { }, 2842 { { 0, 2 } }, 2843 }, 2844 { 2845 "ALU64_MOD_X: 3 % 2 = 1", 2846 .u.insns_int = { 2847 BPF_LD_IMM64(R0, 3), 2848 BPF_ALU32_IMM(BPF_MOV, R1, 2), 2849 BPF_ALU64_REG(BPF_MOD, R0, R1), 2850 BPF_EXIT_INSN(), 2851 }, 2852 INTERNAL, 2853 { }, 2854 { { 0, 1 } }, 2855 }, 2856 { 2857 "ALU64_MOD_X: 2147483647 % 2147483645 = 2", 2858 .u.insns_int = { 2859 BPF_LD_IMM64(R0, 2147483647), 2860 BPF_ALU32_IMM(BPF_MOV, R1, 2147483645), 2861 BPF_ALU64_REG(BPF_MOD, R0, R1), 2862 BPF_EXIT_INSN(), 2863 }, 2864 INTERNAL, 2865 { }, 2866 { { 0, 2 } }, 2867 }, 2868 /* BPF_ALU | BPF_MOD | BPF_K */ 2869 { 2870 "ALU_MOD_K: 3 % 2 = 1", 2871 .u.insns_int = { 2872 BPF_LD_IMM64(R0, 3), 2873 BPF_ALU32_IMM(BPF_MOD, R0, 2), 2874 BPF_EXIT_INSN(), 2875 }, 2876 INTERNAL, 2877 { }, 2878 { { 0, 1 } }, 2879 }, 2880 { 2881 "ALU_MOD_K: 3 % 1 = 0", 2882 .u.insns_int = { 2883 BPF_LD_IMM64(R0, 3), 2884 BPF_ALU32_IMM(BPF_MOD, R0, 1), 2885 BPF_EXIT_INSN(), 2886 }, 2887 INTERNAL, 2888 { }, 2889 { { 0, 0 } }, 2890 }, 2891 { 2892 "ALU_MOD_K: 4294967295 % 4294967293 = 2", 2893 .u.insns_int = { 2894 BPF_LD_IMM64(R0, 4294967295U), 2895 BPF_ALU32_IMM(BPF_MOD, R0, 4294967293U), 2896 BPF_EXIT_INSN(), 2897 }, 2898 INTERNAL, 2899 { }, 2900 { { 0, 2 } }, 2901 }, 2902 { 2903 "ALU64_MOD_K: 3 % 2 = 1", 2904 .u.insns_int = { 2905 BPF_LD_IMM64(R0, 3), 2906 BPF_ALU64_IMM(BPF_MOD, R0, 2), 2907 BPF_EXIT_INSN(), 2908 }, 2909 INTERNAL, 2910 { }, 2911 { { 0, 1 } }, 2912 }, 2913 { 2914 "ALU64_MOD_K: 3 % 1 = 0", 2915 .u.insns_int = { 2916 BPF_LD_IMM64(R0, 3), 2917 BPF_ALU64_IMM(BPF_MOD, R0, 1), 2918 BPF_EXIT_INSN(), 2919 }, 2920 INTERNAL, 2921 { }, 2922 { { 0, 0 } }, 2923 }, 2924 { 2925 "ALU64_MOD_K: 2147483647 % 2147483645 = 2", 2926 .u.insns_int = { 2927 BPF_LD_IMM64(R0, 2147483647), 2928 BPF_ALU64_IMM(BPF_MOD, R0, 2147483645), 2929 BPF_EXIT_INSN(), 2930 }, 2931 INTERNAL, 2932 { }, 2933 { { 0, 2 } }, 2934 }, 2935 /* BPF_ALU | BPF_AND | BPF_X */ 2936 { 2937 "ALU_AND_X: 3 & 2 = 2", 2938 .u.insns_int = { 2939 BPF_LD_IMM64(R0, 3), 2940 BPF_ALU32_IMM(BPF_MOV, R1, 2), 2941 BPF_ALU32_REG(BPF_AND, R0, R1), 2942 BPF_EXIT_INSN(), 2943 }, 2944 INTERNAL, 2945 { }, 2946 { { 0, 2 } }, 2947 }, 2948 { 2949 "ALU_AND_X: 0xffffffff & 0xffffffff = 0xffffffff", 2950 .u.insns_int = { 2951 BPF_LD_IMM64(R0, 0xffffffff), 2952 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), 2953 BPF_ALU32_REG(BPF_AND, R0, R1), 2954 BPF_EXIT_INSN(), 2955 }, 2956 INTERNAL, 2957 { }, 2958 { { 0, 0xffffffff } }, 2959 }, 2960 { 2961 "ALU64_AND_X: 3 & 2 = 2", 2962 .u.insns_int = { 2963 BPF_LD_IMM64(R0, 3), 2964 BPF_ALU32_IMM(BPF_MOV, R1, 2), 2965 BPF_ALU64_REG(BPF_AND, R0, R1), 2966 BPF_EXIT_INSN(), 2967 }, 2968 INTERNAL, 2969 { }, 2970 { { 0, 2 } }, 2971 }, 2972 { 2973 "ALU64_AND_X: 0xffffffff & 0xffffffff = 0xffffffff", 2974 .u.insns_int = { 2975 BPF_LD_IMM64(R0, 0xffffffff), 2976 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), 2977 BPF_ALU64_REG(BPF_AND, R0, R1), 2978 BPF_EXIT_INSN(), 2979 }, 2980 INTERNAL, 2981 { }, 2982 { { 0, 0xffffffff } }, 2983 }, 2984 /* BPF_ALU | BPF_AND | BPF_K */ 2985 { 2986 "ALU_AND_K: 3 & 2 = 2", 2987 .u.insns_int = { 2988 BPF_LD_IMM64(R0, 3), 2989 BPF_ALU32_IMM(BPF_AND, R0, 2), 2990 BPF_EXIT_INSN(), 2991 }, 2992 INTERNAL, 2993 { }, 2994 { { 0, 2 } }, 2995 }, 2996 { 2997 "ALU_AND_K: 0xffffffff & 0xffffffff = 0xffffffff", 2998 .u.insns_int = { 2999 BPF_LD_IMM64(R0, 0xffffffff), 3000 BPF_ALU32_IMM(BPF_AND, R0, 0xffffffff), 3001 BPF_EXIT_INSN(), 3002 }, 3003 INTERNAL, 3004 { }, 3005 { { 0, 0xffffffff } }, 3006 }, 3007 { 3008 "ALU64_AND_K: 3 & 2 = 2", 3009 .u.insns_int = { 3010 BPF_LD_IMM64(R0, 3), 3011 BPF_ALU64_IMM(BPF_AND, R0, 2), 3012 BPF_EXIT_INSN(), 3013 }, 3014 INTERNAL, 3015 { }, 3016 { { 0, 2 } }, 3017 }, 3018 { 3019 "ALU64_AND_K: 0xffffffff & 0xffffffff = 0xffffffff", 3020 .u.insns_int = { 3021 BPF_LD_IMM64(R0, 0xffffffff), 3022 BPF_ALU64_IMM(BPF_AND, R0, 0xffffffff), 3023 BPF_EXIT_INSN(), 3024 }, 3025 INTERNAL, 3026 { }, 3027 { { 0, 0xffffffff } }, 3028 }, 3029 { 3030 "ALU64_AND_K: 0x0000ffffffff0000 & 0x0 = 0x0000ffff00000000", 3031 .u.insns_int = { 3032 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), 3033 BPF_LD_IMM64(R3, 0x0000000000000000LL), 3034 BPF_ALU64_IMM(BPF_AND, R2, 0x0), 3035 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 3036 BPF_MOV32_IMM(R0, 2), 3037 BPF_EXIT_INSN(), 3038 BPF_MOV32_IMM(R0, 1), 3039 BPF_EXIT_INSN(), 3040 }, 3041 INTERNAL, 3042 { }, 3043 { { 0, 0x1 } }, 3044 }, 3045 { 3046 "ALU64_AND_K: 0x0000ffffffff0000 & -1 = 0x0000ffffffffffff", 3047 .u.insns_int = { 3048 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), 3049 BPF_LD_IMM64(R3, 0x0000ffffffff0000LL), 3050 BPF_ALU64_IMM(BPF_AND, R2, 0xffffffff), 3051 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 3052 BPF_MOV32_IMM(R0, 2), 3053 BPF_EXIT_INSN(), 3054 BPF_MOV32_IMM(R0, 1), 3055 BPF_EXIT_INSN(), 3056 }, 3057 INTERNAL, 3058 { }, 3059 { { 0, 0x1 } }, 3060 }, 3061 { 3062 "ALU64_AND_K: 0xffffffffffffffff & -1 = 0xffffffffffffffff", 3063 .u.insns_int = { 3064 BPF_LD_IMM64(R2, 0xffffffffffffffffLL), 3065 BPF_LD_IMM64(R3, 0xffffffffffffffffLL), 3066 BPF_ALU64_IMM(BPF_AND, R2, 0xffffffff), 3067 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 3068 BPF_MOV32_IMM(R0, 2), 3069 BPF_EXIT_INSN(), 3070 BPF_MOV32_IMM(R0, 1), 3071 BPF_EXIT_INSN(), 3072 }, 3073 INTERNAL, 3074 { }, 3075 { { 0, 0x1 } }, 3076 }, 3077 /* BPF_ALU | BPF_OR | BPF_X */ 3078 { 3079 "ALU_OR_X: 1 | 2 = 3", 3080 .u.insns_int = { 3081 BPF_LD_IMM64(R0, 1), 3082 BPF_ALU32_IMM(BPF_MOV, R1, 2), 3083 BPF_ALU32_REG(BPF_OR, R0, R1), 3084 BPF_EXIT_INSN(), 3085 }, 3086 INTERNAL, 3087 { }, 3088 { { 0, 3 } }, 3089 }, 3090 { 3091 "ALU_OR_X: 0x0 | 0xffffffff = 0xffffffff", 3092 .u.insns_int = { 3093 BPF_LD_IMM64(R0, 0), 3094 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), 3095 BPF_ALU32_REG(BPF_OR, R0, R1), 3096 BPF_EXIT_INSN(), 3097 }, 3098 INTERNAL, 3099 { }, 3100 { { 0, 0xffffffff } }, 3101 }, 3102 { 3103 "ALU64_OR_X: 1 | 2 = 3", 3104 .u.insns_int = { 3105 BPF_LD_IMM64(R0, 1), 3106 BPF_ALU32_IMM(BPF_MOV, R1, 2), 3107 BPF_ALU64_REG(BPF_OR, R0, R1), 3108 BPF_EXIT_INSN(), 3109 }, 3110 INTERNAL, 3111 { }, 3112 { { 0, 3 } }, 3113 }, 3114 { 3115 "ALU64_OR_X: 0 | 0xffffffff = 0xffffffff", 3116 .u.insns_int = { 3117 BPF_LD_IMM64(R0, 0), 3118 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), 3119 BPF_ALU64_REG(BPF_OR, R0, R1), 3120 BPF_EXIT_INSN(), 3121 }, 3122 INTERNAL, 3123 { }, 3124 { { 0, 0xffffffff } }, 3125 }, 3126 /* BPF_ALU | BPF_OR | BPF_K */ 3127 { 3128 "ALU_OR_K: 1 | 2 = 3", 3129 .u.insns_int = { 3130 BPF_LD_IMM64(R0, 1), 3131 BPF_ALU32_IMM(BPF_OR, R0, 2), 3132 BPF_EXIT_INSN(), 3133 }, 3134 INTERNAL, 3135 { }, 3136 { { 0, 3 } }, 3137 }, 3138 { 3139 "ALU_OR_K: 0 & 0xffffffff = 0xffffffff", 3140 .u.insns_int = { 3141 BPF_LD_IMM64(R0, 0), 3142 BPF_ALU32_IMM(BPF_OR, R0, 0xffffffff), 3143 BPF_EXIT_INSN(), 3144 }, 3145 INTERNAL, 3146 { }, 3147 { { 0, 0xffffffff } }, 3148 }, 3149 { 3150 "ALU64_OR_K: 1 | 2 = 3", 3151 .u.insns_int = { 3152 BPF_LD_IMM64(R0, 1), 3153 BPF_ALU64_IMM(BPF_OR, R0, 2), 3154 BPF_EXIT_INSN(), 3155 }, 3156 INTERNAL, 3157 { }, 3158 { { 0, 3 } }, 3159 }, 3160 { 3161 "ALU64_OR_K: 0 & 0xffffffff = 0xffffffff", 3162 .u.insns_int = { 3163 BPF_LD_IMM64(R0, 0), 3164 BPF_ALU64_IMM(BPF_OR, R0, 0xffffffff), 3165 BPF_EXIT_INSN(), 3166 }, 3167 INTERNAL, 3168 { }, 3169 { { 0, 0xffffffff } }, 3170 }, 3171 { 3172 "ALU64_OR_K: 0x0000ffffffff0000 | 0x0 = 0x0000ffff00000000", 3173 .u.insns_int = { 3174 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), 3175 BPF_LD_IMM64(R3, 0x0000ffffffff0000LL), 3176 BPF_ALU64_IMM(BPF_OR, R2, 0x0), 3177 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 3178 BPF_MOV32_IMM(R0, 2), 3179 BPF_EXIT_INSN(), 3180 BPF_MOV32_IMM(R0, 1), 3181 BPF_EXIT_INSN(), 3182 }, 3183 INTERNAL, 3184 { }, 3185 { { 0, 0x1 } }, 3186 }, 3187 { 3188 "ALU64_OR_K: 0x0000ffffffff0000 | -1 = 0xffffffffffffffff", 3189 .u.insns_int = { 3190 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), 3191 BPF_LD_IMM64(R3, 0xffffffffffffffffLL), 3192 BPF_ALU64_IMM(BPF_OR, R2, 0xffffffff), 3193 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 3194 BPF_MOV32_IMM(R0, 2), 3195 BPF_EXIT_INSN(), 3196 BPF_MOV32_IMM(R0, 1), 3197 BPF_EXIT_INSN(), 3198 }, 3199 INTERNAL, 3200 { }, 3201 { { 0, 0x1 } }, 3202 }, 3203 { 3204 "ALU64_OR_K: 0x000000000000000 | -1 = 0xffffffffffffffff", 3205 .u.insns_int = { 3206 BPF_LD_IMM64(R2, 0x0000000000000000LL), 3207 BPF_LD_IMM64(R3, 0xffffffffffffffffLL), 3208 BPF_ALU64_IMM(BPF_OR, R2, 0xffffffff), 3209 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 3210 BPF_MOV32_IMM(R0, 2), 3211 BPF_EXIT_INSN(), 3212 BPF_MOV32_IMM(R0, 1), 3213 BPF_EXIT_INSN(), 3214 }, 3215 INTERNAL, 3216 { }, 3217 { { 0, 0x1 } }, 3218 }, 3219 /* BPF_ALU | BPF_XOR | BPF_X */ 3220 { 3221 "ALU_XOR_X: 5 ^ 6 = 3", 3222 .u.insns_int = { 3223 BPF_LD_IMM64(R0, 5), 3224 BPF_ALU32_IMM(BPF_MOV, R1, 6), 3225 BPF_ALU32_REG(BPF_XOR, R0, R1), 3226 BPF_EXIT_INSN(), 3227 }, 3228 INTERNAL, 3229 { }, 3230 { { 0, 3 } }, 3231 }, 3232 { 3233 "ALU_XOR_X: 0x1 ^ 0xffffffff = 0xfffffffe", 3234 .u.insns_int = { 3235 BPF_LD_IMM64(R0, 1), 3236 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), 3237 BPF_ALU32_REG(BPF_XOR, R0, R1), 3238 BPF_EXIT_INSN(), 3239 }, 3240 INTERNAL, 3241 { }, 3242 { { 0, 0xfffffffe } }, 3243 }, 3244 { 3245 "ALU64_XOR_X: 5 ^ 6 = 3", 3246 .u.insns_int = { 3247 BPF_LD_IMM64(R0, 5), 3248 BPF_ALU32_IMM(BPF_MOV, R1, 6), 3249 BPF_ALU64_REG(BPF_XOR, R0, R1), 3250 BPF_EXIT_INSN(), 3251 }, 3252 INTERNAL, 3253 { }, 3254 { { 0, 3 } }, 3255 }, 3256 { 3257 "ALU64_XOR_X: 1 ^ 0xffffffff = 0xfffffffe", 3258 .u.insns_int = { 3259 BPF_LD_IMM64(R0, 1), 3260 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff), 3261 BPF_ALU64_REG(BPF_XOR, R0, R1), 3262 BPF_EXIT_INSN(), 3263 }, 3264 INTERNAL, 3265 { }, 3266 { { 0, 0xfffffffe } }, 3267 }, 3268 /* BPF_ALU | BPF_XOR | BPF_K */ 3269 { 3270 "ALU_XOR_K: 5 ^ 6 = 3", 3271 .u.insns_int = { 3272 BPF_LD_IMM64(R0, 5), 3273 BPF_ALU32_IMM(BPF_XOR, R0, 6), 3274 BPF_EXIT_INSN(), 3275 }, 3276 INTERNAL, 3277 { }, 3278 { { 0, 3 } }, 3279 }, 3280 { 3281 "ALU_XOR_K: 1 ^ 0xffffffff = 0xfffffffe", 3282 .u.insns_int = { 3283 BPF_LD_IMM64(R0, 1), 3284 BPF_ALU32_IMM(BPF_XOR, R0, 0xffffffff), 3285 BPF_EXIT_INSN(), 3286 }, 3287 INTERNAL, 3288 { }, 3289 { { 0, 0xfffffffe } }, 3290 }, 3291 { 3292 "ALU64_XOR_K: 5 ^ 6 = 3", 3293 .u.insns_int = { 3294 BPF_LD_IMM64(R0, 5), 3295 BPF_ALU64_IMM(BPF_XOR, R0, 6), 3296 BPF_EXIT_INSN(), 3297 }, 3298 INTERNAL, 3299 { }, 3300 { { 0, 3 } }, 3301 }, 3302 { 3303 "ALU64_XOR_K: 1 & 0xffffffff = 0xfffffffe", 3304 .u.insns_int = { 3305 BPF_LD_IMM64(R0, 1), 3306 BPF_ALU64_IMM(BPF_XOR, R0, 0xffffffff), 3307 BPF_EXIT_INSN(), 3308 }, 3309 INTERNAL, 3310 { }, 3311 { { 0, 0xfffffffe } }, 3312 }, 3313 { 3314 "ALU64_XOR_K: 0x0000ffffffff0000 ^ 0x0 = 0x0000ffffffff0000", 3315 .u.insns_int = { 3316 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), 3317 BPF_LD_IMM64(R3, 0x0000ffffffff0000LL), 3318 BPF_ALU64_IMM(BPF_XOR, R2, 0x0), 3319 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 3320 BPF_MOV32_IMM(R0, 2), 3321 BPF_EXIT_INSN(), 3322 BPF_MOV32_IMM(R0, 1), 3323 BPF_EXIT_INSN(), 3324 }, 3325 INTERNAL, 3326 { }, 3327 { { 0, 0x1 } }, 3328 }, 3329 { 3330 "ALU64_XOR_K: 0x0000ffffffff0000 ^ -1 = 0xffff00000000ffff", 3331 .u.insns_int = { 3332 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL), 3333 BPF_LD_IMM64(R3, 0xffff00000000ffffLL), 3334 BPF_ALU64_IMM(BPF_XOR, R2, 0xffffffff), 3335 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 3336 BPF_MOV32_IMM(R0, 2), 3337 BPF_EXIT_INSN(), 3338 BPF_MOV32_IMM(R0, 1), 3339 BPF_EXIT_INSN(), 3340 }, 3341 INTERNAL, 3342 { }, 3343 { { 0, 0x1 } }, 3344 }, 3345 { 3346 "ALU64_XOR_K: 0x000000000000000 ^ -1 = 0xffffffffffffffff", 3347 .u.insns_int = { 3348 BPF_LD_IMM64(R2, 0x0000000000000000LL), 3349 BPF_LD_IMM64(R3, 0xffffffffffffffffLL), 3350 BPF_ALU64_IMM(BPF_XOR, R2, 0xffffffff), 3351 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 3352 BPF_MOV32_IMM(R0, 2), 3353 BPF_EXIT_INSN(), 3354 BPF_MOV32_IMM(R0, 1), 3355 BPF_EXIT_INSN(), 3356 }, 3357 INTERNAL, 3358 { }, 3359 { { 0, 0x1 } }, 3360 }, 3361 /* BPF_ALU | BPF_LSH | BPF_X */ 3362 { 3363 "ALU_LSH_X: 1 << 1 = 2", 3364 .u.insns_int = { 3365 BPF_LD_IMM64(R0, 1), 3366 BPF_ALU32_IMM(BPF_MOV, R1, 1), 3367 BPF_ALU32_REG(BPF_LSH, R0, R1), 3368 BPF_EXIT_INSN(), 3369 }, 3370 INTERNAL, 3371 { }, 3372 { { 0, 2 } }, 3373 }, 3374 { 3375 "ALU_LSH_X: 1 << 31 = 0x80000000", 3376 .u.insns_int = { 3377 BPF_LD_IMM64(R0, 1), 3378 BPF_ALU32_IMM(BPF_MOV, R1, 31), 3379 BPF_ALU32_REG(BPF_LSH, R0, R1), 3380 BPF_EXIT_INSN(), 3381 }, 3382 INTERNAL, 3383 { }, 3384 { { 0, 0x80000000 } }, 3385 }, 3386 { 3387 "ALU64_LSH_X: 1 << 1 = 2", 3388 .u.insns_int = { 3389 BPF_LD_IMM64(R0, 1), 3390 BPF_ALU32_IMM(BPF_MOV, R1, 1), 3391 BPF_ALU64_REG(BPF_LSH, R0, R1), 3392 BPF_EXIT_INSN(), 3393 }, 3394 INTERNAL, 3395 { }, 3396 { { 0, 2 } }, 3397 }, 3398 { 3399 "ALU64_LSH_X: 1 << 31 = 0x80000000", 3400 .u.insns_int = { 3401 BPF_LD_IMM64(R0, 1), 3402 BPF_ALU32_IMM(BPF_MOV, R1, 31), 3403 BPF_ALU64_REG(BPF_LSH, R0, R1), 3404 BPF_EXIT_INSN(), 3405 }, 3406 INTERNAL, 3407 { }, 3408 { { 0, 0x80000000 } }, 3409 }, 3410 /* BPF_ALU | BPF_LSH | BPF_K */ 3411 { 3412 "ALU_LSH_K: 1 << 1 = 2", 3413 .u.insns_int = { 3414 BPF_LD_IMM64(R0, 1), 3415 BPF_ALU32_IMM(BPF_LSH, R0, 1), 3416 BPF_EXIT_INSN(), 3417 }, 3418 INTERNAL, 3419 { }, 3420 { { 0, 2 } }, 3421 }, 3422 { 3423 "ALU_LSH_K: 1 << 31 = 0x80000000", 3424 .u.insns_int = { 3425 BPF_LD_IMM64(R0, 1), 3426 BPF_ALU32_IMM(BPF_LSH, R0, 31), 3427 BPF_EXIT_INSN(), 3428 }, 3429 INTERNAL, 3430 { }, 3431 { { 0, 0x80000000 } }, 3432 }, 3433 { 3434 "ALU64_LSH_K: 1 << 1 = 2", 3435 .u.insns_int = { 3436 BPF_LD_IMM64(R0, 1), 3437 BPF_ALU64_IMM(BPF_LSH, R0, 1), 3438 BPF_EXIT_INSN(), 3439 }, 3440 INTERNAL, 3441 { }, 3442 { { 0, 2 } }, 3443 }, 3444 { 3445 "ALU64_LSH_K: 1 << 31 = 0x80000000", 3446 .u.insns_int = { 3447 BPF_LD_IMM64(R0, 1), 3448 BPF_ALU64_IMM(BPF_LSH, R0, 31), 3449 BPF_EXIT_INSN(), 3450 }, 3451 INTERNAL, 3452 { }, 3453 { { 0, 0x80000000 } }, 3454 }, 3455 /* BPF_ALU | BPF_RSH | BPF_X */ 3456 { 3457 "ALU_RSH_X: 2 >> 1 = 1", 3458 .u.insns_int = { 3459 BPF_LD_IMM64(R0, 2), 3460 BPF_ALU32_IMM(BPF_MOV, R1, 1), 3461 BPF_ALU32_REG(BPF_RSH, R0, R1), 3462 BPF_EXIT_INSN(), 3463 }, 3464 INTERNAL, 3465 { }, 3466 { { 0, 1 } }, 3467 }, 3468 { 3469 "ALU_RSH_X: 0x80000000 >> 31 = 1", 3470 .u.insns_int = { 3471 BPF_LD_IMM64(R0, 0x80000000), 3472 BPF_ALU32_IMM(BPF_MOV, R1, 31), 3473 BPF_ALU32_REG(BPF_RSH, R0, R1), 3474 BPF_EXIT_INSN(), 3475 }, 3476 INTERNAL, 3477 { }, 3478 { { 0, 1 } }, 3479 }, 3480 { 3481 "ALU64_RSH_X: 2 >> 1 = 1", 3482 .u.insns_int = { 3483 BPF_LD_IMM64(R0, 2), 3484 BPF_ALU32_IMM(BPF_MOV, R1, 1), 3485 BPF_ALU64_REG(BPF_RSH, R0, R1), 3486 BPF_EXIT_INSN(), 3487 }, 3488 INTERNAL, 3489 { }, 3490 { { 0, 1 } }, 3491 }, 3492 { 3493 "ALU64_RSH_X: 0x80000000 >> 31 = 1", 3494 .u.insns_int = { 3495 BPF_LD_IMM64(R0, 0x80000000), 3496 BPF_ALU32_IMM(BPF_MOV, R1, 31), 3497 BPF_ALU64_REG(BPF_RSH, R0, R1), 3498 BPF_EXIT_INSN(), 3499 }, 3500 INTERNAL, 3501 { }, 3502 { { 0, 1 } }, 3503 }, 3504 /* BPF_ALU | BPF_RSH | BPF_K */ 3505 { 3506 "ALU_RSH_K: 2 >> 1 = 1", 3507 .u.insns_int = { 3508 BPF_LD_IMM64(R0, 2), 3509 BPF_ALU32_IMM(BPF_RSH, R0, 1), 3510 BPF_EXIT_INSN(), 3511 }, 3512 INTERNAL, 3513 { }, 3514 { { 0, 1 } }, 3515 }, 3516 { 3517 "ALU_RSH_K: 0x80000000 >> 31 = 1", 3518 .u.insns_int = { 3519 BPF_LD_IMM64(R0, 0x80000000), 3520 BPF_ALU32_IMM(BPF_RSH, R0, 31), 3521 BPF_EXIT_INSN(), 3522 }, 3523 INTERNAL, 3524 { }, 3525 { { 0, 1 } }, 3526 }, 3527 { 3528 "ALU64_RSH_K: 2 >> 1 = 1", 3529 .u.insns_int = { 3530 BPF_LD_IMM64(R0, 2), 3531 BPF_ALU64_IMM(BPF_RSH, R0, 1), 3532 BPF_EXIT_INSN(), 3533 }, 3534 INTERNAL, 3535 { }, 3536 { { 0, 1 } }, 3537 }, 3538 { 3539 "ALU64_RSH_K: 0x80000000 >> 31 = 1", 3540 .u.insns_int = { 3541 BPF_LD_IMM64(R0, 0x80000000), 3542 BPF_ALU64_IMM(BPF_RSH, R0, 31), 3543 BPF_EXIT_INSN(), 3544 }, 3545 INTERNAL, 3546 { }, 3547 { { 0, 1 } }, 3548 }, 3549 /* BPF_ALU | BPF_ARSH | BPF_X */ 3550 { 3551 "ALU_ARSH_X: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff", 3552 .u.insns_int = { 3553 BPF_LD_IMM64(R0, 0xff00ff0000000000LL), 3554 BPF_ALU32_IMM(BPF_MOV, R1, 40), 3555 BPF_ALU64_REG(BPF_ARSH, R0, R1), 3556 BPF_EXIT_INSN(), 3557 }, 3558 INTERNAL, 3559 { }, 3560 { { 0, 0xffff00ff } }, 3561 }, 3562 /* BPF_ALU | BPF_ARSH | BPF_K */ 3563 { 3564 "ALU_ARSH_K: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff", 3565 .u.insns_int = { 3566 BPF_LD_IMM64(R0, 0xff00ff0000000000LL), 3567 BPF_ALU64_IMM(BPF_ARSH, R0, 40), 3568 BPF_EXIT_INSN(), 3569 }, 3570 INTERNAL, 3571 { }, 3572 { { 0, 0xffff00ff } }, 3573 }, 3574 /* BPF_ALU | BPF_NEG */ 3575 { 3576 "ALU_NEG: -(3) = -3", 3577 .u.insns_int = { 3578 BPF_ALU32_IMM(BPF_MOV, R0, 3), 3579 BPF_ALU32_IMM(BPF_NEG, R0, 0), 3580 BPF_EXIT_INSN(), 3581 }, 3582 INTERNAL, 3583 { }, 3584 { { 0, -3 } }, 3585 }, 3586 { 3587 "ALU_NEG: -(-3) = 3", 3588 .u.insns_int = { 3589 BPF_ALU32_IMM(BPF_MOV, R0, -3), 3590 BPF_ALU32_IMM(BPF_NEG, R0, 0), 3591 BPF_EXIT_INSN(), 3592 }, 3593 INTERNAL, 3594 { }, 3595 { { 0, 3 } }, 3596 }, 3597 { 3598 "ALU64_NEG: -(3) = -3", 3599 .u.insns_int = { 3600 BPF_LD_IMM64(R0, 3), 3601 BPF_ALU64_IMM(BPF_NEG, R0, 0), 3602 BPF_EXIT_INSN(), 3603 }, 3604 INTERNAL, 3605 { }, 3606 { { 0, -3 } }, 3607 }, 3608 { 3609 "ALU64_NEG: -(-3) = 3", 3610 .u.insns_int = { 3611 BPF_LD_IMM64(R0, -3), 3612 BPF_ALU64_IMM(BPF_NEG, R0, 0), 3613 BPF_EXIT_INSN(), 3614 }, 3615 INTERNAL, 3616 { }, 3617 { { 0, 3 } }, 3618 }, 3619 /* BPF_ALU | BPF_END | BPF_FROM_BE */ 3620 { 3621 "ALU_END_FROM_BE 16: 0x0123456789abcdef -> 0xcdef", 3622 .u.insns_int = { 3623 BPF_LD_IMM64(R0, 0x0123456789abcdefLL), 3624 BPF_ENDIAN(BPF_FROM_BE, R0, 16), 3625 BPF_EXIT_INSN(), 3626 }, 3627 INTERNAL, 3628 { }, 3629 { { 0, cpu_to_be16(0xcdef) } }, 3630 }, 3631 { 3632 "ALU_END_FROM_BE 32: 0x0123456789abcdef -> 0x89abcdef", 3633 .u.insns_int = { 3634 BPF_LD_IMM64(R0, 0x0123456789abcdefLL), 3635 BPF_ENDIAN(BPF_FROM_BE, R0, 32), 3636 BPF_EXIT_INSN(), 3637 }, 3638 INTERNAL, 3639 { }, 3640 { { 0, cpu_to_be32(0x89abcdef) } }, 3641 }, 3642 { 3643 "ALU_END_FROM_BE 64: 0x0123456789abcdef -> 0x89abcdef", 3644 .u.insns_int = { 3645 BPF_LD_IMM64(R0, 0x0123456789abcdefLL), 3646 BPF_ENDIAN(BPF_FROM_BE, R0, 64), 3647 BPF_EXIT_INSN(), 3648 }, 3649 INTERNAL, 3650 { }, 3651 { { 0, (u32) cpu_to_be64(0x0123456789abcdefLL) } }, 3652 }, 3653 /* BPF_ALU | BPF_END | BPF_FROM_LE */ 3654 { 3655 "ALU_END_FROM_LE 16: 0x0123456789abcdef -> 0xefcd", 3656 .u.insns_int = { 3657 BPF_LD_IMM64(R0, 0x0123456789abcdefLL), 3658 BPF_ENDIAN(BPF_FROM_LE, R0, 16), 3659 BPF_EXIT_INSN(), 3660 }, 3661 INTERNAL, 3662 { }, 3663 { { 0, cpu_to_le16(0xcdef) } }, 3664 }, 3665 { 3666 "ALU_END_FROM_LE 32: 0x0123456789abcdef -> 0xefcdab89", 3667 .u.insns_int = { 3668 BPF_LD_IMM64(R0, 0x0123456789abcdefLL), 3669 BPF_ENDIAN(BPF_FROM_LE, R0, 32), 3670 BPF_EXIT_INSN(), 3671 }, 3672 INTERNAL, 3673 { }, 3674 { { 0, cpu_to_le32(0x89abcdef) } }, 3675 }, 3676 { 3677 "ALU_END_FROM_LE 64: 0x0123456789abcdef -> 0x67452301", 3678 .u.insns_int = { 3679 BPF_LD_IMM64(R0, 0x0123456789abcdefLL), 3680 BPF_ENDIAN(BPF_FROM_LE, R0, 64), 3681 BPF_EXIT_INSN(), 3682 }, 3683 INTERNAL, 3684 { }, 3685 { { 0, (u32) cpu_to_le64(0x0123456789abcdefLL) } }, 3686 }, 3687 /* BPF_ST(X) | BPF_MEM | BPF_B/H/W/DW */ 3688 { 3689 "ST_MEM_B: Store/Load byte: max negative", 3690 .u.insns_int = { 3691 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3692 BPF_ST_MEM(BPF_B, R10, -40, 0xff), 3693 BPF_LDX_MEM(BPF_B, R0, R10, -40), 3694 BPF_EXIT_INSN(), 3695 }, 3696 INTERNAL, 3697 { }, 3698 { { 0, 0xff } }, 3699 }, 3700 { 3701 "ST_MEM_B: Store/Load byte: max positive", 3702 .u.insns_int = { 3703 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3704 BPF_ST_MEM(BPF_H, R10, -40, 0x7f), 3705 BPF_LDX_MEM(BPF_H, R0, R10, -40), 3706 BPF_EXIT_INSN(), 3707 }, 3708 INTERNAL, 3709 { }, 3710 { { 0, 0x7f } }, 3711 }, 3712 { 3713 "STX_MEM_B: Store/Load byte: max negative", 3714 .u.insns_int = { 3715 BPF_LD_IMM64(R0, 0), 3716 BPF_LD_IMM64(R1, 0xffLL), 3717 BPF_STX_MEM(BPF_B, R10, R1, -40), 3718 BPF_LDX_MEM(BPF_B, R0, R10, -40), 3719 BPF_EXIT_INSN(), 3720 }, 3721 INTERNAL, 3722 { }, 3723 { { 0, 0xff } }, 3724 }, 3725 { 3726 "ST_MEM_H: Store/Load half word: max negative", 3727 .u.insns_int = { 3728 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3729 BPF_ST_MEM(BPF_H, R10, -40, 0xffff), 3730 BPF_LDX_MEM(BPF_H, R0, R10, -40), 3731 BPF_EXIT_INSN(), 3732 }, 3733 INTERNAL, 3734 { }, 3735 { { 0, 0xffff } }, 3736 }, 3737 { 3738 "ST_MEM_H: Store/Load half word: max positive", 3739 .u.insns_int = { 3740 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3741 BPF_ST_MEM(BPF_H, R10, -40, 0x7fff), 3742 BPF_LDX_MEM(BPF_H, R0, R10, -40), 3743 BPF_EXIT_INSN(), 3744 }, 3745 INTERNAL, 3746 { }, 3747 { { 0, 0x7fff } }, 3748 }, 3749 { 3750 "STX_MEM_H: Store/Load half word: max negative", 3751 .u.insns_int = { 3752 BPF_LD_IMM64(R0, 0), 3753 BPF_LD_IMM64(R1, 0xffffLL), 3754 BPF_STX_MEM(BPF_H, R10, R1, -40), 3755 BPF_LDX_MEM(BPF_H, R0, R10, -40), 3756 BPF_EXIT_INSN(), 3757 }, 3758 INTERNAL, 3759 { }, 3760 { { 0, 0xffff } }, 3761 }, 3762 { 3763 "ST_MEM_W: Store/Load word: max negative", 3764 .u.insns_int = { 3765 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3766 BPF_ST_MEM(BPF_W, R10, -40, 0xffffffff), 3767 BPF_LDX_MEM(BPF_W, R0, R10, -40), 3768 BPF_EXIT_INSN(), 3769 }, 3770 INTERNAL, 3771 { }, 3772 { { 0, 0xffffffff } }, 3773 }, 3774 { 3775 "ST_MEM_W: Store/Load word: max positive", 3776 .u.insns_int = { 3777 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3778 BPF_ST_MEM(BPF_W, R10, -40, 0x7fffffff), 3779 BPF_LDX_MEM(BPF_W, R0, R10, -40), 3780 BPF_EXIT_INSN(), 3781 }, 3782 INTERNAL, 3783 { }, 3784 { { 0, 0x7fffffff } }, 3785 }, 3786 { 3787 "STX_MEM_W: Store/Load word: max negative", 3788 .u.insns_int = { 3789 BPF_LD_IMM64(R0, 0), 3790 BPF_LD_IMM64(R1, 0xffffffffLL), 3791 BPF_STX_MEM(BPF_W, R10, R1, -40), 3792 BPF_LDX_MEM(BPF_W, R0, R10, -40), 3793 BPF_EXIT_INSN(), 3794 }, 3795 INTERNAL, 3796 { }, 3797 { { 0, 0xffffffff } }, 3798 }, 3799 { 3800 "ST_MEM_DW: Store/Load double word: max negative", 3801 .u.insns_int = { 3802 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3803 BPF_ST_MEM(BPF_DW, R10, -40, 0xffffffff), 3804 BPF_LDX_MEM(BPF_DW, R0, R10, -40), 3805 BPF_EXIT_INSN(), 3806 }, 3807 INTERNAL, 3808 { }, 3809 { { 0, 0xffffffff } }, 3810 }, 3811 { 3812 "ST_MEM_DW: Store/Load double word: max negative 2", 3813 .u.insns_int = { 3814 BPF_LD_IMM64(R2, 0xffff00000000ffffLL), 3815 BPF_LD_IMM64(R3, 0xffffffffffffffffLL), 3816 BPF_ST_MEM(BPF_DW, R10, -40, 0xffffffff), 3817 BPF_LDX_MEM(BPF_DW, R2, R10, -40), 3818 BPF_JMP_REG(BPF_JEQ, R2, R3, 2), 3819 BPF_MOV32_IMM(R0, 2), 3820 BPF_EXIT_INSN(), 3821 BPF_MOV32_IMM(R0, 1), 3822 BPF_EXIT_INSN(), 3823 }, 3824 INTERNAL, 3825 { }, 3826 { { 0, 0x1 } }, 3827 }, 3828 { 3829 "ST_MEM_DW: Store/Load double word: max positive", 3830 .u.insns_int = { 3831 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3832 BPF_ST_MEM(BPF_DW, R10, -40, 0x7fffffff), 3833 BPF_LDX_MEM(BPF_DW, R0, R10, -40), 3834 BPF_EXIT_INSN(), 3835 }, 3836 INTERNAL, 3837 { }, 3838 { { 0, 0x7fffffff } }, 3839 }, 3840 { 3841 "STX_MEM_DW: Store/Load double word: max negative", 3842 .u.insns_int = { 3843 BPF_LD_IMM64(R0, 0), 3844 BPF_LD_IMM64(R1, 0xffffffffffffffffLL), 3845 BPF_STX_MEM(BPF_W, R10, R1, -40), 3846 BPF_LDX_MEM(BPF_W, R0, R10, -40), 3847 BPF_EXIT_INSN(), 3848 }, 3849 INTERNAL, 3850 { }, 3851 { { 0, 0xffffffff } }, 3852 }, 3853 /* BPF_STX | BPF_XADD | BPF_W/DW */ 3854 { 3855 "STX_XADD_W: Test: 0x12 + 0x10 = 0x22", 3856 .u.insns_int = { 3857 BPF_ALU32_IMM(BPF_MOV, R0, 0x12), 3858 BPF_ST_MEM(BPF_W, R10, -40, 0x10), 3859 BPF_STX_XADD(BPF_W, R10, R0, -40), 3860 BPF_LDX_MEM(BPF_W, R0, R10, -40), 3861 BPF_EXIT_INSN(), 3862 }, 3863 INTERNAL, 3864 { }, 3865 { { 0, 0x22 } }, 3866 }, 3867 { 3868 "STX_XADD_DW: Test: 0x12 + 0x10 = 0x22", 3869 .u.insns_int = { 3870 BPF_ALU32_IMM(BPF_MOV, R0, 0x12), 3871 BPF_ST_MEM(BPF_DW, R10, -40, 0x10), 3872 BPF_STX_XADD(BPF_DW, R10, R0, -40), 3873 BPF_LDX_MEM(BPF_DW, R0, R10, -40), 3874 BPF_EXIT_INSN(), 3875 }, 3876 INTERNAL, 3877 { }, 3878 { { 0, 0x22 } }, 3879 }, 3880 /* BPF_JMP | BPF_EXIT */ 3881 { 3882 "JMP_EXIT", 3883 .u.insns_int = { 3884 BPF_ALU32_IMM(BPF_MOV, R0, 0x4711), 3885 BPF_EXIT_INSN(), 3886 BPF_ALU32_IMM(BPF_MOV, R0, 0x4712), 3887 }, 3888 INTERNAL, 3889 { }, 3890 { { 0, 0x4711 } }, 3891 }, 3892 /* BPF_JMP | BPF_JA */ 3893 { 3894 "JMP_JA: Unconditional jump: if (true) return 1", 3895 .u.insns_int = { 3896 BPF_ALU32_IMM(BPF_MOV, R0, 0), 3897 BPF_JMP_IMM(BPF_JA, 0, 0, 1), 3898 BPF_EXIT_INSN(), 3899 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3900 BPF_EXIT_INSN(), 3901 }, 3902 INTERNAL, 3903 { }, 3904 { { 0, 1 } }, 3905 }, 3906 /* BPF_JMP | BPF_JSGT | BPF_K */ 3907 { 3908 "JMP_JSGT_K: Signed jump: if (-1 > -2) return 1", 3909 .u.insns_int = { 3910 BPF_ALU32_IMM(BPF_MOV, R0, 0), 3911 BPF_LD_IMM64(R1, 0xffffffffffffffffLL), 3912 BPF_JMP_IMM(BPF_JSGT, R1, -2, 1), 3913 BPF_EXIT_INSN(), 3914 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3915 BPF_EXIT_INSN(), 3916 }, 3917 INTERNAL, 3918 { }, 3919 { { 0, 1 } }, 3920 }, 3921 { 3922 "JMP_JSGT_K: Signed jump: if (-1 > -1) return 0", 3923 .u.insns_int = { 3924 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3925 BPF_LD_IMM64(R1, 0xffffffffffffffffLL), 3926 BPF_JMP_IMM(BPF_JSGT, R1, -1, 1), 3927 BPF_EXIT_INSN(), 3928 BPF_ALU32_IMM(BPF_MOV, R0, 0), 3929 BPF_EXIT_INSN(), 3930 }, 3931 INTERNAL, 3932 { }, 3933 { { 0, 1 } }, 3934 }, 3935 /* BPF_JMP | BPF_JSGE | BPF_K */ 3936 { 3937 "JMP_JSGE_K: Signed jump: if (-1 >= -2) return 1", 3938 .u.insns_int = { 3939 BPF_ALU32_IMM(BPF_MOV, R0, 0), 3940 BPF_LD_IMM64(R1, 0xffffffffffffffffLL), 3941 BPF_JMP_IMM(BPF_JSGE, R1, -2, 1), 3942 BPF_EXIT_INSN(), 3943 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3944 BPF_EXIT_INSN(), 3945 }, 3946 INTERNAL, 3947 { }, 3948 { { 0, 1 } }, 3949 }, 3950 { 3951 "JMP_JSGE_K: Signed jump: if (-1 >= -1) return 1", 3952 .u.insns_int = { 3953 BPF_ALU32_IMM(BPF_MOV, R0, 0), 3954 BPF_LD_IMM64(R1, 0xffffffffffffffffLL), 3955 BPF_JMP_IMM(BPF_JSGE, R1, -1, 1), 3956 BPF_EXIT_INSN(), 3957 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3958 BPF_EXIT_INSN(), 3959 }, 3960 INTERNAL, 3961 { }, 3962 { { 0, 1 } }, 3963 }, 3964 /* BPF_JMP | BPF_JGT | BPF_K */ 3965 { 3966 "JMP_JGT_K: if (3 > 2) return 1", 3967 .u.insns_int = { 3968 BPF_ALU32_IMM(BPF_MOV, R0, 0), 3969 BPF_LD_IMM64(R1, 3), 3970 BPF_JMP_IMM(BPF_JGT, R1, 2, 1), 3971 BPF_EXIT_INSN(), 3972 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3973 BPF_EXIT_INSN(), 3974 }, 3975 INTERNAL, 3976 { }, 3977 { { 0, 1 } }, 3978 }, 3979 /* BPF_JMP | BPF_JGE | BPF_K */ 3980 { 3981 "JMP_JGE_K: if (3 >= 2) return 1", 3982 .u.insns_int = { 3983 BPF_ALU32_IMM(BPF_MOV, R0, 0), 3984 BPF_LD_IMM64(R1, 3), 3985 BPF_JMP_IMM(BPF_JGE, R1, 2, 1), 3986 BPF_EXIT_INSN(), 3987 BPF_ALU32_IMM(BPF_MOV, R0, 1), 3988 BPF_EXIT_INSN(), 3989 }, 3990 INTERNAL, 3991 { }, 3992 { { 0, 1 } }, 3993 }, 3994 /* BPF_JMP | BPF_JGT | BPF_K jump backwards */ 3995 { 3996 "JMP_JGT_K: if (3 > 2) return 1 (jump backwards)", 3997 .u.insns_int = { 3998 BPF_JMP_IMM(BPF_JA, 0, 0, 2), /* goto start */ 3999 BPF_ALU32_IMM(BPF_MOV, R0, 1), /* out: */ 4000 BPF_EXIT_INSN(), 4001 BPF_ALU32_IMM(BPF_MOV, R0, 0), /* start: */ 4002 BPF_LD_IMM64(R1, 3), /* note: this takes 2 insns */ 4003 BPF_JMP_IMM(BPF_JGT, R1, 2, -6), /* goto out */ 4004 BPF_EXIT_INSN(), 4005 }, 4006 INTERNAL, 4007 { }, 4008 { { 0, 1 } }, 4009 }, 4010 { 4011 "JMP_JGE_K: if (3 >= 3) return 1", 4012 .u.insns_int = { 4013 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4014 BPF_LD_IMM64(R1, 3), 4015 BPF_JMP_IMM(BPF_JGE, R1, 3, 1), 4016 BPF_EXIT_INSN(), 4017 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4018 BPF_EXIT_INSN(), 4019 }, 4020 INTERNAL, 4021 { }, 4022 { { 0, 1 } }, 4023 }, 4024 /* BPF_JMP | BPF_JNE | BPF_K */ 4025 { 4026 "JMP_JNE_K: if (3 != 2) return 1", 4027 .u.insns_int = { 4028 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4029 BPF_LD_IMM64(R1, 3), 4030 BPF_JMP_IMM(BPF_JNE, R1, 2, 1), 4031 BPF_EXIT_INSN(), 4032 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4033 BPF_EXIT_INSN(), 4034 }, 4035 INTERNAL, 4036 { }, 4037 { { 0, 1 } }, 4038 }, 4039 /* BPF_JMP | BPF_JEQ | BPF_K */ 4040 { 4041 "JMP_JEQ_K: if (3 == 3) return 1", 4042 .u.insns_int = { 4043 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4044 BPF_LD_IMM64(R1, 3), 4045 BPF_JMP_IMM(BPF_JEQ, R1, 3, 1), 4046 BPF_EXIT_INSN(), 4047 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4048 BPF_EXIT_INSN(), 4049 }, 4050 INTERNAL, 4051 { }, 4052 { { 0, 1 } }, 4053 }, 4054 /* BPF_JMP | BPF_JSET | BPF_K */ 4055 { 4056 "JMP_JSET_K: if (0x3 & 0x2) return 1", 4057 .u.insns_int = { 4058 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4059 BPF_LD_IMM64(R1, 3), 4060 BPF_JMP_IMM(BPF_JNE, R1, 2, 1), 4061 BPF_EXIT_INSN(), 4062 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4063 BPF_EXIT_INSN(), 4064 }, 4065 INTERNAL, 4066 { }, 4067 { { 0, 1 } }, 4068 }, 4069 { 4070 "JMP_JSET_K: if (0x3 & 0xffffffff) return 1", 4071 .u.insns_int = { 4072 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4073 BPF_LD_IMM64(R1, 3), 4074 BPF_JMP_IMM(BPF_JNE, R1, 0xffffffff, 1), 4075 BPF_EXIT_INSN(), 4076 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4077 BPF_EXIT_INSN(), 4078 }, 4079 INTERNAL, 4080 { }, 4081 { { 0, 1 } }, 4082 }, 4083 /* BPF_JMP | BPF_JSGT | BPF_X */ 4084 { 4085 "JMP_JSGT_X: Signed jump: if (-1 > -2) return 1", 4086 .u.insns_int = { 4087 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4088 BPF_LD_IMM64(R1, -1), 4089 BPF_LD_IMM64(R2, -2), 4090 BPF_JMP_REG(BPF_JSGT, R1, R2, 1), 4091 BPF_EXIT_INSN(), 4092 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4093 BPF_EXIT_INSN(), 4094 }, 4095 INTERNAL, 4096 { }, 4097 { { 0, 1 } }, 4098 }, 4099 { 4100 "JMP_JSGT_X: Signed jump: if (-1 > -1) return 0", 4101 .u.insns_int = { 4102 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4103 BPF_LD_IMM64(R1, -1), 4104 BPF_LD_IMM64(R2, -1), 4105 BPF_JMP_REG(BPF_JSGT, R1, R2, 1), 4106 BPF_EXIT_INSN(), 4107 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4108 BPF_EXIT_INSN(), 4109 }, 4110 INTERNAL, 4111 { }, 4112 { { 0, 1 } }, 4113 }, 4114 /* BPF_JMP | BPF_JSGE | BPF_X */ 4115 { 4116 "JMP_JSGE_X: Signed jump: if (-1 >= -2) return 1", 4117 .u.insns_int = { 4118 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4119 BPF_LD_IMM64(R1, -1), 4120 BPF_LD_IMM64(R2, -2), 4121 BPF_JMP_REG(BPF_JSGE, R1, R2, 1), 4122 BPF_EXIT_INSN(), 4123 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4124 BPF_EXIT_INSN(), 4125 }, 4126 INTERNAL, 4127 { }, 4128 { { 0, 1 } }, 4129 }, 4130 { 4131 "JMP_JSGE_X: Signed jump: if (-1 >= -1) return 1", 4132 .u.insns_int = { 4133 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4134 BPF_LD_IMM64(R1, -1), 4135 BPF_LD_IMM64(R2, -1), 4136 BPF_JMP_REG(BPF_JSGE, R1, R2, 1), 4137 BPF_EXIT_INSN(), 4138 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4139 BPF_EXIT_INSN(), 4140 }, 4141 INTERNAL, 4142 { }, 4143 { { 0, 1 } }, 4144 }, 4145 /* BPF_JMP | BPF_JGT | BPF_X */ 4146 { 4147 "JMP_JGT_X: if (3 > 2) return 1", 4148 .u.insns_int = { 4149 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4150 BPF_LD_IMM64(R1, 3), 4151 BPF_LD_IMM64(R2, 2), 4152 BPF_JMP_REG(BPF_JGT, R1, R2, 1), 4153 BPF_EXIT_INSN(), 4154 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4155 BPF_EXIT_INSN(), 4156 }, 4157 INTERNAL, 4158 { }, 4159 { { 0, 1 } }, 4160 }, 4161 /* BPF_JMP | BPF_JGE | BPF_X */ 4162 { 4163 "JMP_JGE_X: if (3 >= 2) return 1", 4164 .u.insns_int = { 4165 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4166 BPF_LD_IMM64(R1, 3), 4167 BPF_LD_IMM64(R2, 2), 4168 BPF_JMP_REG(BPF_JGE, R1, R2, 1), 4169 BPF_EXIT_INSN(), 4170 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4171 BPF_EXIT_INSN(), 4172 }, 4173 INTERNAL, 4174 { }, 4175 { { 0, 1 } }, 4176 }, 4177 { 4178 "JMP_JGE_X: if (3 >= 3) return 1", 4179 .u.insns_int = { 4180 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4181 BPF_LD_IMM64(R1, 3), 4182 BPF_LD_IMM64(R2, 3), 4183 BPF_JMP_REG(BPF_JGE, R1, R2, 1), 4184 BPF_EXIT_INSN(), 4185 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4186 BPF_EXIT_INSN(), 4187 }, 4188 INTERNAL, 4189 { }, 4190 { { 0, 1 } }, 4191 }, 4192 /* BPF_JMP | BPF_JNE | BPF_X */ 4193 { 4194 "JMP_JNE_X: if (3 != 2) return 1", 4195 .u.insns_int = { 4196 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4197 BPF_LD_IMM64(R1, 3), 4198 BPF_LD_IMM64(R2, 2), 4199 BPF_JMP_REG(BPF_JNE, R1, R2, 1), 4200 BPF_EXIT_INSN(), 4201 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4202 BPF_EXIT_INSN(), 4203 }, 4204 INTERNAL, 4205 { }, 4206 { { 0, 1 } }, 4207 }, 4208 /* BPF_JMP | BPF_JEQ | BPF_X */ 4209 { 4210 "JMP_JEQ_X: if (3 == 3) return 1", 4211 .u.insns_int = { 4212 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4213 BPF_LD_IMM64(R1, 3), 4214 BPF_LD_IMM64(R2, 3), 4215 BPF_JMP_REG(BPF_JEQ, R1, R2, 1), 4216 BPF_EXIT_INSN(), 4217 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4218 BPF_EXIT_INSN(), 4219 }, 4220 INTERNAL, 4221 { }, 4222 { { 0, 1 } }, 4223 }, 4224 /* BPF_JMP | BPF_JSET | BPF_X */ 4225 { 4226 "JMP_JSET_X: if (0x3 & 0x2) return 1", 4227 .u.insns_int = { 4228 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4229 BPF_LD_IMM64(R1, 3), 4230 BPF_LD_IMM64(R2, 2), 4231 BPF_JMP_REG(BPF_JNE, R1, R2, 1), 4232 BPF_EXIT_INSN(), 4233 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4234 BPF_EXIT_INSN(), 4235 }, 4236 INTERNAL, 4237 { }, 4238 { { 0, 1 } }, 4239 }, 4240 { 4241 "JMP_JSET_X: if (0x3 & 0xffffffff) return 1", 4242 .u.insns_int = { 4243 BPF_ALU32_IMM(BPF_MOV, R0, 0), 4244 BPF_LD_IMM64(R1, 3), 4245 BPF_LD_IMM64(R2, 0xffffffff), 4246 BPF_JMP_REG(BPF_JNE, R1, R2, 1), 4247 BPF_EXIT_INSN(), 4248 BPF_ALU32_IMM(BPF_MOV, R0, 1), 4249 BPF_EXIT_INSN(), 4250 }, 4251 INTERNAL, 4252 { }, 4253 { { 0, 1 } }, 4254 }, 4255 { /* Mainly checking JIT here. */ 4256 "BPF_MAXINSNS: Maximum possible literals", 4257 { }, 4258 CLASSIC | FLAG_NO_DATA, 4259 { }, 4260 { { 0, 0xffffffff } }, 4261 .fill_helper = bpf_fill_maxinsns1, 4262 }, 4263 { /* Mainly checking JIT here. */ 4264 "BPF_MAXINSNS: Single literal", 4265 { }, 4266 CLASSIC | FLAG_NO_DATA, 4267 { }, 4268 { { 0, 0xfefefefe } }, 4269 .fill_helper = bpf_fill_maxinsns2, 4270 }, 4271 { /* Mainly checking JIT here. */ 4272 "BPF_MAXINSNS: Run/add until end", 4273 { }, 4274 CLASSIC | FLAG_NO_DATA, 4275 { }, 4276 { { 0, 0x947bf368 } }, 4277 .fill_helper = bpf_fill_maxinsns3, 4278 }, 4279 { 4280 "BPF_MAXINSNS: Too many instructions", 4281 { }, 4282 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, 4283 { }, 4284 { }, 4285 .fill_helper = bpf_fill_maxinsns4, 4286 }, 4287 { /* Mainly checking JIT here. */ 4288 "BPF_MAXINSNS: Very long jump", 4289 { }, 4290 CLASSIC | FLAG_NO_DATA, 4291 { }, 4292 { { 0, 0xabababab } }, 4293 .fill_helper = bpf_fill_maxinsns5, 4294 }, 4295 { /* Mainly checking JIT here. */ 4296 "BPF_MAXINSNS: Ctx heavy transformations", 4297 { }, 4298 CLASSIC, 4299 { }, 4300 { 4301 { 1, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) }, 4302 { 10, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) } 4303 }, 4304 .fill_helper = bpf_fill_maxinsns6, 4305 }, 4306 { /* Mainly checking JIT here. */ 4307 "BPF_MAXINSNS: Call heavy transformations", 4308 { }, 4309 CLASSIC | FLAG_NO_DATA, 4310 { }, 4311 { { 1, 0 }, { 10, 0 } }, 4312 .fill_helper = bpf_fill_maxinsns7, 4313 }, 4314 { /* Mainly checking JIT here. */ 4315 "BPF_MAXINSNS: Jump heavy test", 4316 { }, 4317 CLASSIC | FLAG_NO_DATA, 4318 { }, 4319 { { 0, 0xffffffff } }, 4320 .fill_helper = bpf_fill_maxinsns8, 4321 }, 4322 { /* Mainly checking JIT here. */ 4323 "BPF_MAXINSNS: Very long jump backwards", 4324 { }, 4325 INTERNAL | FLAG_NO_DATA, 4326 { }, 4327 { { 0, 0xcbababab } }, 4328 .fill_helper = bpf_fill_maxinsns9, 4329 }, 4330 { /* Mainly checking JIT here. */ 4331 "BPF_MAXINSNS: Edge hopping nuthouse", 4332 { }, 4333 INTERNAL | FLAG_NO_DATA, 4334 { }, 4335 { { 0, 0xabababac } }, 4336 .fill_helper = bpf_fill_maxinsns10, 4337 }, 4338 }; 4339 4340 static struct net_device dev; 4341 4342 static struct sk_buff *populate_skb(char *buf, int size) 4343 { 4344 struct sk_buff *skb; 4345 4346 if (size >= MAX_DATA) 4347 return NULL; 4348 4349 skb = alloc_skb(MAX_DATA, GFP_KERNEL); 4350 if (!skb) 4351 return NULL; 4352 4353 memcpy(__skb_put(skb, size), buf, size); 4354 4355 /* Initialize a fake skb with test pattern. */ 4356 skb_reset_mac_header(skb); 4357 skb->protocol = htons(ETH_P_IP); 4358 skb->pkt_type = SKB_TYPE; 4359 skb->mark = SKB_MARK; 4360 skb->hash = SKB_HASH; 4361 skb->queue_mapping = SKB_QUEUE_MAP; 4362 skb->vlan_tci = SKB_VLAN_TCI; 4363 skb->dev = &dev; 4364 skb->dev->ifindex = SKB_DEV_IFINDEX; 4365 skb->dev->type = SKB_DEV_TYPE; 4366 skb_set_network_header(skb, min(size, ETH_HLEN)); 4367 4368 return skb; 4369 } 4370 4371 static void *generate_test_data(struct bpf_test *test, int sub) 4372 { 4373 if (test->aux & FLAG_NO_DATA) 4374 return NULL; 4375 4376 /* Test case expects an skb, so populate one. Various 4377 * subtests generate skbs of different sizes based on 4378 * the same data. 4379 */ 4380 return populate_skb(test->data, test->test[sub].data_size); 4381 } 4382 4383 static void release_test_data(const struct bpf_test *test, void *data) 4384 { 4385 if (test->aux & FLAG_NO_DATA) 4386 return; 4387 4388 kfree_skb(data); 4389 } 4390 4391 static int filter_length(int which) 4392 { 4393 struct sock_filter *fp; 4394 int len; 4395 4396 if (tests[which].fill_helper) 4397 return tests[which].u.ptr.len; 4398 4399 fp = tests[which].u.insns; 4400 for (len = MAX_INSNS - 1; len > 0; --len) 4401 if (fp[len].code != 0 || fp[len].k != 0) 4402 break; 4403 4404 return len + 1; 4405 } 4406 4407 static void *filter_pointer(int which) 4408 { 4409 if (tests[which].fill_helper) 4410 return tests[which].u.ptr.insns; 4411 else 4412 return tests[which].u.insns; 4413 } 4414 4415 static struct bpf_prog *generate_filter(int which, int *err) 4416 { 4417 __u8 test_type = tests[which].aux & TEST_TYPE_MASK; 4418 unsigned int flen = filter_length(which); 4419 void *fptr = filter_pointer(which); 4420 struct sock_fprog_kern fprog; 4421 struct bpf_prog *fp; 4422 4423 switch (test_type) { 4424 case CLASSIC: 4425 fprog.filter = fptr; 4426 fprog.len = flen; 4427 4428 *err = bpf_prog_create(&fp, &fprog); 4429 if (tests[which].aux & FLAG_EXPECTED_FAIL) { 4430 if (*err == -EINVAL) { 4431 pr_cont("PASS\n"); 4432 /* Verifier rejected filter as expected. */ 4433 *err = 0; 4434 return NULL; 4435 } else { 4436 pr_cont("UNEXPECTED_PASS\n"); 4437 /* Verifier didn't reject the test that's 4438 * bad enough, just return! 4439 */ 4440 *err = -EINVAL; 4441 return NULL; 4442 } 4443 } 4444 /* We don't expect to fail. */ 4445 if (*err) { 4446 pr_cont("FAIL to attach err=%d len=%d\n", 4447 *err, fprog.len); 4448 return NULL; 4449 } 4450 break; 4451 4452 case INTERNAL: 4453 fp = bpf_prog_alloc(bpf_prog_size(flen), 0); 4454 if (fp == NULL) { 4455 pr_cont("UNEXPECTED_FAIL no memory left\n"); 4456 *err = -ENOMEM; 4457 return NULL; 4458 } 4459 4460 fp->len = flen; 4461 memcpy(fp->insnsi, fptr, fp->len * sizeof(struct bpf_insn)); 4462 4463 bpf_prog_select_runtime(fp); 4464 break; 4465 } 4466 4467 *err = 0; 4468 return fp; 4469 } 4470 4471 static void release_filter(struct bpf_prog *fp, int which) 4472 { 4473 __u8 test_type = tests[which].aux & TEST_TYPE_MASK; 4474 4475 switch (test_type) { 4476 case CLASSIC: 4477 bpf_prog_destroy(fp); 4478 break; 4479 case INTERNAL: 4480 bpf_prog_free(fp); 4481 break; 4482 } 4483 } 4484 4485 static int __run_one(const struct bpf_prog *fp, const void *data, 4486 int runs, u64 *duration) 4487 { 4488 u64 start, finish; 4489 int ret = 0, i; 4490 4491 start = ktime_to_us(ktime_get()); 4492 4493 for (i = 0; i < runs; i++) 4494 ret = BPF_PROG_RUN(fp, data); 4495 4496 finish = ktime_to_us(ktime_get()); 4497 4498 *duration = (finish - start) * 1000ULL; 4499 do_div(*duration, runs); 4500 4501 return ret; 4502 } 4503 4504 static int run_one(const struct bpf_prog *fp, struct bpf_test *test) 4505 { 4506 int err_cnt = 0, i, runs = MAX_TESTRUNS; 4507 4508 for (i = 0; i < MAX_SUBTESTS; i++) { 4509 void *data; 4510 u64 duration; 4511 u32 ret; 4512 4513 if (test->test[i].data_size == 0 && 4514 test->test[i].result == 0) 4515 break; 4516 4517 data = generate_test_data(test, i); 4518 ret = __run_one(fp, data, runs, &duration); 4519 release_test_data(test, data); 4520 4521 if (ret == test->test[i].result) { 4522 pr_cont("%lld ", duration); 4523 } else { 4524 pr_cont("ret %d != %d ", ret, 4525 test->test[i].result); 4526 err_cnt++; 4527 } 4528 } 4529 4530 return err_cnt; 4531 } 4532 4533 static __init int prepare_bpf_tests(void) 4534 { 4535 int i; 4536 4537 for (i = 0; i < ARRAY_SIZE(tests); i++) { 4538 if (tests[i].fill_helper && 4539 tests[i].fill_helper(&tests[i]) < 0) 4540 return -ENOMEM; 4541 } 4542 4543 return 0; 4544 } 4545 4546 static __init void destroy_bpf_tests(void) 4547 { 4548 int i; 4549 4550 for (i = 0; i < ARRAY_SIZE(tests); i++) { 4551 if (tests[i].fill_helper) 4552 kfree(tests[i].u.ptr.insns); 4553 } 4554 } 4555 4556 static __init int test_bpf(void) 4557 { 4558 int i, err_cnt = 0, pass_cnt = 0; 4559 int jit_cnt = 0, run_cnt = 0; 4560 4561 for (i = 0; i < ARRAY_SIZE(tests); i++) { 4562 struct bpf_prog *fp; 4563 int err; 4564 4565 pr_info("#%d %s ", i, tests[i].descr); 4566 4567 fp = generate_filter(i, &err); 4568 if (fp == NULL) { 4569 if (err == 0) { 4570 pass_cnt++; 4571 continue; 4572 } 4573 4574 return err; 4575 } 4576 4577 pr_cont("jited:%u ", fp->jited); 4578 4579 run_cnt++; 4580 if (fp->jited) 4581 jit_cnt++; 4582 4583 err = run_one(fp, &tests[i]); 4584 release_filter(fp, i); 4585 4586 if (err) { 4587 pr_cont("FAIL (%d times)\n", err); 4588 err_cnt++; 4589 } else { 4590 pr_cont("PASS\n"); 4591 pass_cnt++; 4592 } 4593 } 4594 4595 pr_info("Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed]\n", 4596 pass_cnt, err_cnt, jit_cnt, run_cnt); 4597 4598 return err_cnt ? -EINVAL : 0; 4599 } 4600 4601 static int __init test_bpf_init(void) 4602 { 4603 int ret; 4604 4605 ret = prepare_bpf_tests(); 4606 if (ret < 0) 4607 return ret; 4608 4609 ret = test_bpf(); 4610 4611 destroy_bpf_tests(); 4612 return ret; 4613 } 4614 4615 static void __exit test_bpf_exit(void) 4616 { 4617 } 4618 4619 module_init(test_bpf_init); 4620 module_exit(test_bpf_exit); 4621 4622 MODULE_LICENSE("GPL"); 4623