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